Skip to content

Commit 7bf02ea

Browse files
rientjestorvalds
authored andcommitted
arch, mm: filter disallowed nodes from arch specific show_mem functions
Architectures that implement their own show_mem() function did not pass the filter argument to show_free_areas() to appropriately avoid emitting the state of nodes that are disallowed in the current context. This patch now passes the filter argument to show_free_areas() so those nodes are now avoided. This patch also removes the show_free_areas() wrapper around __show_free_areas() and converts existing callers to pass an empty filter. ia64 emits additional information for each node, so skip_free_areas_zone() must be made global to filter disallowed nodes and it is converted to use a nid argument rather than a zone for this use case. Signed-off-by: David Rientjes <[email protected]> Cc: Russell King <[email protected]> Cc: Tony Luck <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Kyle McMartin <[email protected]> Cc: Helge Deller <[email protected]> Cc: James Bottomley <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Guan Xuetao <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 851cc85 commit 7bf02ea

File tree

13 files changed

+34
-36
lines changed

13 files changed

+34
-36
lines changed

arch/arm/mm/init.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void show_mem(unsigned int filter)
8585
struct meminfo * mi = &meminfo;
8686

8787
printk("Mem-info:\n");
88-
show_free_areas();
88+
show_free_areas(filter);
8989

9090
for_each_bank (i, mi) {
9191
struct membank *bank = &mi->bank[i];

arch/ia64/mm/contig.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ void show_mem(unsigned int filter)
4444
pg_data_t *pgdat;
4545

4646
printk(KERN_INFO "Mem-info:\n");
47-
show_free_areas();
47+
show_free_areas(filter);
4848
printk(KERN_INFO "Node memory in pages:\n");
4949
for_each_online_pgdat(pgdat) {
5050
unsigned long present;
5151
unsigned long flags;
5252
int shared = 0, cached = 0, reserved = 0;
53+
int nid = pgdat->node_id;
5354

55+
if (skip_free_areas_node(filter, nid))
56+
continue;
5457
pgdat_resize_lock(pgdat, &flags);
5558
present = pgdat->node_present_pages;
5659
for(i = 0; i < pgdat->node_spanned_pages; i++) {
@@ -64,8 +67,7 @@ void show_mem(unsigned int filter)
6467
if (max_gap < LARGE_GAP)
6568
continue;
6669
#endif
67-
i = vmemmap_find_next_valid_pfn(pgdat->node_id,
68-
i) - 1;
70+
i = vmemmap_find_next_valid_pfn(nid, i) - 1;
6971
continue;
7072
}
7173
if (PageReserved(page))
@@ -81,7 +83,7 @@ void show_mem(unsigned int filter)
8183
total_cached += cached;
8284
total_shared += shared;
8385
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
84-
"shrd: %10d, swpd: %10d\n", pgdat->node_id,
86+
"shrd: %10d, swpd: %10d\n", nid,
8587
present, reserved, shared, cached);
8688
}
8789
printk(KERN_INFO "%ld pages of RAM\n", total_present);

arch/ia64/mm/discontig.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,16 @@ void show_mem(unsigned int filter)
622622
pg_data_t *pgdat;
623623

624624
printk(KERN_INFO "Mem-info:\n");
625-
show_free_areas();
625+
show_free_areas(filter);
626626
printk(KERN_INFO "Node memory in pages:\n");
627627
for_each_online_pgdat(pgdat) {
628628
unsigned long present;
629629
unsigned long flags;
630630
int shared = 0, cached = 0, reserved = 0;
631+
int nid = pgdat->node_id;
631632

633+
if (skip_free_areas_node(filter, nid))
634+
continue;
632635
pgdat_resize_lock(pgdat, &flags);
633636
present = pgdat->node_present_pages;
634637
for(i = 0; i < pgdat->node_spanned_pages; i++) {
@@ -638,8 +641,7 @@ void show_mem(unsigned int filter)
638641
if (pfn_valid(pgdat->node_start_pfn + i))
639642
page = pfn_to_page(pgdat->node_start_pfn + i);
640643
else {
641-
i = vmemmap_find_next_valid_pfn(pgdat->node_id,
642-
i) - 1;
644+
i = vmemmap_find_next_valid_pfn(nid, i) - 1;
643645
continue;
644646
}
645647
if (PageReserved(page))
@@ -655,7 +657,7 @@ void show_mem(unsigned int filter)
655657
total_cached += cached;
656658
total_shared += shared;
657659
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
658-
"shrd: %10d, swpd: %10d\n", pgdat->node_id,
660+
"shrd: %10d, swpd: %10d\n", nid,
659661
present, reserved, shared, cached);
660662
}
661663
printk(KERN_INFO "%ld pages of RAM\n", total_present);

arch/parisc/mm/init.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ void show_mem(unsigned int filter)
686686
int shared = 0, cached = 0;
687687

688688
printk(KERN_INFO "Mem-info:\n");
689-
show_free_areas();
689+
show_free_areas(filter);
690690
#ifndef CONFIG_DISCONTIGMEM
691691
i = max_mapnr;
692692
while (i-- > 0) {

arch/sparc/kernel/setup_32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static void prom_sync_me(void)
8282
"nop\n\t" : : "r" (&trapbase));
8383

8484
prom_printf("PROM SYNC COMMAND...\n");
85-
show_free_areas();
85+
show_free_areas(0);
8686
if(current->pid != 0) {
8787
local_irq_enable();
8888
sys_sync();

arch/sparc/mm/init_32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void __init kmap_init(void)
7878
void show_mem(unsigned int filter)
7979
{
8080
printk("Mem-info:\n");
81-
show_free_areas();
81+
show_free_areas(filter);
8282
printk("Free swap: %6ldkB\n",
8383
nr_swap_pages << (PAGE_SHIFT-10));
8484
printk("%ld pages of RAM\n", totalram_pages);

arch/unicore32/mm/init.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void show_mem(unsigned int filter)
6262
struct meminfo *mi = &meminfo;
6363

6464
printk(KERN_DEFAULT "Mem-info:\n");
65-
show_free_areas();
65+
show_free_areas(filter);
6666

6767
for_each_bank(i, mi) {
6868
struct membank *bank = &mi->bank[i];

drivers/net/ioc3-eth.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static void ioc3_alloc_rings(struct net_device *dev)
915915

916916
skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
917917
if (!skb) {
918-
show_free_areas();
918+
show_free_areas(0);
919919
continue;
920920
}
921921

drivers/tty/serial/68328serial.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
281281
#ifdef CONFIG_MAGIC_SYSRQ
282282
} else if (ch == 0x10) { /* ^P */
283283
show_state();
284-
show_free_areas();
284+
show_free_areas(0);
285285
show_buffers();
286286
/* show_net_buffers(); */
287287
return;

include/linux/mm.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,13 @@ extern void pagefault_out_of_memory(void);
862862
#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
863863

864864
/*
865-
* Flags passed to show_mem() and __show_free_areas() to suppress output in
865+
* Flags passed to show_mem() and show_free_areas() to suppress output in
866866
* various contexts.
867867
*/
868868
#define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */
869869

870-
extern void show_free_areas(void);
871-
extern void __show_free_areas(unsigned int flags);
870+
extern void show_free_areas(unsigned int flags);
871+
extern bool skip_free_areas_node(unsigned int flags, int nid);
872872

873873
int shmem_lock(struct file *file, int lock, struct user_struct *user);
874874
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);

lib/show_mem.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void show_mem(unsigned int filter)
1616
nonshared = 0, highmem = 0;
1717

1818
printk("Mem-Info:\n");
19-
__show_free_areas(filter);
19+
show_free_areas(filter);
2020

2121
for_each_online_pgdat(pgdat) {
2222
unsigned long i, flags;

mm/nommu.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
12351235
enomem:
12361236
printk("Allocation of length %lu from process %d (%s) failed\n",
12371237
len, current->pid, current->comm);
1238-
show_free_areas();
1238+
show_free_areas(0);
12391239
return -ENOMEM;
12401240
}
12411241

@@ -1468,14 +1468,14 @@ unsigned long do_mmap_pgoff(struct file *file,
14681468
printk(KERN_WARNING "Allocation of vma for %lu byte allocation"
14691469
" from process %d failed\n",
14701470
len, current->pid);
1471-
show_free_areas();
1471+
show_free_areas(0);
14721472
return -ENOMEM;
14731473

14741474
error_getting_region:
14751475
printk(KERN_WARNING "Allocation of vm region for %lu byte allocation"
14761476
" from process %d failed\n",
14771477
len, current->pid);
1478-
show_free_areas();
1478+
show_free_areas(0);
14791479
return -ENOMEM;
14801480
}
14811481
EXPORT_SYMBOL(do_mmap_pgoff);

mm/page_alloc.c

+8-14
Original file line numberDiff line numberDiff line change
@@ -2473,19 +2473,18 @@ void si_meminfo_node(struct sysinfo *val, int nid)
24732473
#endif
24742474

24752475
/*
2476-
* Determine whether the zone's node should be displayed or not, depending on
2477-
* whether SHOW_MEM_FILTER_NODES was passed to __show_free_areas().
2476+
* Determine whether the node should be displayed or not, depending on whether
2477+
* SHOW_MEM_FILTER_NODES was passed to show_free_areas().
24782478
*/
2479-
static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone)
2479+
bool skip_free_areas_node(unsigned int flags, int nid)
24802480
{
24812481
bool ret = false;
24822482

24832483
if (!(flags & SHOW_MEM_FILTER_NODES))
24842484
goto out;
24852485

24862486
get_mems_allowed();
2487-
ret = !node_isset(zone->zone_pgdat->node_id,
2488-
cpuset_current_mems_allowed);
2487+
ret = !node_isset(nid, cpuset_current_mems_allowed);
24892488
put_mems_allowed();
24902489
out:
24912490
return ret;
@@ -2500,13 +2499,13 @@ static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone)
25002499
* Suppresses nodes that are not allowed by current's cpuset if
25012500
* SHOW_MEM_FILTER_NODES is passed.
25022501
*/
2503-
void __show_free_areas(unsigned int filter)
2502+
void show_free_areas(unsigned int filter)
25042503
{
25052504
int cpu;
25062505
struct zone *zone;
25072506

25082507
for_each_populated_zone(zone) {
2509-
if (skip_free_areas_zone(filter, zone))
2508+
if (skip_free_areas_node(filter, zone_to_nid(zone)))
25102509
continue;
25112510
show_node(zone);
25122511
printk("%s per-cpu:\n", zone->name);
@@ -2549,7 +2548,7 @@ void __show_free_areas(unsigned int filter)
25492548
for_each_populated_zone(zone) {
25502549
int i;
25512550

2552-
if (skip_free_areas_zone(filter, zone))
2551+
if (skip_free_areas_node(filter, zone_to_nid(zone)))
25532552
continue;
25542553
show_node(zone);
25552554
printk("%s"
@@ -2618,7 +2617,7 @@ void __show_free_areas(unsigned int filter)
26182617
for_each_populated_zone(zone) {
26192618
unsigned long nr[MAX_ORDER], flags, order, total = 0;
26202619

2621-
if (skip_free_areas_zone(filter, zone))
2620+
if (skip_free_areas_node(filter, zone_to_nid(zone)))
26222621
continue;
26232622
show_node(zone);
26242623
printk("%s: ", zone->name);
@@ -2639,11 +2638,6 @@ void __show_free_areas(unsigned int filter)
26392638
show_swap_cache_info();
26402639
}
26412640

2642-
void show_free_areas(void)
2643-
{
2644-
__show_free_areas(0);
2645-
}
2646-
26472641
static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref)
26482642
{
26492643
zoneref->zone = zone;

0 commit comments

Comments
 (0)