In /proc/<pid>/ksm_stat, Add two extra ksm involvement items including
KSM_mergeable and KSM_merge_any. It helps administrators to
better know the system's KSM behavior at process level.
KSM_mergeable: yes/no
whether any VMAs of the process'mm are currently applicable to KSM.
KSM_merge_any: yes/no
whether the process'mm is added by prctl() into the candidate list
of KSM or not, and fully enabled at process level.
Signed-off-by: xu xin <xu.xin16@xxxxxxxxxx>
---
Changelog
=========
v2 -> v3:
Update the KSM_mergeable getting method: loop up if any vma is
mergeable to KSM.
https://lore.kernel.org/all/bc0e1cdd-2d9d-437c-8fc9-4df0e13c48c0@xxxxxxxxxx/
v1 -> v2:
replace the internal flag names with straightforward strings.
* MMF_VM_MERGEABLE -> KSM_mergeable
* MMF_VM_MERGE_ANY -> KSM_merge_any
fs/proc/base.c | 4 ++++
include/linux/ksm.h | 1 +
mm/ksm.c | 16 ++++++++++++++++
3 files changed, 21 insertions(+)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 18550c071d71..45e12560e698 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3217,6 +3217,10 @@ static int proc_pid_ksm_stat(struct seq_file *m, struct pid_namespace *ns,
seq_printf(m, "ksm_zero_pages %lu\n", mm->ksm_zero_pages);
seq_printf(m, "ksm_merging_pages %lu\n", mm->ksm_merging_pages);
seq_printf(m, "ksm_process_profit %ld\n", ksm_process_profit(mm));
+ seq_printf(m, "KSM_mergeable: %s\n",
+ ksm_process_mergeable(mm) ? "yes" : "no");
+ seq_printf(m, "KSM_merge_any: %s\n",
+ test_bit(MMF_VM_MERGE_ANY, &mm->flags) ? "yes" : "no");
Inconsistent "KSM" casing .
Excuse me, could you be more specific? I didn't get it