From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4SK3S CVE: NA
--------------------------------
Show debug info about memory reliable if oom occurs.
Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- mm/mem_reliable.c | 41 ++++++++++++++++++++++++++++++++++------- mm/show_mem.c | 1 + 2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/mm/mem_reliable.c b/mm/mem_reliable.c index c20a8e72b3e2..c28b4ebe71c9 100644 --- a/mm/mem_reliable.c +++ b/mm/mem_reliable.c @@ -346,26 +346,49 @@ static void mem_reliable_feature_disable(int idx) pr_info("%s is disabled\n", str); }
+#define TO_KB(bytes) ((bytes) >> 10) #define PAGES_TO_KB(n_pages) ((n_pages) << (PAGE_SHIFT - 10))
+#define SEQ_printf(m, x...) \ +do { \ + if (m) \ + seq_printf(m, x); \ + else \ + pr_info(x); \ +} while (0) + +static void reliable_show_limits(void) +{ + SEQ_printf(NULL, "ReliableTaskLimit: %lu kB\n", + TO_KB(task_reliable_limit)); + + if (shmem_reliable_is_enabled()) + SEQ_printf(NULL, "ReliableShmemLimit: %lu kB\n", + TO_KB(shmem_reliable_limit)); + + if (filemap_reliable_is_enabled()) + SEQ_printf(NULL, "ReliableFileCacheLimit: %lu kB\n", + TO_KB(pagecache_reliable_limit)); +} + void reliable_report_meminfo(struct seq_file *m) { if (!mem_reliable_is_enabled()) return;
- seq_printf(m, "ReliableTotal: %8lu kB\n", + SEQ_printf(m, "ReliableTotal: %8lu kB\n", PAGES_TO_KB(total_reliable_pages())); - seq_printf(m, "ReliableUsed: %8lu kB\n", + SEQ_printf(m, "ReliableUsed: %8lu kB\n", PAGES_TO_KB(used_reliable_pages())); - seq_printf(m, "ReliableTaskUsed: %8lu kB\n", + SEQ_printf(m, "ReliableTaskUsed: %8lu kB\n", PAGES_TO_KB(task_reliable_used_pages())); - seq_printf(m, "ReliableBuddyMem: %8lu kB\n", + SEQ_printf(m, "ReliableBuddyMem: %8lu kB\n", PAGES_TO_KB(free_reliable_pages()));
if (shmem_reliable_is_enabled()) { unsigned long shmem_pages = (unsigned long)percpu_counter_sum( &shmem_reliable_pages); - seq_printf(m, "ReliableShmem: %8lu kB\n", + SEQ_printf(m, "ReliableShmem: %8lu kB\n", PAGES_TO_KB(shmem_pages)); }
@@ -375,13 +398,17 @@ void reliable_report_meminfo(struct seq_file *m)
num += global_node_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); num += global_node_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); - seq_printf(m, "FileCache: %8lu kB\n", PAGES_TO_KB(num)); + SEQ_printf(m, "FileCache: %8lu kB\n", PAGES_TO_KB(num));
nr_reliable_pages = percpu_counter_sum_positive(&pagecache_reliable_pages); - seq_printf(m, "ReliableFileCache: %8lu kB\n", + SEQ_printf(m, "ReliableFileCache: %8lu kB\n", PAGES_TO_KB(nr_reliable_pages)); } + + /* show limit info during oom */ + if (!m) + reliable_show_limits(); }
void mem_reliable_out_of_memory(gfp_t gfp, unsigned int order, diff --git a/mm/show_mem.c b/mm/show_mem.c index 4b888b18bdde..5604925fb0b4 100644 --- a/mm/show_mem.c +++ b/mm/show_mem.c @@ -426,4 +426,5 @@ void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx) #ifdef CONFIG_MEMORY_FAILURE printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages)); #endif + reliable_report_meminfo(NULL); }