Linux-Fsdevel Archive mirror
 help / color / mirror / Atom feed
From: xu xin <xu.xin.sc@gmail.com>
To: david@redhat.com
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, shr@devkernel.io,
	si.hao@zte.com.cn, xu.xin16@zte.com.cn
Subject: Re: [PATCH linux-next v2] ksm: add ksm involvement information for each process
Date: Sat, 11 May 2024 08:12:24 +0000	[thread overview]
Message-ID: <20240511081224.637842-1-xu.xin16@zte.com.cn> (raw)
In-Reply-To: <bc0e1cdd-2d9d-437c-8fc9-4df0e13c48c0@redhat.com>

>> @@ -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",
>> +				test_bit(MMF_VM_MERGEABLE, &mm->flags) ? "yes" : "no");
>
>All it *currently* means is "we called __ksm_enter()" once. It does not 
>mean that KSM is still enabled for that process and that any VMA would 
>be considered for merging.
>
>I don't think we should expose this.
>
>That information can be more reliably had by looking at
>
>"/proc/pid/smaps" and looking for "mg".
>
>Which tells you exactly if any VMA (and which) is currently applicable 
>to KSM.
>
>
>> +		seq_printf(m, "KSM_merge_any: %s\n",
>> +				test_bit(MMF_VM_MERGE_ANY, &mm->flags) ? "yes" : "no");
>
>This makes more sense to export. It's the same as reading 
>prctl(PR_GET_MEMORY_MERGE).
>
>The man page [1] calls it simply "KSM has been enabled for this 
>process", so process-wide KSM compared to per-VMA KSM.
>
>"KSM_enabled:"
>
>*might* be more reasonable in the context of PR_SET_MEMORY_MERGE.
>
>It wouldn't tell though if KSM is enabled on the system, though.
>

I agree it. But I hope admistrators can tell if the process enabled KSM-scan
by madvise or prctl. At this point, only "/proc/pid/smaps"  is not enough.

So can we add a item "KSM_enabled" which has three value as follows?

1) "prctl": KSM has been fully enabled for this process.

2) "madvise": KSM has been enabled on parts of VMA for this process.

3) "never": KSM has been never enabled for this process.

Just refer to the semantics of '/sys/kernel/mm/transparent_hugepage/enabled' 

      reply	other threads:[~2024-05-11  8:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26  1:46 [PATCH linux-next v2] ksm: add ksm involvement information for each process xu.xin16
2024-04-26  8:13 ` David Hildenbrand
2024-05-11  8:12   ` xu xin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240511081224.637842-1-xu.xin16@zte.com.cn \
    --to=xu.xin.sc@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shr@devkernel.io \
    --cc=si.hao@zte.com.cn \
    --cc=xu.xin16@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).