blob: ddad34ebb5d96089afad76bb689dac553116e19e [file] [log] [blame]
Laura Abbott96805232014-09-22 13:26:28 -07001/*
2 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/kernel.h>
15#include <linux/notifier.h>
16#include <linux/debugfs.h>
17#include <linux/fs.h>
18#include <linux/init.h>
19
20BLOCKING_NOTIFIER_HEAD(show_mem_notifier);
21
22int show_mem_notifier_register(struct notifier_block *nb)
23{
24 return blocking_notifier_chain_register(&show_mem_notifier, nb);
25}
26
27int show_mem_notifier_unregister(struct notifier_block *nb)
28{
29 return blocking_notifier_chain_unregister(&show_mem_notifier, nb);
30}
31
32void show_mem_call_notifiers(void)
33{
34 blocking_notifier_call_chain(&show_mem_notifier, 0, NULL);
35}
36
37static int show_mem_notifier_get(void *dat, u64 *val)
38{
39 show_mem_call_notifiers();
40 *val = 0;
41 return 0;
42}
43
44DEFINE_SIMPLE_ATTRIBUTE(show_mem_notifier_debug_ops, show_mem_notifier_get,
45 NULL, "%llu\n");
46
47int show_mem_notifier_debugfs_register(void)
48{
49 debugfs_create_file("show_mem_notifier", 0664, NULL, NULL,
50 &show_mem_notifier_debug_ops);
51
52 return 0;
53}
54late_initcall(show_mem_notifier_debugfs_register);