Re: [PATCH] mm: Add AnonZero accounting for zero-filled anonymous pages

From: David Hildenbrand (Arm)

Date: Mon Feb 16 2026 - 12:10:26 EST


On 2/16/26 18:01, Matthew Wilcox wrote:
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.
That's just like all of these entries (Rss, Anonymous, KSM) except the Pss ones behave.

--
Cheers,

David