linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Hao <haowenchao22@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
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: [PATCH] mm: Add AnonZero accounting for zero-filled anonymous pages
Date: Mon, 16 Feb 2026 23:55:31 +0800	[thread overview]
Message-ID: <CAOptpSMXu384dbhAeUhRVpaqG-zACfSn22dOpyhs1rD=v9+MOg@mail.gmail.com> (raw)
In-Reply-To: <aZMoQw-86_FtUvLU@casper.infradead.org>

On Mon, Feb 16, 2026 at 10:23 PM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Sat, Feb 14, 2026 at 04:45:14PM +0800, 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.
> >
> > 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.
>
> Why are you trying to get this upstream when you admitted in an earlier
> email this is just for your internal use?
>

I see this as a debugging feature, not limited to internal use only.

Our real goal is to gain more precise visibility into how system memory is used.
A basic requirement is to measure the memory overhead caused by anonymous
hugepages that have been pre-allocated but never accessed.
With this information, we can implement various policies:
 - Allocate only 4K pages for applications that suffer severe memory waste from
   anonymous hugepages.
- Evaluate per-process hugepage waste during low system load and proactively
   split hugepages accordingly.

So I believe this debugging feature still provides value when merged upstream.
Currently, there is no effective way to account for memory waste from
pre-allocated
but unused anonymous hugepages, and this feature fills that gap. Or do you have
any suggestions about how to get this info?

> Why do you think that "unaccessed pages" are the only, or even the
> largest source of extra memory consumption?  The vast majority of files
> are never mmaped.
>

In my view, memory waste from anonymous hugepages is less acceptable than that
from file pages.

Although file pages may also be unmapped, a cache hit can still reduce
I/O overhead.
By contrast, pre-allocated anonymous hugepages that are never accessed represent
pure waste.

Furthermore, the total number of unmapped file pages can already be
estimated from
/proc/meminfo, so we can already apply policies to control file page waste.

From my research, many memory-sensitive environments already apply
special policies
for file pages—for example, the RFC patch from vivo that manages
readahead file pages
separately:
https://lore.kernel.org/linux-mm/20250916072226.220426-1-liulei.rjpt@vivo.com/

But file page waste is not the main point I want to focus on here.

Thanks.


  reply	other threads:[~2026-02-16 15:55 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
2026-02-16 15:18     ` David Hildenbrand (Arm)
2026-02-16 14:22 ` Matthew Wilcox
2026-02-16 15:55   ` Wenchao Hao [this message]
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='CAOptpSMXu384dbhAeUhRVpaqG-zACfSn22dOpyhs1rD=v9+MOg@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 \
    --cc=willy@infradead.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