xu xin <xu.xin.sc@xxxxxxxxx> writes: >> This adds the general_profit KSM sysfs knob and the process profit metric >> knobs to ksm_stat. >> >> 1) 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. >> >> 2) document general_profit sysfs knob >> >> 3) 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. >> >> 4) 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. > > I wasn't aware the formula that is described in the documentation is from you. I simply implemented the documented metrics. If you came up with it, happy to give you credit. > 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@xxxxxxxxxx) as least. > >> 5) document new procfs ksm knobs >> >> Signed-off-by: Stefan Roesch <shr@xxxxxxxxxxxx> >> Reviewed-by: Bagas Sanjaya <bagasdotme@xxxxxxxxx> >> Acked-by: David Hildenbrand <david@xxxxxxxxxx> >> Cc: David Hildenbrand <david@xxxxxxxxxx> >> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> >> Cc: Michal Hocko <mhocko@xxxxxxxx> >> Cc: Rik van Riel <riel@xxxxxxxxxxx> >> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> >> --- >> 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@xxxxxxxxx> >> +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