Skip to content

Commit 93b3a67

Browse files
Michal Hockotorvalds
authored andcommitted
mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo
pagetypeinfo_showfree_print is called by zone->lock held in irq mode. This is not really nice because it blocks both any interrupts on that cpu and the page allocator. On large machines this might even trigger the hard lockup detector. Considering the pagetypeinfo is a debugging tool we do not really need exact numbers here. The primary reason to look at the outuput is to see how pageblocks are spread among different migratetypes and low number of pages is much more interesting therefore putting a bound on the number of pages on the free_list sounds like a reasonable tradeoff. The new output will simply tell [...] Node 6, zone Normal, type Movable >100000 >100000 >100000 >100000 41019 31560 23996 10054 3229 983 648 instead of Node 6, zone Normal, type Movable 399568 294127 221558 102119 41019 31560 23996 10054 3229 983 648 The limit has been chosen arbitrary and it is a subject of a future change should there be a need for that. While we are at it, also drop the zone lock after each free_list iteration which will help with the IRQ and page allocator responsiveness even further as the IRQ lock held time is always bound to those 100k pages. [[email protected]: tweak comment text, per David Hildenbrand] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Michal Hocko <[email protected]> Suggested-by: Andrew Morton <[email protected]> Reviewed-by: Waiman Long <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Rafael Aquini <[email protected]> Acked-by: David Rientjes <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Jann Horn <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Song Liu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent abaed01 commit 93b3a67

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

mm/vmstat.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,12 +1383,29 @@ static void pagetypeinfo_showfree_print(struct seq_file *m,
13831383
unsigned long freecount = 0;
13841384
struct free_area *area;
13851385
struct list_head *curr;
1386+
bool overflow = false;
13861387

13871388
area = &(zone->free_area[order]);
13881389

1389-
list_for_each(curr, &area->free_list[mtype])
1390-
freecount++;
1391-
seq_printf(m, "%6lu ", freecount);
1390+
list_for_each(curr, &area->free_list[mtype]) {
1391+
/*
1392+
* Cap the free_list iteration because it might
1393+
* be really large and we are under a spinlock
1394+
* so a long time spent here could trigger a
1395+
* hard lockup detector. Anyway this is a
1396+
* debugging tool so knowing there is a handful
1397+
* of pages of this order should be more than
1398+
* sufficient.
1399+
*/
1400+
if (++freecount >= 100000) {
1401+
overflow = true;
1402+
break;
1403+
}
1404+
}
1405+
seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount);
1406+
spin_unlock_irq(&zone->lock);
1407+
cond_resched();
1408+
spin_lock_irq(&zone->lock);
13921409
}
13931410
seq_putc(m, '\n');
13941411
}

0 commit comments

Comments
 (0)