DAMON development mailing list
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: Kyuwon Cho <kyuwon.cho@skku.edu>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Quanmin Yan <yanquanmin1@huawei.com>,
	damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [PATCH] mm/damon/paddr: prevent address wrap in action walks
Date: Thu,  3 Dec 2026 17:53:23 -0800	[thread overview]
Message-ID: <20261204015323.739742-1-sj@kernel.org> (raw)
In-Reply-To: <179614474316.1073623.13833808548597202010@skku.edu>

Hello Kyuwon,

On Fri,  4 Dec 2026 01:43:55 +0900 Kyuwon Cho <kyuwon.cho@skku.edu> wrote:

> The physical-address DAMOS action loops advance their cursor by PAGE_SIZE
> or folio_size().  A region whose converted end is near the maximum
> physical address can make that addition wrap to zero.  The loop condition
> remains true and the DAMON worker scans almost the entire physical address
> domain.  Control operations such as damon_stop() then cannot complete:
> 
>   INFO: task test:117 blocked for more than 10 seconds.
>   Call Trace:
>    __schedule (kernel/sched/core.c:7437)
>    schedule (kernel/sched/core.c:7529)
>    schedule_timeout (kernel/time/sleep_timeout.c:75)
>    wait_for_completion (kernel/sched/completion.c:153)
>    kthread_stop (kernel/kthread.c:760)
>    kthread_stop_put (kernel/kthread.c:781)
>    damon_stop (mm/damon/core.c:2207)
>    kernfs_fop_write_iter (fs/kernfs/file.c:345)

Thank you for finding and sharing this problem!

> 
> Calculate each converted end once

I agree this is a good optimization.  But not related to the abovely explained
problem.  Hence shouldn't be a part of this patch, in my opinion.  Please split
the change out to another patch, and post separately.

> and saturate every page or folio advance
> at that end.

Makes sense to me.

> Apply the same cursor handling to pageout, LRU deactivation,
> migration, and stat actions because all four use the same open-ended
> addition.

Doing these all in a single patch could make it difficult to backport on
certain stable kernels.  Could you please find 'Fixes:' for each of the four
uses, and make patches for the each fix?

> 
> Fixes: 85246435b249 ("mm/damon/paddr: support addr_unit for DAMOS_PAGEOUT")

I think the fix patches would deserve Cc: stable@.

> Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
> ---
> The issue was found by an LLM-guided test generator that we are
> developing as a research prototype.  The reproducer configures one paddr
> region whose addr_unit conversion ends at PHYS_ADDR_MAX, starts a DAMOS
> action, and requests that DAMON stop.  With the patch the cursor reaches
> the region end without wrapping and the stop request returns.
> 
> Found and tested on mainline fe6ff8d5d675 (v7.4-rc5); the patch is
> against the DAMON next tree at 88b4c437ff4c.
> 
>  mm/damon/paddr.c | 46 ++++++++++++++++++++++++++++++----------------
>  1 file changed, 30 insertions(+), 16 deletions(-)
> 
> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
> index 2292f0d1aca9..cb67e0cd657d 100644
> --- a/mm/damon/paddr.c
> +++ b/mm/damon/paddr.c
> @@ -36,6 +36,12 @@ static unsigned long damon_pa_core_addr(
>  	return pa / addr_unit;
>  }
>  
> +static phys_addr_t damon_pa_next_addr(phys_addr_t addr, phys_addr_t end,
> +				      unsigned long size)
> +{
> +	return end - addr <= size ? end : addr + size;

I'd prefer having safe case first.  E.g.,

    return addr < end - size ? addr + size : end;

Could you please use that?

Also, as the code looks intuitive, I don't really feel like this helper
function is needed.  What do you think?


Thanks,
SJ

[...]

  parent reply	other threads:[~2026-12-04  1:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 16:43 [PATCH] mm/damon/paddr: prevent address wrap in action walks Kyuwon Cho
2026-12-03 17:17 ` sashiko-bot
2026-12-03 17:38 ` Aveline Noir
2026-12-04  1:55   ` SJ Park
2026-12-04  1:53 ` SJ Park [this message]
2026-12-04  2:26   ` SJ Park

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=20261204015323.739742-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=kyuwon.cho@skku.edu \
    --cc=linux-mm@kvack.org \
    --cc=yanquanmin1@huawei.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