diff --git a/mm/ksm.c b/mm/ksm.c index 8713f1f31112..8f088c04ca78 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "internal.h" @@ -250,6 +251,20 @@ static DEFINE_SPINLOCK(ksm_mmlist_lock); sizeof(struct __struct), __alignof__(struct __struct),\ (__flags), NULL) +static int ksm_show_mem_notifier(struct notifier_block *nb, + unsigned long action, + void *data) +{ + pr_info("ksm_pages_sharing: %lu\n", ksm_pages_sharing); + pr_info("ksm_pages_shared: %lu\n", ksm_pages_shared); + + return 0; +} + +static struct notifier_block ksm_show_mem_notifier_block = { + .notifier_call = ksm_show_mem_notifier, +}; + static int __init ksm_slab_init(void) { rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0); @@ -2494,6 +2509,8 @@ static int __init ksm_init(void) /* There is no significance to this priority 100 */ hotplug_memory_notifier(ksm_memory_callback, 100); #endif + + show_mem_notifier_register(&ksm_show_mem_notifier_block); return 0; out_free: