aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorxu xin <[email protected]>2022-04-28 23:16:16 -0700
committerakpm <[email protected]>2022-04-28 23:16:16 -0700
commit7609385337a4feb6236e42dcd0df2185683ce839 (patch)
tree2ec02ae22d747eb005c0545d294ba3dac72c8750 /include
parentba91fb7dd03c4f463453f28af24851097a6547fb (diff)
ksm: count ksm merging pages for each process
Some applications or containers want to use KSM by calling madvise() to advise areas of address space to be MERGEABLE. But they may not know which applications are more likely to cause real merges in the deployment. If this patch is applied, it helps them know their corresponding number of merged pages, and then optimize their app code. As current KSM only counts the number of KSM merging pages(e.g. ksm_pages_sharing and ksm_pages_shared) of the whole system, we cannot see the more fine-grained KSM merging, for the upper application optimization, the merging area cannot be set easily according to the KSM page merging probability of each process. Therefore, it is necessary to add extra statistical means so that the upper level users can know the detailed KSM merging information of each process. We add a new proc file named as ksm_merging_pages under /proc/<pid>/ to indicate the involved ksm merging pages of this process. [[email protected]: fix comment typo, remove BUG_ON()s] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: xu xin <[email protected]> Reported-by: kernel test robot <[email protected]> Reviewed-by: Yang Yang <[email protected]> Reviewed-by: Ran Xiaokai <[email protected]> Reported-by: Zeal Robot <[email protected]> Cc: Kees Cook <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Ohhoon Kwon <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Stephen Brennan <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Feng Tang <[email protected]> Cc: Yang Yang <[email protected]> Cc: Ran Xiaokai <[email protected]> Cc: Zeal Robot <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mm_types.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 8834e38c06a4..87eddd509de2 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -655,6 +655,13 @@ struct mm_struct {
#ifdef CONFIG_IOMMU_SVA
u32 pasid;
#endif
+#ifdef CONFIG_KSM
+ /*
+ * Represent how many pages of this process are involved in KSM
+ * merging.
+ */
+ unsigned long ksm_merging_pages;
+#endif
} __randomize_layout;
/*