From: Wenchao Hao <haowenchao22@gmail.com>
To: Kiryl Shutsemau <kirill@shutemov.name>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] mm: only set fault addrsss' access bit in do_anonymous_page
Date: Thu, 12 Feb 2026 10:08:35 +0800 [thread overview]
Message-ID: <CAOptpSNSOy5=-M_VkZp=KwDc5HR41ynYnvLrO5O+UesYSKYA8Q@mail.gmail.com> (raw)
In-Reply-To: <aYxhgHcTZMJx99fi@thinkstation>
On Wed, Feb 11, 2026 at 7:03 PM Kiryl Shutsemau <kirill@shutemov.name> wrote:
>
> On Wed, Feb 11, 2026 at 09:00:45AM +0800, Wenchao Hao wrote:
> > On Tue, Feb 10, 2026 at 7:56 PM Kiryl Shutsemau <kirill@shutemov.name> wrote:
> > >
> > > On Tue, Feb 10, 2026 at 12:34:56PM +0800, Wenchao Hao wrote:
> > > > When do_anonymous_page() creates mappings for huge pages, it currently sets
> > > > the access bit for all mapped PTEs (Page Table Entries) by default.
> > > >
> > > > This causes an issue where the Referenced field in /proc/pid/smaps cannot
> > > > distinguish whether a page was actually accessed.
> > > >
> > > > So here introduces a new interface, set_anon_ptes(), which only sets the
> > > > access bit for the PTE corresponding to the faulting address. This allows
> > > > accurate tracking of page access status in /proc/pid/smaps before memory
> > > > reclaim scan the folios.
> > > >
> > > > During memory reclaim: folio_referenced() checks and clears the access bits
> > > > of PTEs, rmap verifies all PTEs under a folio. If any PTE mapped subpage of
> > > > folio has access bit set, the folio is retained during reclaim. So only
> > > > set the access bit for the faulting PTE in do_anonymous_page() is safe, as
> > > > it does not interfere with reclaim decisions.
> > >
> > > We had similar discussion about faultaround and briefly made it produce
> > > old ptes, but it caused performance regression as old ptes require
> > > additional pagewalk to set accessed bit on touch. It got reverted,
> > > but arch can opt-in for setting up old ptes for non-fault address.
> > >
> > > See commits:
> > >
> > > 5c0a85fad949 ("mm: make faultaround produce old ptes")
> > > 315d09bf30c2 ("Revert "mm: make faultaround produce old ptes"")
> > > 46bdb4277f98 ("mm: Allow architectures to request 'old' entries when prefaulting")
> > >
> > It does look similar—our modifications both revolve around whether pre-mapped
> > PTEs should be marked as "new."
> >
> > Was there any analysis into why your changes led to performance regressions?
>
> As I mentioned, my theory was that it is due to an additional pagewalks
> CPU has to do to flip access bit when it touches the memory, but I
> didn't profile it to confirm.
>
Thanks for your reply.
My change is mainly for debugging purposes and targeted at huge pages.
The only place I can see that might relate to the access bit of
contiguous huge pages is memory reclaim.
However, the huge page reclaim logic checks the access status of the
entire folio, so my conclusion is that this change should not affect
performance.
As for the overhead of the CPU flipping access bits you mentioned, it
cannot be determined at this point.
> --
> Kiryl Shutsemau / Kirill A. Shutemov
prev parent reply other threads:[~2026-02-12 2:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 4:34 Wenchao Hao
2026-02-10 9:07 ` David Hildenbrand (Arm)
2026-02-11 0:49 ` Wenchao Hao
2026-02-11 4:18 ` Dev Jain
2026-02-12 1:42 ` Wenchao Hao
2026-02-12 5:04 ` Dev Jain
2026-02-11 9:05 ` David Hildenbrand (Arm)
2026-02-12 1:57 ` Wenchao Hao
2026-02-12 8:54 ` David Hildenbrand (Arm)
2026-02-13 9:02 ` Wenchao Hao
2026-02-13 9:07 ` David Hildenbrand (Arm)
2026-02-13 14:52 ` Wenchao Hao
2026-02-13 15:08 ` David Hildenbrand (Arm)
2026-02-10 11:56 ` Kiryl Shutsemau
2026-02-11 1:00 ` Wenchao Hao
2026-02-11 11:03 ` Kiryl Shutsemau
2026-02-12 2:08 ` Wenchao Hao [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='CAOptpSNSOy5=-M_VkZp=KwDc5HR41ynYnvLrO5O+UesYSKYA8Q@mail.gmail.com' \
--to=haowenchao22@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
/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