mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
Merge "mm: Add notifier framework for showing memory"
This commit is contained in:
commit
84dad359b7
3 changed files with 60 additions and 1 deletions
12
include/linux/show_mem_notifier.h
Normal file
12
include/linux/show_mem_notifier.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#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);
|
||||
|
|
@ -42,7 +42,7 @@ obj-y := filemap.o mempool.o oom_kill.o fadvise.o \
|
|||
mm_init.o mmu_context.o percpu.o slab_common.o \
|
||||
compaction.o vmacache.o \
|
||||
interval_tree.o list_lru.o workingset.o \
|
||||
debug.o gup.o $(mmu-y)
|
||||
debug.o gup.o $(mmu-y) showmem.o
|
||||
|
||||
# Give 'page_alloc' its own module-parameter namespace
|
||||
page-alloc-y := page_alloc.o
|
||||
|
|
|
|||
47
mm/showmem.c
Normal file
47
mm/showmem.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/show_mem_notifier.h>
|
||||
|
||||
static 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_DEBUGFS_ATTRIBUTE(show_mem_notifier_debug_ops, show_mem_notifier_get,
|
||||
NULL, "%llu\n");
|
||||
|
||||
static 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 a new issue