summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Abbott <lauraa@codeaurora.org>2014-09-24 15:53:57 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-22 11:03:28 -0700
commit1fe8bfe88af138b470e05d7f8b4b52ea3bfcf985 (patch)
treece4ff6426f601ee173f5150f051223a5f0630131
parentc5eff6c3212aed6715cd0a1ade55de5616fe43ac (diff)
ksm: Add showmem notifier
KSM is yet another framework which may obfuscate some memory problems. Use the showmem notifier to show how KSM is being used to give some insight into potential issues or non-issues. Change-Id: If82405dc33f212d085e6847f7c511fd4d0a32a10 Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
-rw-r--r--mm/ksm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/ksm.c b/mm/ksm.c
index 1ba25cfb94ab..4bf14d0e3a8a 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -37,6 +37,7 @@
#include <linux/freezer.h>
#include <linux/oom.h>
#include <linux/numa.h>
+#include <linux/show_mem_notifier.h>
#include <asm/tlbflush.h>
#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);
@@ -2415,6 +2430,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: