lib, arch: add filter argument to show_mem and fix private implementations

Commit ddd588b5dd55 ("oom: suppress nodes that are not allowed from
meminfo on oom kill") moved lib/show_mem.o out of lib/lib.a, which
resulted in build warnings on all architectures that implement their own
versions of show_mem():

lib/lib.a(show_mem.o): In function `show_mem':
show_mem.c:(.text+0x1f4): multiple definition of `show_mem'
arch/sparc/mm/built-in.o:(.text+0xd70): first defined here

The fix is to remove __show_mem() and add its argument to show_mem() in
all implementations to prevent this breakage.

Architectures that implement their own show_mem() actually don't do
anything with the argument yet, but they could be made to filter nodes
that aren't allowed in the current context in the future just like the
generic implementation.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: James Bottomley <James.Bottomley@hansenpartnership.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by David Rientjes and committed by Linus Torvalds b2b755b5 e285c174

+15 -21
+1 -1
arch/arm/mm/init.c
··· 78 */ 79 struct meminfo meminfo; 80 81 - void show_mem(void) 82 { 83 int free = 0, total = 0, reserved = 0; 84 int shared = 0, cached = 0, slab = 0, i;
··· 78 */ 79 struct meminfo meminfo; 80 81 + void show_mem(unsigned int filter) 82 { 83 int free = 0, total = 0, reserved = 0; 84 int shared = 0, cached = 0, slab = 0, i;
+1 -1
arch/ia64/mm/contig.c
··· 36 * Shows a simple page count of reserved and used pages in the system. 37 * For discontig machines, it does this on a per-pgdat basis. 38 */ 39 - void show_mem(void) 40 { 41 int i, total_reserved = 0; 42 int total_shared = 0, total_cached = 0;
··· 36 * Shows a simple page count of reserved and used pages in the system. 37 * For discontig machines, it does this on a per-pgdat basis. 38 */ 39 + void show_mem(unsigned int filter) 40 { 41 int i, total_reserved = 0; 42 int total_shared = 0, total_cached = 0;
+1 -1
arch/ia64/mm/discontig.c
··· 614 * Shows a simple page count of reserved and used pages in the system. 615 * For discontig machines, it does this on a per-pgdat basis. 616 */ 617 - void show_mem(void) 618 { 619 int i, total_reserved = 0; 620 int total_shared = 0, total_cached = 0;
··· 614 * Shows a simple page count of reserved and used pages in the system. 615 * For discontig machines, it does this on a per-pgdat basis. 616 */ 617 + void show_mem(unsigned int filter) 618 { 619 int i, total_reserved = 0; 620 int total_shared = 0, total_cached = 0;
+1 -1
arch/parisc/mm/init.c
··· 544 unsigned long *empty_zero_page __read_mostly; 545 EXPORT_SYMBOL(empty_zero_page); 546 547 - void show_mem(void) 548 { 549 int i,free = 0,total = 0,reserved = 0; 550 int shared = 0, cached = 0;
··· 544 unsigned long *empty_zero_page __read_mostly; 545 EXPORT_SYMBOL(empty_zero_page); 546 547 + void show_mem(unsigned int filter) 548 { 549 int i,free = 0,total = 0,reserved = 0; 550 int shared = 0, cached = 0;
+1 -1
arch/powerpc/xmon/xmon.c
··· 821 memzcan(); 822 break; 823 case 'i': 824 - show_mem(); 825 break; 826 default: 827 termch = cmd;
··· 821 memzcan(); 822 break; 823 case 'i': 824 + show_mem(0); 825 break; 826 default: 827 termch = cmd;
+1 -1
arch/sparc/mm/init_32.c
··· 75 kmap_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE); 76 } 77 78 - void show_mem(void) 79 { 80 printk("Mem-info:\n"); 81 show_free_areas();
··· 75 kmap_prot = __pgprot(SRMMU_ET_PTE | SRMMU_PRIV | SRMMU_CACHE); 76 } 77 78 + void show_mem(unsigned int filter) 79 { 80 printk("Mem-info:\n"); 81 show_free_areas();
+1 -1
arch/tile/mm/pgtable.c
··· 41 * The normal show_free_areas() is too verbose on Tile, with dozens 42 * of processors and often four NUMA zones each with high and lowmem. 43 */ 44 - void show_mem(void) 45 { 46 struct zone *zone; 47
··· 41 * The normal show_free_areas() is too verbose on Tile, with dozens 42 * of processors and often four NUMA zones each with high and lowmem. 43 */ 44 + void show_mem(unsigned int filter) 45 { 46 struct zone *zone; 47
+1 -1
arch/unicore32/mm/init.c
··· 55 */ 56 struct meminfo meminfo; 57 58 - void show_mem(void) 59 { 60 int free = 0, total = 0, reserved = 0; 61 int shared = 0, cached = 0, slab = 0, i;
··· 55 */ 56 struct meminfo meminfo; 57 58 + void show_mem(unsigned int filter) 59 { 60 int free = 0, total = 0, reserved = 0; 61 int shared = 0, cached = 0, slab = 0, i;
+1 -1
drivers/tty/sysrq.c
··· 306 307 static void sysrq_handle_showmem(int key) 308 { 309 - show_mem(); 310 } 311 static struct sysrq_key_op sysrq_showmem_op = { 312 .handler = sysrq_handle_showmem,
··· 306 307 static void sysrq_handle_showmem(int key) 308 { 309 + show_mem(0); 310 } 311 static struct sysrq_key_op sysrq_showmem_op = { 312 .handler = sysrq_handle_showmem,
+1 -1
drivers/tty/vt/keyboard.c
··· 600 601 static void fn_show_mem(struct vc_data *vc) 602 { 603 - show_mem(); 604 } 605 606 static void fn_show_state(struct vc_data *vc)
··· 600 601 static void fn_show_mem(struct vc_data *vc) 602 { 603 + show_mem(0); 604 } 605 606 static void fn_show_state(struct vc_data *vc)
+2 -3
include/linux/mm.h
··· 861 #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) 862 863 /* 864 - * Flags passed to __show_mem() and __show_free_areas() to suppress output in 865 * various contexts. 866 */ 867 #define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */ ··· 1360 extern void calculate_zone_inactive_ratio(struct zone *zone); 1361 extern void mem_init(void); 1362 extern void __init mmap_init(void); 1363 - extern void show_mem(void); 1364 - extern void __show_mem(unsigned int flags); 1365 extern void si_meminfo(struct sysinfo * val); 1366 extern void si_meminfo_node(struct sysinfo *val, int nid); 1367 extern int after_bootmem;
··· 861 #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) 862 863 /* 864 + * Flags passed to show_mem() and __show_free_areas() to suppress output in 865 * various contexts. 866 */ 867 #define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */ ··· 1360 extern void calculate_zone_inactive_ratio(struct zone *zone); 1361 extern void mem_init(void); 1362 extern void __init mmap_init(void); 1363 + extern void show_mem(unsigned int flags); 1364 extern void si_meminfo(struct sysinfo * val); 1365 extern void si_meminfo_node(struct sysinfo *val, int nid); 1366 extern int after_bootmem;
+1 -6
lib/show_mem.c
··· 9 #include <linux/nmi.h> 10 #include <linux/quicklist.h> 11 12 - void __show_mem(unsigned int filter) 13 { 14 pg_data_t *pgdat; 15 unsigned long total = 0, reserved = 0, shared = 0, ··· 60 printk("%lu pages in pagetable cache\n", 61 quicklist_total_size()); 62 #endif 63 - } 64 - 65 - void show_mem(void) 66 - { 67 - __show_mem(0); 68 }
··· 9 #include <linux/nmi.h> 10 #include <linux/quicklist.h> 11 12 + void show_mem(unsigned int filter) 13 { 14 pg_data_t *pgdat; 15 unsigned long total = 0, reserved = 0, shared = 0, ··· 60 printk("%lu pages in pagetable cache\n", 61 quicklist_total_size()); 62 #endif 63 }
+1 -1
mm/oom_kill.c
··· 406 task_unlock(current); 407 dump_stack(); 408 mem_cgroup_print_oom_info(mem, p); 409 - __show_mem(SHOW_MEM_FILTER_NODES); 410 if (sysctl_oom_dump_tasks) 411 dump_tasks(mem, nodemask); 412 }
··· 406 task_unlock(current); 407 dump_stack(); 408 mem_cgroup_print_oom_info(mem, p); 409 + show_mem(SHOW_MEM_FILTER_NODES); 410 if (sysctl_oom_dump_tasks) 411 dump_tasks(mem, nodemask); 412 }
+1 -1
mm/page_alloc.c
··· 2195 current->comm, order, gfp_mask); 2196 dump_stack(); 2197 if (!should_suppress_show_mem()) 2198 - __show_mem(filter); 2199 } 2200 return page; 2201 got_pg:
··· 2195 current->comm, order, gfp_mask); 2196 dump_stack(); 2197 if (!should_suppress_show_mem()) 2198 + show_mem(filter); 2199 } 2200 return page; 2201 got_pg: