linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yu Zhao <yuzhao@google.com>
To: Jinyu Tang <tjytimi@163.com>
Cc: yuanchu@google.com, akpm@linux-foundation.org,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	falcon@tinylab.org, ttjjyystupid@163.com
Subject: Re: [PATCH v1] mm: multi-gen LRU: reduce repeated scans in rmap
Date: Sun, 15 Jan 2023 15:46:54 -0700	[thread overview]
Message-ID: <CAOUHufaSajkrrkZKx+htAA3gORhB1dEO98=jOT_tzQ9HjUxvhw@mail.gmail.com> (raw)
In-Reply-To: <20230115125721.3553-1-tjytimi@163.com>

On Sun, Jan 15, 2023 at 5:57 AM Jinyu Tang <tjytimi@163.com> wrote:
>
> The folio is physically and virtually contiguous. If a folio have
> more than one pages, lru_gen_look_around() will run several times in
> the while loop in folio_referenced_one(), but most of times is
> unnecessary. Because these pages always belong to the same pmd and
> vma, lru_gen_look_around() will scan the same range.

Thanks -- the commit message is quite clear, so I think I understand
what you're thinking.

Let me clarify:
1. First of all, there are no repeated scans, because after
lru_gen_look_around() clears the A-bit in a range, the pte_young()
test stops it from going into the same range again.
2. Of course, pte_young() can become true later, but this is not a
problem because it's cache hot.
3. Physically and virtually contiguous mapping existed before folios:
a THP can be mapped by 512 PTEs.

>         while (page_vma_mapped_walk(&pvmw)) {
>                 address = pvmw.address;
> @@ -825,7 +826,13 @@ static bool folio_referenced_one(struct folio *folio,
>                 if (pvmw.pte) {
>                         if (lru_gen_enabled() && pte_young(*pvmw.pte) &&
>                             !(vma->vm_flags & (VM_SEQ_READ | VM_RAND_READ))) {
> -                               lru_gen_look_around(&pvmw);
> +                               unsigned long pmd_now = pvmw.address & PMD_MASK;
> +                               unsigned long pmd_former = former_address & PMD_MASK;
> +
> +                               if ((!former_address) || (pmd_now != pmd_former)) {
> +                                       lru_gen_look_around(&pvmw);
> +                                       former_address = pvmw.address;
> +                               }
>                                 referenced++;
>                         }


           reply	other threads:[~2023-01-15 22:47 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20230115125721.3553-1-tjytimi@163.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOUHufaSajkrrkZKx+htAA3gORhB1dEO98=jOT_tzQ9HjUxvhw@mail.gmail.com' \
    --to=yuzhao@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tjytimi@163.com \
    --cc=ttjjyystupid@163.com \
    --cc=yuanchu@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox