aboutsummaryrefslogtreecommitdiff
path: root/mm/showmem.c
blob: aa74c71faaad3e3c9d56c722cc8f093671656940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018, 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>

ATOMIC_NOTIFIER_HEAD(show_mem_notifier);

int show_mem_notifier_register(struct notifier_block *nb)
{
	return atomic_notifier_chain_register(&show_mem_notifier, nb);
}

int show_mem_notifier_unregister(struct notifier_block *nb)
{
	return  atomic_notifier_chain_unregister(&show_mem_notifier, nb);
}

void show_mem_call_notifiers(void)
{
	atomic_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);