Commit 7bf02ea2 authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds

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: default avatarDavid Rientjes <rientjes@google.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: James Bottomley <jejb@parisc-linux.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 851cc856
...@@ -85,7 +85,7 @@ void show_mem(unsigned int filter) ...@@ -85,7 +85,7 @@ void show_mem(unsigned int filter)
struct meminfo * mi = &meminfo; struct meminfo * mi = &meminfo;
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas(filter);
for_each_bank (i, mi) { for_each_bank (i, mi) {
struct membank *bank = &mi->bank[i]; struct membank *bank = &mi->bank[i];
......
...@@ -44,13 +44,16 @@ void show_mem(unsigned int filter) ...@@ -44,13 +44,16 @@ void show_mem(unsigned int filter)
pg_data_t *pgdat; pg_data_t *pgdat;
printk(KERN_INFO "Mem-info:\n"); printk(KERN_INFO "Mem-info:\n");
show_free_areas(); show_free_areas(filter);
printk(KERN_INFO "Node memory in pages:\n"); printk(KERN_INFO "Node memory in pages:\n");
for_each_online_pgdat(pgdat) { for_each_online_pgdat(pgdat) {
unsigned long present; unsigned long present;
unsigned long flags; unsigned long flags;
int shared = 0, cached = 0, reserved = 0; int shared = 0, cached = 0, reserved = 0;
int nid = pgdat->node_id;
if (skip_free_areas_node(filter, nid))
continue;
pgdat_resize_lock(pgdat, &flags); pgdat_resize_lock(pgdat, &flags);
present = pgdat->node_present_pages; present = pgdat->node_present_pages;
for(i = 0; i < pgdat->node_spanned_pages; i++) { for(i = 0; i < pgdat->node_spanned_pages; i++) {
...@@ -64,8 +67,7 @@ void show_mem(unsigned int filter) ...@@ -64,8 +67,7 @@ void show_mem(unsigned int filter)
if (max_gap < LARGE_GAP) if (max_gap < LARGE_GAP)
continue; continue;
#endif #endif
i = vmemmap_find_next_valid_pfn(pgdat->node_id, i = vmemmap_find_next_valid_pfn(nid, i) - 1;
i) - 1;
continue; continue;
} }
if (PageReserved(page)) if (PageReserved(page))
...@@ -81,7 +83,7 @@ void show_mem(unsigned int filter) ...@@ -81,7 +83,7 @@ void show_mem(unsigned int filter)
total_cached += cached; total_cached += cached;
total_shared += shared; total_shared += shared;
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, " printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
"shrd: %10d, swpd: %10d\n", pgdat->node_id, "shrd: %10d, swpd: %10d\n", nid,
present, reserved, shared, cached); present, reserved, shared, cached);
} }
printk(KERN_INFO "%ld pages of RAM\n", total_present); printk(KERN_INFO "%ld pages of RAM\n", total_present);
......
...@@ -622,13 +622,16 @@ void show_mem(unsigned int filter) ...@@ -622,13 +622,16 @@ void show_mem(unsigned int filter)
pg_data_t *pgdat; pg_data_t *pgdat;
printk(KERN_INFO "Mem-info:\n"); printk(KERN_INFO "Mem-info:\n");
show_free_areas(); show_free_areas(filter);
printk(KERN_INFO "Node memory in pages:\n"); printk(KERN_INFO "Node memory in pages:\n");
for_each_online_pgdat(pgdat) { for_each_online_pgdat(pgdat) {
unsigned long present; unsigned long present;
unsigned long flags; unsigned long flags;
int shared = 0, cached = 0, reserved = 0; int shared = 0, cached = 0, reserved = 0;
int nid = pgdat->node_id;
if (skip_free_areas_node(filter, nid))
continue;
pgdat_resize_lock(pgdat, &flags); pgdat_resize_lock(pgdat, &flags);
present = pgdat->node_present_pages; present = pgdat->node_present_pages;
for(i = 0; i < pgdat->node_spanned_pages; i++) { for(i = 0; i < pgdat->node_spanned_pages; i++) {
...@@ -638,8 +641,7 @@ void show_mem(unsigned int filter) ...@@ -638,8 +641,7 @@ void show_mem(unsigned int filter)
if (pfn_valid(pgdat->node_start_pfn + i)) if (pfn_valid(pgdat->node_start_pfn + i))
page = pfn_to_page(pgdat->node_start_pfn + i); page = pfn_to_page(pgdat->node_start_pfn + i);
else { else {
i = vmemmap_find_next_valid_pfn(pgdat->node_id, i = vmemmap_find_next_valid_pfn(nid, i) - 1;
i) - 1;
continue; continue;
} }
if (PageReserved(page)) if (PageReserved(page))
...@@ -655,7 +657,7 @@ void show_mem(unsigned int filter) ...@@ -655,7 +657,7 @@ void show_mem(unsigned int filter)
total_cached += cached; total_cached += cached;
total_shared += shared; total_shared += shared;
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, " printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
"shrd: %10d, swpd: %10d\n", pgdat->node_id, "shrd: %10d, swpd: %10d\n", nid,
present, reserved, shared, cached); present, reserved, shared, cached);
} }
printk(KERN_INFO "%ld pages of RAM\n", total_present); printk(KERN_INFO "%ld pages of RAM\n", total_present);
......
...@@ -686,7 +686,7 @@ void show_mem(unsigned int filter) ...@@ -686,7 +686,7 @@ void show_mem(unsigned int filter)
int shared = 0, cached = 0; int shared = 0, cached = 0;
printk(KERN_INFO "Mem-info:\n"); printk(KERN_INFO "Mem-info:\n");
show_free_areas(); show_free_areas(filter);
#ifndef CONFIG_DISCONTIGMEM #ifndef CONFIG_DISCONTIGMEM
i = max_mapnr; i = max_mapnr;
while (i-- > 0) { while (i-- > 0) {
......
...@@ -82,7 +82,7 @@ static void prom_sync_me(void) ...@@ -82,7 +82,7 @@ static void prom_sync_me(void)
"nop\n\t" : : "r" (&trapbase)); "nop\n\t" : : "r" (&trapbase));
prom_printf("PROM SYNC COMMAND...\n"); prom_printf("PROM SYNC COMMAND...\n");
show_free_areas(); show_free_areas(0);
if(current->pid != 0) { if(current->pid != 0) {
local_irq_enable(); local_irq_enable();
sys_sync(); sys_sync();
......
...@@ -78,7 +78,7 @@ void __init kmap_init(void) ...@@ -78,7 +78,7 @@ void __init kmap_init(void)
void show_mem(unsigned int filter) void show_mem(unsigned int filter)
{ {
printk("Mem-info:\n"); printk("Mem-info:\n");
show_free_areas(); show_free_areas(filter);
printk("Free swap: %6ldkB\n", printk("Free swap: %6ldkB\n",
nr_swap_pages << (PAGE_SHIFT-10)); nr_swap_pages << (PAGE_SHIFT-10));
printk("%ld pages of RAM\n", totalram_pages); printk("%ld pages of RAM\n", totalram_pages);
......
...@@ -62,7 +62,7 @@ void show_mem(unsigned int filter) ...@@ -62,7 +62,7 @@ void show_mem(unsigned int filter)
struct meminfo *mi = &meminfo; struct meminfo *mi = &meminfo;
printk(KERN_DEFAULT "Mem-info:\n"); printk(KERN_DEFAULT "Mem-info:\n");
show_free_areas(); show_free_areas(filter);
for_each_bank(i, mi) { for_each_bank(i, mi) {
struct membank *bank = &mi->bank[i]; struct membank *bank = &mi->bank[i];
......
...@@ -915,7 +915,7 @@ static void ioc3_alloc_rings(struct net_device *dev) ...@@ -915,7 +915,7 @@ static void ioc3_alloc_rings(struct net_device *dev)
skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC); skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
if (!skb) { if (!skb) {
show_free_areas(); show_free_areas(0);
continue; continue;
} }
......
...@@ -281,7 +281,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx) ...@@ -281,7 +281,7 @@ static void receive_chars(struct m68k_serial *info, unsigned short rx)
#ifdef CONFIG_MAGIC_SYSRQ #ifdef CONFIG_MAGIC_SYSRQ
} else if (ch == 0x10) { /* ^P */ } else if (ch == 0x10) { /* ^P */
show_state(); show_state();
show_free_areas(); show_free_areas(0);
show_buffers(); show_buffers();
/* show_net_buffers(); */ /* show_net_buffers(); */
return; return;
......
...@@ -862,13 +862,13 @@ extern void pagefault_out_of_memory(void); ...@@ -862,13 +862,13 @@ extern void pagefault_out_of_memory(void);
#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
/* /*
* Flags passed to show_mem() and __show_free_areas() to suppress output in * Flags passed to show_mem() and show_free_areas() to suppress output in
* various contexts. * various contexts.
*/ */
#define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */ #define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */
extern void show_free_areas(void); extern void show_free_areas(unsigned int flags);
extern void __show_free_areas(unsigned int flags); extern bool skip_free_areas_node(unsigned int flags, int nid);
int shmem_lock(struct file *file, int lock, struct user_struct *user); int shmem_lock(struct file *file, int lock, struct user_struct *user);
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags); struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
......
...@@ -16,7 +16,7 @@ void show_mem(unsigned int filter) ...@@ -16,7 +16,7 @@ void show_mem(unsigned int filter)
nonshared = 0, highmem = 0; nonshared = 0, highmem = 0;
printk("Mem-Info:\n"); printk("Mem-Info:\n");
__show_free_areas(filter); show_free_areas(filter);
for_each_online_pgdat(pgdat) { for_each_online_pgdat(pgdat) {
unsigned long i, flags; unsigned long i, flags;
......
...@@ -1235,7 +1235,7 @@ static int do_mmap_private(struct vm_area_struct *vma, ...@@ -1235,7 +1235,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
enomem: enomem:
printk("Allocation of length %lu from process %d (%s) failed\n", printk("Allocation of length %lu from process %d (%s) failed\n",
len, current->pid, current->comm); len, current->pid, current->comm);
show_free_areas(); show_free_areas(0);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1468,14 +1468,14 @@ unsigned long do_mmap_pgoff(struct file *file, ...@@ -1468,14 +1468,14 @@ unsigned long do_mmap_pgoff(struct file *file,
printk(KERN_WARNING "Allocation of vma for %lu byte allocation" printk(KERN_WARNING "Allocation of vma for %lu byte allocation"
" from process %d failed\n", " from process %d failed\n",
len, current->pid); len, current->pid);
show_free_areas(); show_free_areas(0);
return -ENOMEM; return -ENOMEM;
error_getting_region: error_getting_region:
printk(KERN_WARNING "Allocation of vm region for %lu byte allocation" printk(KERN_WARNING "Allocation of vm region for %lu byte allocation"
" from process %d failed\n", " from process %d failed\n",
len, current->pid); len, current->pid);
show_free_areas(); show_free_areas(0);
return -ENOMEM; return -ENOMEM;
} }
EXPORT_SYMBOL(do_mmap_pgoff); EXPORT_SYMBOL(do_mmap_pgoff);
......
...@@ -2473,10 +2473,10 @@ void si_meminfo_node(struct sysinfo *val, int nid) ...@@ -2473,10 +2473,10 @@ void si_meminfo_node(struct sysinfo *val, int nid)
#endif #endif
/* /*
* Determine whether the zone's node should be displayed or not, depending on * Determine whether the node should be displayed or not, depending on whether
* whether SHOW_MEM_FILTER_NODES was passed to __show_free_areas(). * SHOW_MEM_FILTER_NODES was passed to show_free_areas().
*/ */
static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone) bool skip_free_areas_node(unsigned int flags, int nid)
{ {
bool ret = false; bool ret = false;
...@@ -2484,8 +2484,7 @@ static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone) ...@@ -2484,8 +2484,7 @@ static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone)
goto out; goto out;
get_mems_allowed(); get_mems_allowed();
ret = !node_isset(zone->zone_pgdat->node_id, ret = !node_isset(nid, cpuset_current_mems_allowed);
cpuset_current_mems_allowed);
put_mems_allowed(); put_mems_allowed();
out: out:
return ret; return ret;
...@@ -2500,13 +2499,13 @@ static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone) ...@@ -2500,13 +2499,13 @@ static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone)
* Suppresses nodes that are not allowed by current's cpuset if * Suppresses nodes that are not allowed by current's cpuset if
* SHOW_MEM_FILTER_NODES is passed. * SHOW_MEM_FILTER_NODES is passed.
*/ */
void __show_free_areas(unsigned int filter) void show_free_areas(unsigned int filter)
{ {
int cpu; int cpu;
struct zone *zone; struct zone *zone;
for_each_populated_zone(zone) { for_each_populated_zone(zone) {
if (skip_free_areas_zone(filter, zone)) if (skip_free_areas_node(filter, zone_to_nid(zone)))
continue; continue;
show_node(zone); show_node(zone);
printk("%s per-cpu:\n", zone->name); printk("%s per-cpu:\n", zone->name);
...@@ -2549,7 +2548,7 @@ void __show_free_areas(unsigned int filter) ...@@ -2549,7 +2548,7 @@ void __show_free_areas(unsigned int filter)
for_each_populated_zone(zone) { for_each_populated_zone(zone) {
int i; int i;
if (skip_free_areas_zone(filter, zone)) if (skip_free_areas_node(filter, zone_to_nid(zone)))
continue; continue;
show_node(zone); show_node(zone);
printk("%s" printk("%s"
...@@ -2618,7 +2617,7 @@ void __show_free_areas(unsigned int filter) ...@@ -2618,7 +2617,7 @@ void __show_free_areas(unsigned int filter)
for_each_populated_zone(zone) { for_each_populated_zone(zone) {
unsigned long nr[MAX_ORDER], flags, order, total = 0; unsigned long nr[MAX_ORDER], flags, order, total = 0;
if (skip_free_areas_zone(filter, zone)) if (skip_free_areas_node(filter, zone_to_nid(zone)))
continue; continue;
show_node(zone); show_node(zone);
printk("%s: ", zone->name); printk("%s: ", zone->name);
...@@ -2639,11 +2638,6 @@ void __show_free_areas(unsigned int filter) ...@@ -2639,11 +2638,6 @@ void __show_free_areas(unsigned int filter)
show_swap_cache_info(); show_swap_cache_info();
} }
void show_free_areas(void)
{
__show_free_areas(0);
}
static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref) static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref)
{ {
zoneref->zone = zone; zoneref->zone = zone;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment