mbox series

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

Message ID 20220830143731.299702-1-xu.xin16@zte.com.cn (mailing list archive)
Headers show
Series ksm: count allocated rmap_items and update documentation | expand

Message

CGEL Aug. 30, 2022, 2:37 p.m. UTC
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.

The detailed description can be seen in the following patches' commit message.


-----------
v4->v5:
1. change ksm_rmp_items to ksm_rmap_items;
2. use /proc/*/ksm_stat as proc name rather than "ksm_rmap_items" and
   start filling it with the value "ksm_rmap_items" so that more values
   can be added in future.

v3->v4:
Fix the wrong writing format and some misspellings of the related documentaion.

v2->v3:
remake the patches based on the latest linux-next branch.

v1->v2:
Add documentation for the new item.

*** BLURB HERE ***

xu xin (2):
  ksm: count allocated ksm rmap_items for each process
  ksm: add profit monitoring documentation

 Documentation/admin-guide/mm/ksm.rst | 36 ++++++++++++++++++++++++++++
 fs/proc/base.c                       | 15 ++++++++++++
 include/linux/mm_types.h             |  5 ++++
 mm/ksm.c                             |  2 ++
 4 files changed, 58 insertions(+)

Comments

Andrew Morton Aug. 31, 2022, 12:38 a.m. UTC | #1
On Tue, 30 Aug 2022 14:37:31 +0000 xu xin <cgel.zte@gmail.com> 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.