Skip to content

Commit aec6a88

Browse files
Mel Gormantorvalds
authored andcommitted
mm, show_mem: remove SHOW_MEM_FILTER_PAGE_COUNT
Commit 4b59e6c ("mm, show_mem: suppress page counts in non-blockable contexts") introduced SHOW_MEM_FILTER_PAGE_COUNT to suppress PFN walks on large memory machines. Commit c78e936 ("mm: do not walk all of system memory during show_mem") avoided a PFN walk in the generic show_mem helper which removes the requirement for SHOW_MEM_FILTER_PAGE_COUNT in that case. This patch removes PFN walkers from the arch-specific implementations that report on a per-node or per-zone granularity. ARM and unicore32 still do a PFN walk as they report memory usage on each bank which is a much finer granularity where the debugging information may still be of use. As the remaining arches doing PFN walks have relatively small amounts of memory, this patch simply removes SHOW_MEM_FILTER_PAGE_COUNT. [akpm@linux-foundation.org: fix parisc] Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: David Rientjes <rientjes@google.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: James Bottomley <jejb@parisc-linux.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ece86e2 commit aec6a88

9 files changed

Lines changed: 65 additions & 190 deletions

File tree

‎arch/arm/mm/init.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ void show_mem(unsigned int filter)
9292
printk("Mem-info:\n");
9393
show_free_areas(filter);
9494

95-
if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
96-
return;
97-
9895
for_each_bank (i, mi) {
9996
struct membank *bank = &mi->bank[i];
10097
unsigned int pfn1, pfn2;

‎arch/ia64/mm/contig.c‎

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -31,74 +31,6 @@
3131
static unsigned long max_gap;
3232
#endif
3333

34-
/**
35-
* show_mem - give short summary of memory stats
36-
*
37-
* Shows a simple page count of reserved and used pages in the system.
38-
* For discontig machines, it does this on a per-pgdat basis.
39-
*/
40-
void show_mem(unsigned int filter)
41-
{
42-
int i, total_reserved = 0;
43-
int total_shared = 0, total_cached = 0;
44-
unsigned long total_present = 0;
45-
pg_data_t *pgdat;
46-
47-
printk(KERN_INFO "Mem-info:\n");
48-
show_free_areas(filter);
49-
printk(KERN_INFO "Node memory in pages:\n");
50-
if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
51-
return;
52-
for_each_online_pgdat(pgdat) {
53-
unsigned long present;
54-
unsigned long flags;
55-
int shared = 0, cached = 0, reserved = 0;
56-
int nid = pgdat->node_id;
57-
58-
if (skip_free_areas_node(filter, nid))
59-
continue;
60-
pgdat_resize_lock(pgdat, &flags);
61-
present = pgdat->node_present_pages;
62-
for(i = 0; i < pgdat->node_spanned_pages; i++) {
63-
struct page *page;
64-
if (unlikely(i % MAX_ORDER_NR_PAGES == 0))
65-
touch_nmi_watchdog();
66-
if (pfn_valid(pgdat->node_start_pfn + i))
67-
page = pfn_to_page(pgdat->node_start_pfn + i);
68-
else {
69-
#ifdef CONFIG_VIRTUAL_MEM_MAP
70-
if (max_gap < LARGE_GAP)
71-
continue;
72-
#endif
73-
i = vmemmap_find_next_valid_pfn(nid, i) - 1;
74-
continue;
75-
}
76-
if (PageReserved(page))
77-
reserved++;
78-
else if (PageSwapCache(page))
79-
cached++;
80-
else if (page_count(page))
81-
shared += page_count(page)-1;
82-
}
83-
pgdat_resize_unlock(pgdat, &flags);
84-
total_present += present;
85-
total_reserved += reserved;
86-
total_cached += cached;
87-
total_shared += shared;
88-
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
89-
"shrd: %10d, swpd: %10d\n", nid,
90-
present, reserved, shared, cached);
91-
}
92-
printk(KERN_INFO "%ld pages of RAM\n", total_present);
93-
printk(KERN_INFO "%d reserved pages\n", total_reserved);
94-
printk(KERN_INFO "%d pages shared\n", total_shared);
95-
printk(KERN_INFO "%d pages swap cached\n", total_cached);
96-
printk(KERN_INFO "Total of %ld pages in page table cache\n",
97-
quicklist_total_size());
98-
printk(KERN_INFO "%ld free buffer pages\n", nr_free_buffer_pages());
99-
}
100-
101-
10234
/* physical address where the bootmem map is located */
10335
unsigned long bootmap_start;
10436

‎arch/ia64/mm/discontig.c‎

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -607,69 +607,6 @@ void *per_cpu_init(void)
607607
}
608608
#endif /* CONFIG_SMP */
609609

610-
/**
611-
* show_mem - give short summary of memory stats
612-
*
613-
* Shows a simple page count of reserved and used pages in the system.
614-
* For discontig machines, it does this on a per-pgdat basis.
615-
*/
616-
void show_mem(unsigned int filter)
617-
{
618-
int i, total_reserved = 0;
619-
int total_shared = 0, total_cached = 0;
620-
unsigned long total_present = 0;
621-
pg_data_t *pgdat;
622-
623-
printk(KERN_INFO "Mem-info:\n");
624-
show_free_areas(filter);
625-
if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
626-
return;
627-
printk(KERN_INFO "Node memory in pages:\n");
628-
for_each_online_pgdat(pgdat) {
629-
unsigned long present;
630-
unsigned long flags;
631-
int shared = 0, cached = 0, reserved = 0;
632-
int nid = pgdat->node_id;
633-
634-
if (skip_free_areas_node(filter, nid))
635-
continue;
636-
pgdat_resize_lock(pgdat, &flags);
637-
present = pgdat->node_present_pages;
638-
for(i = 0; i < pgdat->node_spanned_pages; i++) {
639-
struct page *page;
640-
if (unlikely(i % MAX_ORDER_NR_PAGES == 0))
641-
touch_nmi_watchdog();
642-
if (pfn_valid(pgdat->node_start_pfn + i))
643-
page = pfn_to_page(pgdat->node_start_pfn + i);
644-
else {
645-
i = vmemmap_find_next_valid_pfn(nid, i) - 1;
646-
continue;
647-
}
648-
if (PageReserved(page))
649-
reserved++;
650-
else if (PageSwapCache(page))
651-
cached++;
652-
else if (page_count(page))
653-
shared += page_count(page)-1;
654-
}
655-
pgdat_resize_unlock(pgdat, &flags);
656-
total_present += present;
657-
total_reserved += reserved;
658-
total_cached += cached;
659-
total_shared += shared;
660-
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
661-
"shrd: %10d, swpd: %10d\n", nid,
662-
present, reserved, shared, cached);
663-
}
664-
printk(KERN_INFO "%ld pages of RAM\n", total_present);
665-
printk(KERN_INFO "%d reserved pages\n", total_reserved);
666-
printk(KERN_INFO "%d pages shared\n", total_shared);
667-
printk(KERN_INFO "%d pages swap cached\n", total_cached);
668-
printk(KERN_INFO "Total of %ld pages in page table cache\n",
669-
quicklist_total_size());
670-
printk(KERN_INFO "%ld free buffer pages\n", nr_free_buffer_pages());
671-
}
672-
673610
/**
674611
* call_pernode_memory - use SRAT to call callback functions with node info
675612
* @start: physical start of range

‎arch/ia64/mm/init.c‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,51 @@ per_linux32_init(void)
684684
}
685685

686686
__initcall(per_linux32_init);
687+
688+
/**
689+
* show_mem - give short summary of memory stats
690+
*
691+
* Shows a simple page count of reserved and used pages in the system.
692+
* For discontig machines, it does this on a per-pgdat basis.
693+
*/
694+
void show_mem(unsigned int filter)
695+
{
696+
int total_reserved = 0;
697+
unsigned long total_present = 0;
698+
pg_data_t *pgdat;
699+
700+
printk(KERN_INFO "Mem-info:\n");
701+
show_free_areas(filter);
702+
printk(KERN_INFO "Node memory in pages:\n");
703+
for_each_online_pgdat(pgdat) {
704+
unsigned long present;
705+
unsigned long flags;
706+
int reserved = 0;
707+
int nid = pgdat->node_id;
708+
int zoneid;
709+
710+
if (skip_free_areas_node(filter, nid))
711+
continue;
712+
pgdat_resize_lock(pgdat, &flags);
713+
714+
for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
715+
struct zone *zone = &pgdat->node_zones[zoneid];
716+
if (!populated_zone(zone))
717+
continue;
718+
719+
reserved += zone->present_pages - zone->managed_pages;
720+
}
721+
present = pgdat->node_present_pages;
722+
723+
pgdat_resize_unlock(pgdat, &flags);
724+
total_present += present;
725+
total_reserved += reserved;
726+
printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, ",
727+
nid, present, reserved);
728+
}
729+
printk(KERN_INFO "%ld pages of RAM\n", total_present);
730+
printk(KERN_INFO "%d reserved pages\n", total_reserved);
731+
printk(KERN_INFO "Total of %ld pages in page table cache\n",
732+
quicklist_total_size());
733+
printk(KERN_INFO "%ld free buffer pages\n", nr_free_buffer_pages());
734+
}

‎arch/parisc/mm/init.c‎

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -645,55 +645,30 @@ EXPORT_SYMBOL(empty_zero_page);
645645

646646
void show_mem(unsigned int filter)
647647
{
648-
int i,free = 0,total = 0,reserved = 0;
649-
int shared = 0, cached = 0;
648+
int total = 0,reserved = 0;
649+
pg_data_t *pgdat;
650650

651651
printk(KERN_INFO "Mem-info:\n");
652652
show_free_areas(filter);
653-
if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
654-
return;
655-
#ifndef CONFIG_DISCONTIGMEM
656-
i = max_mapnr;
657-
while (i-- > 0) {
658-
total++;
659-
if (PageReserved(mem_map+i))
660-
reserved++;
661-
else if (PageSwapCache(mem_map+i))
662-
cached++;
663-
else if (!page_count(&mem_map[i]))
664-
free++;
665-
else
666-
shared += page_count(&mem_map[i]) - 1;
667-
}
668-
#else
669-
for (i = 0; i < npmem_ranges; i++) {
670-
int j;
671653

672-
for (j = node_start_pfn(i); j < node_end_pfn(i); j++) {
673-
struct page *p;
674-
unsigned long flags;
675-
676-
pgdat_resize_lock(NODE_DATA(i), &flags);
677-
p = nid_page_nr(i, j) - node_start_pfn(i);
678-
679-
total++;
680-
if (PageReserved(p))
681-
reserved++;
682-
else if (PageSwapCache(p))
683-
cached++;
684-
else if (!page_count(p))
685-
free++;
686-
else
687-
shared += page_count(p) - 1;
688-
pgdat_resize_unlock(NODE_DATA(i), &flags);
689-
}
654+
for_each_online_pgdat(pgdat) {
655+
unsigned long flags;
656+
int zoneid;
657+
658+
pgdat_resize_lock(pgdat, &flags);
659+
for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
660+
struct zone *zone = &pgdat->node_zones[zoneid];
661+
if (!populated_zone(zone))
662+
continue;
663+
664+
total += zone->present_pages;
665+
reserved = zone->present_pages - zone->managed_pages;
666+
}
667+
pgdat_resize_unlock(pgdat, &flags);
690668
}
691-
#endif
669+
692670
printk(KERN_INFO "%d pages of RAM\n", total);
693671
printk(KERN_INFO "%d reserved pages\n", reserved);
694-
printk(KERN_INFO "%d pages shared\n", shared);
695-
printk(KERN_INFO "%d pages swap cached\n", cached);
696-
697672

698673
#ifdef CONFIG_DISCONTIGMEM
699674
{

‎arch/unicore32/mm/init.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ void show_mem(unsigned int filter)
6666
printk(KERN_DEFAULT "Mem-info:\n");
6767
show_free_areas(filter);
6868

69-
if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
70-
return;
71-
7269
for_each_bank(i, mi) {
7370
struct membank *bank = &mi->bank[i];
7471
unsigned int pfn1, pfn2;

‎include/linux/mm.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,6 @@ extern void pagefault_out_of_memory(void);
10161016
* various contexts.
10171017
*/
10181018
#define SHOW_MEM_FILTER_NODES (0x0001u) /* disallowed nodes */
1019-
#define SHOW_MEM_FILTER_PAGE_COUNT (0x0002u) /* page type count */
10201019

10211020
extern void show_free_areas(unsigned int flags);
10221021
extern bool skip_free_areas_node(unsigned int flags, int nid);

‎lib/show_mem.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ void show_mem(unsigned int filter)
1717
printk("Mem-Info:\n");
1818
show_free_areas(filter);
1919

20-
if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
21-
return;
22-
2320
for_each_online_pgdat(pgdat) {
2421
unsigned long flags;
2522
int zoneid;

‎mm/page_alloc.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,13 +2071,6 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...)
20712071
debug_guardpage_minorder() > 0)
20722072
return;
20732073

2074-
/*
2075-
* Walking all memory to count page types is very expensive and should
2076-
* be inhibited in non-blockable contexts.
2077-
*/
2078-
if (!(gfp_mask & __GFP_WAIT))
2079-
filter |= SHOW_MEM_FILTER_PAGE_COUNT;
2080-
20812074
/*
20822075
* This documents exceptions given to allocations in certain
20832076
* contexts that are allowed to allocate outside current's set

0 commit comments

Comments
 (0)