]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: reduce noise in show_mem for lowmem allocations
authorMichal Hocko <mhocko@suse.com>
Tue, 23 Aug 2022 09:22:30 +0000 (11:22 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Aug 2022 05:03:30 +0000 (22:03 -0700)
While discussing early DMA pool pre-allocation failure with Christoph [1]
I have realized that the allocation failure warning is rather noisy for
constrained allocations like GFP_DMA{32}.  Those zones are usually not
populated on all nodes very often as their memory ranges are constrained.

This is an attempt to reduce the ballast that doesn't provide any relevant
information for those allocation failures investigation.  Please note that
I have only compile tested it (in my default config setup) and I am
throwing it mostly to see what people think about it.

[1] http://lkml.kernel.org/r/20220817060647.1032426-1-hch@lst.de

Link: https://lkml.kernel.org/r/YwScVmVofIZkopkF@dhcp22.suse.cz
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/tty/sysrq.c
drivers/tty/vt/keyboard.c
include/linux/mm.h
init/initramfs.c
kernel/panic.c
lib/show_mem.c
mm/nommu.c
mm/oom_kill.c
mm/page_alloc.c

index d2b2720db6ca7bb2e04454ac453d5f6cd3df96f0..c6b2b42d2367f21d947eced371da095cb977ed20 100644 (file)
@@ -342,7 +342,7 @@ static const struct sysrq_key_op sysrq_ftrace_dump_op = {
 
 static void sysrq_handle_showmem(int key)
 {
-       show_mem(0, NULL);
+       show_mem(0, NULL, GFP_HIGHUSER_MOVABLE);
 }
 static const struct sysrq_key_op sysrq_showmem_op = {
        .handler        = sysrq_handle_showmem,
index be8313cdbac360ac3911b5d9c038dbfceebaaecb..9ceeea531cf6ead8ec3be0df21ebc1abdc49337d 100644 (file)
@@ -606,7 +606,7 @@ static void fn_scroll_back(struct vc_data *vc)
 
 static void fn_show_mem(struct vc_data *vc)
 {
-       show_mem(0, NULL);
+       show_mem(0, NULL, GFP_HIGHUSER_MOVABLE);
 }
 
 static void fn_show_state(struct vc_data *vc)
index 55cf92c0eb4f7ebf1c83d73ff697c27e50259f33..7b316c95cd70bffd5f8a62f966294405b3551ec1 100644 (file)
@@ -1842,7 +1842,7 @@ extern void pagefault_out_of_memory(void);
  */
 #define SHOW_MEM_FILTER_NODES          (0x0001u)       /* disallowed nodes */
 
-extern void show_free_areas(unsigned int flags, nodemask_t *nodemask);
+extern void show_free_areas(unsigned int flags, nodemask_t *nodemask, gfp_t gfp_mask);
 
 #ifdef CONFIG_MMU
 extern bool can_do_mlock(void);
@@ -2582,7 +2582,7 @@ extern void calculate_min_free_kbytes(void);
 extern int __meminit init_per_zone_wmark_min(void);
 extern void mem_init(void);
 extern void __init mmap_init(void);
-extern void show_mem(unsigned int flags, nodemask_t *nodemask);
+extern void show_mem(unsigned int flags, nodemask_t *nodemask, gfp_t gfp_mask);
 extern long si_mem_available(void);
 extern void si_meminfo(struct sysinfo * val);
 extern void si_meminfo_node(struct sysinfo *val, int nid);
index 18229cfe8906b7632d7f3f94574c870145f565a6..ec966cb78363e203db5e72c269e45808234bfcf3 100644 (file)
@@ -63,7 +63,7 @@ static void panic_show_mem(const char *fmt, ...)
 {
        va_list args;
 
-       show_mem(0, NULL);
+       show_mem(0, NULL, GFP_HIGHUSER_MOVABLE);
        va_start(args, fmt);
        panic(fmt, args);
        va_end(args);
index c6eb8f8db0c059a3b932d5f304aba39f2e260173..096a1c850277f1210a68ee483e95a49b02afae54 100644 (file)
@@ -187,7 +187,7 @@ static void panic_print_sys_info(bool console_flush)
                show_state();
 
        if (panic_print & PANIC_PRINT_MEM_INFO)
-               show_mem(0, NULL);
+               show_mem(0, NULL, GFP_HIGHUSER_MOVABLE);
 
        if (panic_print & PANIC_PRINT_TIMER_INFO)
                sysrq_timer_list_show();
index 1c26c14ffbb9bdfe8d442cb381e7c7d1fd242305..b97461a6c4bb999e0dd1f9f58d3633612848efb3 100644 (file)
@@ -8,13 +8,13 @@
 #include <linux/mm.h>
 #include <linux/cma.h>
 
-void show_mem(unsigned int filter, nodemask_t *nodemask)
+void show_mem(unsigned int filter, nodemask_t *nodemask, gfp_t gfp_mask)
 {
        pg_data_t *pgdat;
        unsigned long total = 0, reserved = 0, highmem = 0;
 
        printk("Mem-Info:\n");
-       show_free_areas(filter, nodemask);
+       show_free_areas(filter, nodemask, gfp_mask);
 
        for_each_online_pgdat(pgdat) {
                int zoneid;
index 214c70e1d05942e8a0a9a2e4ece7a6f5086f9c62..8d9c51b6ed8c89bf9392a8d772f2efd487067e71 100644 (file)
@@ -1030,7 +1030,7 @@ error_free:
 enomem:
        pr_err("Allocation of length %lu from process %d (%s) failed\n",
               len, current->pid, current->comm);
-       show_free_areas(0, NULL);
+       show_free_areas(0, NULL, GFP_KERNEL);
        return -ENOMEM;
 }
 
@@ -1259,13 +1259,13 @@ error_getting_vma:
        kmem_cache_free(vm_region_jar, region);
        pr_warn("Allocation of vma for %lu byte allocation from process %d failed\n",
                        len, current->pid);
-       show_free_areas(0, NULL);
+       show_free_areas(0, NULL, GFP_KERNEL);
        return -ENOMEM;
 
 error_getting_region:
        pr_warn("Allocation of vm region for %lu byte allocation from process %d failed\n",
                        len, current->pid);
-       show_free_areas(0, NULL);
+       show_free_areas(0, NULL, GFP_KERNEL);
        return -ENOMEM;
 
 error_maple_preallocate:
index 62975225db69fad4691fcc5a5d7e6385615d5a6b..3e83b6d81af4db71d293e0f31ef89cab7982cacd 100644 (file)
@@ -461,7 +461,7 @@ static void dump_header(struct oom_control *oc, struct task_struct *p)
        if (is_memcg_oom(oc))
                mem_cgroup_print_oom_meminfo(oc->memcg);
        else {
-               show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask);
+               show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask, oc->gfp_mask);
                if (should_dump_unreclaim_slab())
                        dump_unreclaimable_slab();
        }
index db434a855a40a4a8d53f79f8ed3d0d6bcf6af023..405da48c63d803235b7e972f0ba812d2a8adcdbc 100644 (file)
@@ -4329,7 +4329,7 @@ static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask)
        if (!in_task() || !(gfp_mask & __GFP_DIRECT_RECLAIM))
                filter &= ~SHOW_MEM_FILTER_NODES;
 
-       show_mem(filter, nodemask);
+       show_mem(filter, nodemask, gfp_mask);
 }
 
 void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
@@ -6049,6 +6049,15 @@ static void show_migration_types(unsigned char type)
        printk(KERN_CONT "(%s) ", tmp);
 }
 
+static bool node_has_managed_zones(pg_data_t *pgdat, int max_zone_idx)
+{
+       int zone_idx;
+       for (zone_idx = 0; zone_idx <= max_zone_idx; zone_idx++)
+               if (zone_managed_pages(pgdat->node_zones + zone_idx))
+                       return true;
+       return false;
+}
+
 /*
  * Show free area list (used inside shift_scroll-lock stuff)
  * We also calculate the percentage fragmentation. We do this by counting the
@@ -6058,14 +6067,17 @@ static void show_migration_types(unsigned char type)
  * SHOW_MEM_FILTER_NODES: suppress nodes that are not allowed by current's
  *   cpuset.
  */
-void show_free_areas(unsigned int filter, nodemask_t *nodemask)
+void show_free_areas(unsigned int filter, nodemask_t *nodemask, gfp_t gfp_mask)
 {
        unsigned long free_pcp = 0;
+       int max_zone_idx = gfp_zone(gfp_mask);
        int cpu, nid;
        struct zone *zone;
        pg_data_t *pgdat;
 
        for_each_populated_zone(zone) {
+               if (zone_idx(zone) > max_zone_idx)
+                       continue;
                if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
                        continue;
 
@@ -6103,6 +6115,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
        for_each_online_pgdat(pgdat) {
                if (show_mem_node_skip(filter, pgdat->node_id, nodemask))
                        continue;
+               if (!node_has_managed_zones(pgdat, max_zone_idx))
+                       continue;
 
                printk("Node %d"
                        " active_anon:%lukB"
@@ -6159,6 +6173,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
        for_each_populated_zone(zone) {
                int i;
 
+               if (zone_idx(zone) > max_zone_idx)
+                       continue;
                if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
                        continue;
 
@@ -6220,6 +6236,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
                unsigned long nr[MAX_ORDER], flags, total = 0;
                unsigned char types[MAX_ORDER];
 
+               if (zone_idx(zone) > max_zone_idx)
+                       continue;
                if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
                        continue;
                show_node(zone);