Re: [PATCH] mm: Add AnonZero accounting for zero-filled anonymous pages
From: Matthew Wilcox
Date: Mon Feb 16 2026 - 12:02:07 EST
On Mon, Feb 16, 2026 at 04:54:05PM +0000, Kiryl Shutsemau wrote:
> What I would like to see in the kernel is a syscall that return the
> memory stats in binary form. Something like
>
> size_t memstat(int pidfd, struct memstat memstatbuf[], size_t n,
> unsigned long flags, unsigned long start, unsigned long end);
>
> The syscall will fill up to n memstatbufs, one per-VMA. What exactly
> filled there defined by flags. The return value is how many memstatbuf
> is populated. The caller can call it multiple times to walk address
> space it is interested in.
>
> We also can have a flag that mirrors smaps_rollup behaviour and collect
> all the data into a single memstatbuf.
But is that what we want? Let's say a process allocates a 2MB THP, uses
12kB of it and then forks. A lot. Now all children that haven't called
exec() see the wasted 2036kB. Would we rather have something that scans
(say) the LRU list looking for zero memory?