提交 b1f317c6 编写于 作者: M Ma Wupeng 提交者: Yang Yingliang

meminfo: Show reliable memory info

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S
CVE: NA

--------------------------------

Add ReliMemTotal & ReliMemUsed in /proc/meminfo to show memory info about
reliable memory.

- ReliableTotal: total reliable RAM

- ReliableUsed: thei used amount of reliable memory kernel
Signed-off-by: NMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 33d1f46a
...@@ -880,6 +880,8 @@ HardwareCorrupted: 0 kB ...@@ -880,6 +880,8 @@ HardwareCorrupted: 0 kB
AnonHugePages: 49152 kB AnonHugePages: 49152 kB
ShmemHugePages: 0 kB ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB ShmemPmdMapped: 0 kB
ReliableTotal: 7340032 kB
ReliableUsed: 418824 kB
MemTotal: Total usable ram (i.e. physical ram minus a few reserved MemTotal: Total usable ram (i.e. physical ram minus a few reserved
...@@ -970,6 +972,8 @@ VmallocTotal: total size of vmalloc memory area ...@@ -970,6 +972,8 @@ VmallocTotal: total size of vmalloc memory area
VmallocChunk: largest contiguous block of vmalloc area which is free VmallocChunk: largest contiguous block of vmalloc area which is free
Percpu: Memory allocated to the percpu allocator used to back percpu Percpu: Memory allocated to the percpu allocator used to back percpu
allocations. This stat excludes the cost of metadata. allocations. This stat excludes the cost of metadata.
ReliableTotal: Total reliable memory size
ReliableUsed: The used amount of reliable memory
.............................................................................. ..............................................................................
......
...@@ -148,6 +148,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v) ...@@ -148,6 +148,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
arch_report_meminfo(m); arch_report_meminfo(m);
reliable_report_meminfo(m);
return 0; return 0;
} }
......
...@@ -18,6 +18,7 @@ extern bool reliable_enabled; ...@@ -18,6 +18,7 @@ extern bool reliable_enabled;
extern void add_reliable_mem_size(long sz); extern void add_reliable_mem_size(long sz);
extern void mem_reliable_init(bool has_unmirrored_mem, extern void mem_reliable_init(bool has_unmirrored_mem,
unsigned long *zone_movable_pfn); unsigned long *zone_movable_pfn);
extern void reliable_report_meminfo(struct seq_file *m);
static inline bool mem_reliable_is_enabled(void) static inline bool mem_reliable_is_enabled(void)
{ {
...@@ -58,6 +59,7 @@ static inline bool skip_none_movable_zone(gfp_t gfp, struct zoneref *z) ...@@ -58,6 +59,7 @@ static inline bool skip_none_movable_zone(gfp_t gfp, struct zoneref *z)
{ {
return false; return false;
} }
static inline void reliable_report_meminfo(struct seq_file *m) {}
#endif #endif
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/memory.h> #include <linux/memory.h>
#include <linux/memory_hotplug.h> #include <linux/memory_hotplug.h>
#include <linux/seq_file.h>
#include <linux/mmzone.h>
DEFINE_STATIC_KEY_FALSE(mem_reliable); DEFINE_STATIC_KEY_FALSE(mem_reliable);
...@@ -76,3 +78,30 @@ void mem_reliable_init(bool has_unmirrored_mem, unsigned long *zone_movable_pfn) ...@@ -76,3 +78,30 @@ void mem_reliable_init(bool has_unmirrored_mem, unsigned long *zone_movable_pfn)
pr_info("init succeed, mirrored memory size(%lu)", pr_info("init succeed, mirrored memory size(%lu)",
atomic_long_read(&total_reliable_mem)); atomic_long_read(&total_reliable_mem));
} }
static unsigned long total_reliable_mem_sz(void)
{
return atomic_long_read(&total_reliable_mem);
}
static unsigned long used_reliable_mem_sz(void)
{
unsigned long nr_page = 0;
struct zone *z;
for_each_populated_zone(z)
if (zone_idx(z) < ZONE_MOVABLE)
nr_page += zone_page_state(z, NR_FREE_PAGES);
return total_reliable_mem_sz() - nr_page * PAGE_SIZE;
}
void reliable_report_meminfo(struct seq_file *m)
{
if (mem_reliable_is_enabled()) {
seq_printf(m, "ReliableTotal: %8lu kB\n",
total_reliable_mem_sz() >> 10);
seq_printf(m, "ReliableUsed: %8lu kB\n",
used_reliable_mem_sz() >> 10);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册