mm: Add notifier framework for showing memory
There are many drivers in the kernel which can hold on to lots of memory. It can be useful to dump out all those drivers at key points in the kernel. Introduct a notifier framework for dumping this information. When the notifiers are called, drivers can dump out the state of any memory they may be using. Change-Id: I514ef1d01510a50970a661c8e9bedc8b78683eab Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
parent
620fcfe32e
commit
92fea070f4
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/notifier.h>
|
||||
|
||||
int show_mem_notifier_register(struct notifier_block *nb);
|
||||
|
||||
int show_mem_notifier_unregister(struct notifier_block *nb);
|
||||
|
||||
void show_mem_call_notifiers(void);
|
|
@ -14,8 +14,7 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
|
|||
prio_tree.o util.o mmzone.o vmstat.o backing-dev.o \
|
||||
page_isolation.o mm_init.o mmu_context.o percpu.o \
|
||||
compaction.o $(mmu-y) \
|
||||
vmpressure.o
|
||||
|
||||
vmpressure.o showmem.o
|
||||
obj-y += init-mm.o
|
||||
|
||||
ifdef CONFIG_NO_BOOTMEM
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
BLOCKING_NOTIFIER_HEAD(show_mem_notifier);
|
||||
|
||||
int show_mem_notifier_register(struct notifier_block *nb)
|
||||
{
|
||||
return blocking_notifier_chain_register(&show_mem_notifier, nb);
|
||||
}
|
||||
|
||||
int show_mem_notifier_unregister(struct notifier_block *nb)
|
||||
{
|
||||
return blocking_notifier_chain_unregister(&show_mem_notifier, nb);
|
||||
}
|
||||
|
||||
void show_mem_call_notifiers(void)
|
||||
{
|
||||
blocking_notifier_call_chain(&show_mem_notifier, 0, NULL);
|
||||
}
|
||||
|
||||
static int show_mem_notifier_get(void *dat, u64 *val)
|
||||
{
|
||||
show_mem_call_notifiers();
|
||||
*val = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SIMPLE_ATTRIBUTE(show_mem_notifier_debug_ops, show_mem_notifier_get,
|
||||
NULL, "%llu\n");
|
||||
|
||||
int show_mem_notifier_debugfs_register(void)
|
||||
{
|
||||
debugfs_create_file("show_mem_notifier", 0664, NULL, NULL,
|
||||
&show_mem_notifier_debug_ops);
|
||||
|
||||
return 0;
|
||||
}
|
||||
late_initcall(show_mem_notifier_debugfs_register);
|
Loading…
Reference in New Issue