This adds the general_profit KSM sysfs knob and the process profit metric knobs to ksm_stat.
expose general_profit metric
The documentation mentions a general profit metric, however this metric is not calculated. In addition the formula depends on the size of internal structures, which makes it more difficult for an administrator to make the calculation. Adding the metric for a better user experience.
document general_profit sysfs knob
calculate ksm process profit metric
The ksm documentation mentions the process profit metric and how to calculate it. This adds the calculation of the metric.
mm: expose ksm process profit metric in ksm_stat
This exposes the ksm process profit metric in /proc/<pid>/ksm_stat. The documentation mentions the formula for the ksm process profit metric, however it does not calculate it. In addition the formula depends on the size of internal structures. So it makes sense to expose it.
Hi, Stefan, I think you should give some credits to me about my contributions on the concept and formula of ksm profit (process wide and system wide), it's kind of idea stealing.
Besides, the idea of Process control KSM was proposed by me last year although you use prctl instead of /proc fs. you even didn't CC my email. I think you should CC my email (xu.xin16@zte.com.cn) as least.
- document new procfs ksm knobs
Signed-off-by: Stefan Roesch shr@devkernel.io Reviewed-by: Bagas Sanjaya bagasdotme@gmail.com Acked-by: David Hildenbrand david@redhat.com Cc: David Hildenbrand david@redhat.com Cc: Johannes Weiner hannes@cmpxchg.org Cc: Michal Hocko mhocko@suse.com Cc: Rik van Riel riel@surriel.com Signed-off-by: Andrew Morton akpm@linux-foundation.org
Documentation/ABI/testing/sysfs-kernel-mm-ksm | 8 +++++++ Documentation/admin-guide/mm/ksm.rst | 5 ++++- fs/proc/base.c | 3 +++ include/linux/ksm.h | 4 ++++ mm/ksm.c | 21 +++++++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-ksm b/Documentation/ABI/testing/sysfs-kernel-mm-ksm index d244674a9480..6041a025b65a 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-ksm +++ b/Documentation/ABI/testing/sysfs-kernel-mm-ksm @@ -51,3 +51,11 @@ Description: Control merging pages across different NUMA nodes. When it is set to 0 only pages from the same node are merged, otherwise pages from all nodes can be merged together (default).
+What: /sys/kernel/mm/ksm/general_profit +Date: April 2023 +KernelVersion: 6.4 +Contact: Linux memory management mailing list linux-mm@kvack.org +Description: Measure how effective KSM is.
general_profit: how effective is KSM. The formula for the
calculation is in Documentation/admin-guide/mm/ksm.rst.
diff --git a/Documentation/admin-guide/mm/ksm.rst b/Documentation/admin-guide/mm/ksm.rst