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

From: Kiryl Shutsemau

Date: Mon Feb 16 2026 - 12:18:17 EST


On Mon, Feb 16, 2026 at 05:01:51PM +0000, 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. 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?

Are describing THP shrinker? :)

I don't particular care about original poster use-case. I want to see
more scalable way to access memory statistic information in general.
smaps is slow, because it collects information user doesn't care about.

--
Kiryl Shutsemau / Kirill A. Shutemov