From: Wenchao Hao <haowenchao22@gmail.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.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: [PATCH] mm: Add AnonZero accounting for zero-filled anonymous pages
Date: Mon, 16 Feb 2026 23:10:11 +0800 [thread overview]
Message-ID: <CAOptpSMCDnnZFSiMrGwA4Kc5Zu=4-6giVbbzMa5UEEE2QzvtoA@mail.gmail.com> (raw)
In-Reply-To: <db1fa367-0fd1-48a1-a58c-73e72cfbdc05@kernel.org>
On Mon, Feb 16, 2026 at 8:15 PM David Hildenbrand (Arm)
<david@kernel.org> wrote:
>
> On 2/14/26 09:45, Wenchao Hao wrote:
> > Add kernel command line option "count_zero_page" to track anonymous pages
> > have been allocated and mapped to userspace but zero-filled.
>
> "count_zero_page" is rather sub-optimal parameter name. "anonzero_in_smaps" or sth like that?
>
Your naming suggestion is indeed better than mine. If this patch is still needed
for further development, I will modify it according to your advice.
> Still wondering if there could be a better way to enable this dynamically.
>
> In particular, not using a core parameter.
>
> If you use a module parameter, you can just set on the cmdline
>
> proc.anonzero_in_smaps=1
>
> And dynamically set/observe it in
>
> /sys/module/proc/parameters/anonzero_in_smaps
>
Regarding the use of module parameters versus core_param, I think
either approach is ok.
Currently, the core_param I'm using also supports two modification methods:
1. Command line parameter: count_zero_page=Y
2. After system boot, view or modify it via
/sys/module/kernel/parameters/count_zero_page
It is true that this modification would be more appropriately placed
in the proc module,
which aligns with your earlier suggestion.
If there is a possibility of further iteration on this change, I will
move it to the proc module instead
of using a core_param
> >
> > This feature is mainly used to debug large folio mechanism, which
> > pre-allocates and map more pages than actually needed, leading to memory
> > waste from unaccessed pages.
> >
> > Export the result in /proc/pid/smaps as "AnonZero" field.
> >
> > Link: https://lore.kernel.org/linux-mm/20260210043456.2137482-1-haowenchao22@gmail.com/
> > Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
> > ---
> > Documentation/filesystems/proc.rst | 5 +++++
> > fs/proc/task_mmu.c | 10 ++++++++++
> > 2 files changed, 15 insertions(+)
> >
> > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst
> > index b0c0d1b45b99..573c8b015e39 100644
> > --- a/Documentation/filesystems/proc.rst
> > +++ b/Documentation/filesystems/proc.rst
> > @@ -545,6 +545,11 @@ replaced by copy-on-write) part of the underlying shmem object out on swap.
> > does not take into account swapped out page of underlying shmem objects.
> > "Locked" indicates whether the mapping is locked in memory or not.
> >
> > +"AnonZero" shows the size of anonymous pages that have never been accessed
> > +after mapping, and it can reflect the memory waste caused by huge pages.
>
> That's not correct. They could be read/written, but with zeroes.
>
> > +Implemented by scanning the size of zero-filled pages of the VMA. It
> > +is default disabled, and enabled via cmdline param "count_zero_page=true".
>
> Probably best to keep it simpler:
>
> "AnonZero" shows the size of anonymous pages that contain zeroes. Zero-filled
> pages can indicate memory waste caused by memory-overallocation with (m)THPs.
> Availability is controlled through XYZ.
>
As with your earlier suggestion, if this change is to be iterated on
further, I will update it according
to your suggestion.
Thanks.
> --
> Cheers,
>
> David
next prev parent reply other threads:[~2026-02-16 15:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-14 8:45 Wenchao Hao
2026-02-16 11:34 ` Kiryl Shutsemau
2026-02-16 11:45 ` David Hildenbrand (Arm)
2026-02-16 11:58 ` Kiryl Shutsemau
2026-02-16 12:19 ` David Hildenbrand (Arm)
2026-02-16 15:59 ` Wenchao Hao
2026-02-16 16:42 ` Michal Hocko
2026-02-16 16:56 ` David Hildenbrand (Arm)
2026-02-16 17:10 ` Michal Hocko
2026-02-16 17:17 ` David Hildenbrand (Arm)
2026-02-16 16:54 ` Kiryl Shutsemau
2026-02-16 17:01 ` Matthew Wilcox
2026-02-16 17:10 ` David Hildenbrand (Arm)
2026-02-16 17:18 ` Kiryl Shutsemau
2026-02-16 12:15 ` David Hildenbrand (Arm)
2026-02-16 15:10 ` Wenchao Hao [this message]
2026-02-16 15:18 ` David Hildenbrand (Arm)
2026-02-16 14:22 ` Matthew Wilcox
2026-02-16 15:55 ` Wenchao Hao
2026-02-16 17:03 ` Matthew Wilcox
2026-02-17 15:22 ` Wenchao Hao
2026-02-17 20:29 ` David Hildenbrand (Arm)
2026-02-17 21:53 ` Kiryl Shutsemau
2026-02-19 2:11 ` Wenchao Hao
2026-02-18 7:52 ` Michal Hocko
2026-02-19 2:47 ` Wenchao Hao
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='CAOptpSMCDnnZFSiMrGwA4Kc5Zu=4-6giVbbzMa5UEEE2QzvtoA@mail.gmail.com' \
--to=haowenchao22@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--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