Re: [PATCH v5 0/2] ksm: count allocated rmap_items and update documentation

From: Andrew Morton
Date: Tue Aug 30 2022 - 20:41:34 EST


On Tue, 30 Aug 2022 14:37:31 +0000 xu xin <cgel.zte@xxxxxxxxx> wrote:

> KSM can save memory by merging identical pages, but also can consume
> additional memory, because it needs to generate rmap_items to save
> each scanned page's brief rmap information.
>
> To determine how beneficial the ksm-policy (like madvise), they are using
> brings, so we add a new interface /proc/<pid>/ksm_stat for each process
> The value "ksm_rmap_items" in it indicates the total allocated ksm
> rmap_items of this process.

I can see the usefulness and the code change is very simple, so I'll
queue it for testing and shall see what other reviewers have to say.

It's useful that the per-process file is called "ksm_stat", because we
may with to add additional content to it in the future. Because
concerns have been expressed (by Alexey) about the proliferation of
procfs files causing major memory use when something reads them all.
Putting more things in the same procfs files will help avoid this.