Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a24d231 authored by Laura Abbott's avatar Laura Abbott Committed by Isaac J. Manjarres
Browse files

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. Introduce 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: Ifb2946964bf5d072552dd56d8d6dfdd794af6d84
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
[swatsrid@codeaurora.org: Fix merge conflicts and errors]
Signed-off-by: default avatarSwathi Sridhar <swatsrid@codeaurora.org>
[isaacm@codeaurora.org: Fix merge conflicts/licensing/scope issues]
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent b53f720c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
/* 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);
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,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

mm/showmem.c

0 → 100644
+47 −0
Original line number Diff line number Diff line
// 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);