lib/show_mem.c: drop pgdat_resize_lock in show_mem()
authorWei Yang <richard.weiyang@gmail.com>
Fri, 28 Dec 2018 08:37:16 +0000 (00:37 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Dec 2018 20:11:49 +0000 (12:11 -0800)
Function show_mem() is used to print system memory status when user
requires or fail to allocate memory.  Generally, this is a best effort
information so any races with memory hotplug (or very theoretically an
early initialization) should be tolerable and the worst that could happen
is to print an imprecise node state.

Drop the resize lock because this is the only place which might hold the
lock from the interrupt context and so all other callers might use a
simple spinlock.  Even though this doesn't solve any real issue it makes
the code easier to follow and tiny more effective.

Link: http://lkml.kernel.org/r/20181129235532.9328-1-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/show_mem.c

index eefe67d50e84a05036ff72c889993de5df3bae1f..6a042f53e7bbc6c84a7ccb61bbc4c85a7032e558 100644 (file)
@@ -18,10 +18,8 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
        show_free_areas(filter, nodemask);
 
        for_each_online_pgdat(pgdat) {
-               unsigned long flags;
                int zoneid;
 
-               pgdat_resize_lock(pgdat, &flags);
                for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
                        struct zone *zone = &pgdat->node_zones[zoneid];
                        if (!populated_zone(zone))
@@ -33,7 +31,6 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
                        if (is_highmem_idx(zoneid))
                                highmem += zone->present_pages;
                }
-               pgdat_resize_unlock(pgdat, &flags);
        }
 
        printk("%lu pages RAM\n", total);