mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: Aveline Noir <jm5905938@gmail.com>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/damon/paddr: skip hugetlb folios as a whole in pageout
Date: Tue, 17 Nov 2026 06:33:51 -0800	[thread overview]
Message-ID: <20261117143352.121497-1-sj@kernel.org> (raw)
In-Reply-To: <20261117-fix-damon-hugetlb-pageout-20261117-v1-1-054ef8760a92@gmail.com>

Hello Aveline,

On Tue, 17 Nov 2026 17:06:54 +1100 Aveline Noir <jm5905938@gmail.com> wrote:

> damon_pa_pageout() uses damon_get_folio(), which rejects hugetlb folios
> because they are not on the LRU.  The loop then advances by PAGE_SIZE and
> looks up every base page of a hugetlb folio that cannot be reclaimed.
> 
> Use damon_get_monitor_folio() and skip a hugetlb folio as a whole by
> advancing to its end.  Do this before the filters, the accounting and the
> last_applied check, so that adjacent regions within the same hugetlb
> folio are not walked by base page either.  Test the LRU flag first to keep
> the hugetlb check off the path of ordinary LRU folios.
> 
> In a pageout microbenchmark in an x86-64 KVM guest, traversal time
> dropped by about 99.7% for regions covering whole 2 MiB hugetlb folios.
> As a side note, there is a small overhead of about 1 ns per region when
> each region is a single 4 KiB page.

Thank you for this patch.

> 
> Signed-off-by: Aveline Noir <jm5905938@gmail.com>
> ---
> Tested in x86-64 KVM guests.  KUnit passes.  The damos_quota.py selftest
> can also fail without this patch; I will send a separate fix for it.
> ---
>  mm/damon/paddr.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
> index 5b773012a876..aca48bf752c8 100644
> --- a/mm/damon/paddr.c
> +++ b/mm/damon/paddr.c
> @@ -268,7 +268,9 @@ static unsigned long damon_pa_pageout(struct damon_region *r,
>  
>  	addr = damon_pa_phys_addr(r->ar.start, addr_unit);
>  	while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
> -		folio = damon_get_folio(PHYS_PFN(addr));
> +		folio = damon_get_monitor_folio(PHYS_PFN(addr));
> +		if (folio && !folio_test_lru(folio) && folio_test_hugetlb(folio))

Why do we need both !folio_test_lru() and folio_test_hugetlb() here?  Could
hugetlb folio in lru list exist?  Could folios not in lru list be reclaimed?

Would only !folio_test_lru() suffice?  If so, the patch subject and description
may also better to be updated.

> +			goto put_folio;
>  		if (damon_pa_invalid_damos_folio(folio, s)) {
>  			addr += PAGE_SIZE;
>  			continue;
> 
> ---
> base-commit: 67f3b04b277373438f17300e056306adbd9edf7b
> change-id: 20261117-fix-damon-hugetlb-pageout-20261117-a4e03d9d5a5b
> 
> Best regards,
> --  
> Aveline Noir <jm5905938@gmail.com>
> 
> 


Thanks,
SJ

  reply	other threads:[~2026-11-17 14:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  6:06 Aveline Noir
2026-11-17 14:33 ` SJ Park [this message]
2026-11-17 15:54   ` Aveline Noir

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=20261117143352.121497-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=jm5905938@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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

all inboxes | Powered by JetHome®