2024-04-25 12:58:33

by xu.xin16

[permalink] [raw]
Subject: [PATCH linux-next] ksm: add ksm involvement information for each process

From: xu xin <[email protected]>

In /proc/<pid>/ksm_stat, Add two extra ksm involvement items including
MMF_VM_MERGEABLE and MMF_VM_MERGE_ANY. It helps administrators to
better know the system's KSM behavior at process level.

MMF_VM_MERGEABLE: yes/no
whether a process'mm is added by madvise() into the candidate list
of KSM or not.
MMF_VM_MERGE_ANY: yes/no
whether a process'mm is added by prctl at process level into the
candidate list of KSM or not.

Signed-off-by: xu xin <[email protected]>
---
fs/proc/base.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 18550c071d71..421594b8510c 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, "MMF_VM_MERGEABLE: %s\n",
+ test_bit(MMF_VM_MERGEABLE, &mm->flags) ? "yes" : "no");
+ seq_printf(m, "MMF_VM_MERGE_ANY: %s\n",
+ test_bit(MMF_VM_MERGE_ANY, &mm->flags) ? "yes" : "no");
mmput(mm);
}

--
2.15.2


2024-04-25 13:01:18

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH linux-next] ksm: add ksm involvement information for each process

On 25.04.24 14:49, [email protected] wrote:
> From: xu xin <[email protected]>
>
> In /proc/<pid>/ksm_stat, Add two extra ksm involvement items including
> MMF_VM_MERGEABLE and MMF_VM_MERGE_ANY. It helps administrators to
> better know the system's KSM behavior at process level.
>
> MMF_VM_MERGEABLE: yes/no
> whether a process'mm is added by madvise() into the candidate list
> of KSM or not.
> MMF_VM_MERGE_ANY: yes/no
> whether a process'mm is added by prctl at process level into the
> candidate list of KSM or not.
>
> Signed-off-by: xu xin <[email protected]>
> ---
> fs/proc/base.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 18550c071d71..421594b8510c 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, "MMF_VM_MERGEABLE: %s\n",
> + test_bit(MMF_VM_MERGEABLE, &mm->flags) ? "yes" : "no");
> + seq_printf(m, "MMF_VM_MERGE_ANY: %s\n",
> + test_bit(MMF_VM_MERGE_ANY, &mm->flags) ? "yes" : "no");

Not sure if exposing these internal flag names is appropriate. Better
describe what they do.

--
Cheers,

David / dhildenb