blob: a7e3caffa59333db5da193c461d9718490f9c0b9 [file] [log] [blame]
Laura Abbott35cded22014-09-22 13:26:28 -07001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
4 */
5
6#include <linux/kernel.h>
7#include <linux/notifier.h>
8#include <linux/debugfs.h>
9#include <linux/fs.h>
10#include <linux/init.h>
11
12BLOCKING_NOTIFIER_HEAD(show_mem_notifier);
13
14int show_mem_notifier_register(struct notifier_block *nb)
15{
16 return blocking_notifier_chain_register(&show_mem_notifier, nb);
17}
18
19int show_mem_notifier_unregister(struct notifier_block *nb)
20{
21 return blocking_notifier_chain_unregister(&show_mem_notifier, nb);
22}
23
24void show_mem_call_notifiers(void)
25{
26 blocking_notifier_call_chain(&show_mem_notifier, 0, NULL);
27}
28
29static int show_mem_notifier_get(void *dat, u64 *val)
30{
31 show_mem_call_notifiers();
32 *val = 0;
33 return 0;
34}
35
36DEFINE_SIMPLE_ATTRIBUTE(show_mem_notifier_debug_ops, show_mem_notifier_get,
37 NULL, "%llu\n");
38
39int show_mem_notifier_debugfs_register(void)
40{
41 debugfs_create_file("show_mem_notifier", 0664, NULL, NULL,
42 &show_mem_notifier_debug_ops);
43
44 return 0;
45}
46late_initcall(show_mem_notifier_debugfs_register);