-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe_show_mem.c
executable file
·89 lines (75 loc) · 2.52 KB
/
e_show_mem.c
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Copyright (C) 2015 Spreadtrum Communications Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/mm.h>
#include <linux/notifier.h>
#include <linux/swap.h>
#ifdef CONFIG_ION
#include <linux/ion.h>
#endif
static BLOCKING_NOTIFIER_HEAD(e_show_mem_notify_list);
int register_e_show_mem_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&e_show_mem_notify_list, nb);
}
EXPORT_SYMBOL_GPL(register_e_show_mem_notifier);
int unregister_e_show_mem_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&e_show_mem_notify_list, nb);
}
EXPORT_SYMBOL_GPL(unregister_e_show_mem_notifier);
void enhanced_show_mem(enum e_show_mem_type type)
{
/* Module used pages */
unsigned long used = 0;
struct sysinfo si;
pr_info("Enhanced Mem-Info:");
if (E_SHOW_MEM_BASIC == type)
pr_info("E_SHOW_MEM_BASIC\n");
else if (E_SHOW_MEM_CLASSIC == type)
pr_info("E_SHOW_MEM_CLASSIC\n");
else
pr_info("E_SHOW_MEM_ALL\n");
pr_info("Enhanced Mem-info :SHOW MEM\n");
show_mem(SHOW_MEM_FILTER_NODES, NULL);
si_meminfo(&si);
pr_info("MemTotal: %8lu kB\n"
"Buffers: %8lu kB\n"
"SwapCached: %8lu kB\n",
(si.totalram) << (PAGE_SHIFT - 10),
(si.bufferram) << (PAGE_SHIFT - 10),
total_swapcache_pages() << (PAGE_SHIFT - 10));
#ifdef CONFIG_ION
pr_info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
pr_info("Enhanced Mem-info :ION\n");
pr_info("Total allocated from Buddy: %8lu kB\n",
get_ion_heap_total_pages() << (PAGE_SHIFT - 10));
pr_info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
#endif
blocking_notifier_call_chain(&e_show_mem_notify_list,
(unsigned long)type, &used);
}
void enhanced_mem(enum e_show_mem_type type)
{
/* Module used pages */
unsigned long used = 0;
pr_info("Enhanced Mem-Info:");
if (E_SHOW_MEM_BASIC == type)
pr_info("E_SHOW_MEM_BASIC\n");
else if (E_SHOW_MEM_CLASSIC == type)
pr_info("E_SHOW_MEM_CLASSIC\n");
else
pr_info("E_SHOW_MEM_ALL\n");
blocking_notifier_call_chain(&e_show_mem_notify_list,
(unsigned long)type, &used);
}