All of lore.kernel.org
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: Nathan Gao <zcgao@amazon.com>
Cc: SJ Park <sj@kernel.org>,
	akpm@linux-foundation.org, damon@lists.linux.dev,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	baolin.wang@linux.alibaba.com, david@kernel.org,
	ryan.roberts@arm.com
Subject: Re: [PATCH v2] mm/damon/vaddr: use a page-aligned address for the sampling walks
Date: Tue,  1 Sep 2026 17:16:06 -0700	[thread overview]
Message-ID: <20260902001607.107382-1-sj@kernel.org> (raw)
In-Reply-To: <20260901202556.39515-1-zcgao@amazon.com>

On Tue, 1 Sep 2026 13:25:36 -0700 Nathan Gao <zcgao@amazon.com> wrote:

> On Mon, 31 Aug 2026 18:35:50 -0700 SJ Park <sj@kernel.org> wrote:
> 
> > On Mon, 31 Aug 2026 15:11:51 -0700 Nathan Gao <zcgao@amazon.com> wrote:
[...]
> > > 
> > > Otherwise the page is writable, the PTE_AF clearing succeeds silently
> > > and the damage only surfaces later, in whatever happened to own the
> > > page, so the backtrace is unrelated to DAMON and differs between runs.
> > 
> > Urgh, this must have been a painful debugging.  Sorry about that, and
> > appreciate your great work on this!
> > 
> 
> No problem at all!  Had fun digging into this. 

Thank you for that kind ack!

> 
> > > 
> > > Align the address down to a page boundary in damon_va_mkold() and
> > > damon_va_young(), the two users that pass it into a page table walk. It
> > > is the address of the page to sample, so this matches its intended
> > > meaning. r->sampling_addr itself is left as is, so the sampling and
> > > region bookkeeping semantics are unchanged.
> > 
> > I'm still wondering if it makes sense to restore unaligned address support in
> > contpte_test_and_clear_young_ptes() as a long term fix.
> > 
> 
> I'd appreciate Baolin's thoughts here.  If it turns out callers are
> expected to do the alignment, it would be better to have a WARN to expose
> the issue.

I agree.  If we conclude contpte helpers are not the right place to warn, we
should do that at least in DAMON internal helpers.

[...]
> > > --- a/mm/damon/vaddr.c
> > > +++ b/mm/damon/vaddr.c
> > > @@ -349,6 +349,9 @@ static void damon_va_mkold(struct mm_struct *mm, unsigned long addr)
> > >  		.hugetlb_entry = damon_mkold_hugetlb_entry,
> > >  	};
> > >  
> > > +	/* Arch helpers can derive a page range from @addr; align it down. */
> > > +	addr = PAGE_ALIGN_DOWN(addr);
> > > +
> > >  	damon_va_walk_page_range(mm, addr, addr + 1, &damon_mkold_ops, NULL);
> > 
> > Could we do the alignment just before passing the addr to
> > contpte_test_and_clear_young_ptes(), which is the exact function that disallows
> > the unaligned address?
> > 
> 
> Sent a v3.  It moves the alignment into damon_ptep_mkold(), the only place
> in DAMON that reaches contpte_test_and_clear_young_ptes(), so it is as
> close to that function as DAMON can get:
> 
> https://lore.kernel.org/all/20260901201001.33271-1-zcgao@amazon.com/

Thank you, I left comments.  Please forgive me being picky there.


Thanks,
SJ

[...]


      reply	other threads:[~2026-09-02  0:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 22:11 [PATCH v2] mm/damon/vaddr: use a page-aligned address for the sampling walks Nathan Gao
2026-08-31 22:39 ` sashiko-bot
2026-09-01  1:27   ` SJ Park
2026-09-01  1:35 ` SJ Park
2026-09-01 20:25   ` Nathan Gao
2026-09-02  0:16     ` SJ Park [this message]

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=20260902001607.107382-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=damon@lists.linux.dev \
    --cc=david@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=zcgao@amazon.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.