@@ -57,6 +57,7 @@ void folio_migrate_ksm(struct folio *newfolio, struct folio *folio);
#ifdef CONFIG_PROC_FS
long ksm_process_profit(struct mm_struct *);
+const char *ksm_merge_type(struct mm_struct *mm);
#endif /* CONFIG_PROC_FS */
#else /* !CONFIG_KSM */
@@ -3030,6 +3030,17 @@ long ksm_process_profit(struct mm_struct *mm)
return (long)mm->ksm_merging_pages * PAGE_SIZE -
mm->ksm_rmap_items * sizeof(struct ksm_rmap_item);
}
+
+/* Return merge type name as string. */
+const char *ksm_merge_type(struct mm_struct *mm)
+{
+ if (test_bit(MMF_VM_MERGE_ANY, &mm->flags))
+ return "process";
+ else if (test_bit(MMF_VM_MERGEABLE, &mm->flags))
+ return "madvise";
+ else
+ return "none";
+}
#endif /* CONFIG_PROC_FS */
#ifdef CONFIG_SYSFS
This adds the ksm_merge_type function. The function returns the merge type for the process. For madvise it returns "madvise", for prctl it returns "process" and otherwise it returns "none". Signed-off-by: Stefan Roesch <shr@devkernel.io> --- include/linux/ksm.h | 1 + mm/ksm.c | 11 +++++++++++ 2 files changed, 12 insertions(+)