Re: [PATCH v4 1/2] ksm: count allocated ksm rmap_items for each process

From: Alexey Dobriyan
Date: Sun Aug 28 2022 - 14:42:10 EST


On Wed, Aug 24, 2022 at 12:46:15PM +0000, xu xin wrote:
> +static int proc_pid_ksm_rmp_items(struct seq_file *m, struct pid_namespace *ns,
> + struct pid *pid, struct task_struct *task)
> +{
> + struct mm_struct *mm;
> +
> + mm = get_task_mm(task);
> + if (mm) {
> + seq_printf(m, "%lu\n", mm->ksm_rmp_items);
> + mmput(mm);
> + }
> +
> + return 0;
> +}
> #endif /* CONFIG_KSM */
>
> #ifdef CONFIG_STACKLEAK_METRICS
> @@ -3334,6 +3347,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> #endif
> #ifdef CONFIG_KSM
> ONE("ksm_merging_pages", S_IRUSR, proc_pid_ksm_merging_pages),
> + ONE("ksm_rmp_items", S_IRUSR, proc_pid_ksm_rmp_items),
> #endif

Another tiny /proc/$pid/ file?

Guys, this problem with "find /proc" instantiating megabytes is not
getting better only worse.

How did KSM didn't get its own /proc/*/ksm file with many values?

Maybe add /proc/*/ksm and start filling it with stuff leaving
/proc/*/ksm_merging_pages alone?