[PATCH v8 8/8] mm: add vmstat counters for tracking PCP drains

From: Gilad Ben-Yossef
Date: Sun Feb 05 2012 - 08:49:44 EST

This patch introduces two new vmstat counters for testing purposes:
pcp_global_drain that counts the number of times a per-cpu pages
global drain was requested and pcp_global_ipi_saved that counts
the number of times the number of CPUs with per-cpu pages in any
zone were less then 1/2 of the number of online CPUs.

The patch purpose is to show the usefulness of only sending an IPI
asking to drain per-cpu pages to CPUs that actually have them
instead of a blind global IPI. It is not inteded to be merged.

Signed-off-by: Gilad Ben-Yossef <gilad@xxxxxxxxxxxxx>
Acked-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
CC: Christoph Lameter <cl@xxxxxxxxx>
CC: Chris Metcalf <cmetcalf@xxxxxxxxxx>
CC: Frederic Weisbecker <fweisbec@xxxxxxxxx>
CC: linux-mm@xxxxxxxxx
CC: Pekka Enberg <penberg@xxxxxxxxxx>
CC: Matt Mackall <mpm@xxxxxxxxxxx>
CC: Sasha Levin <levinsasha928@xxxxxxxxx>
CC: Rik van Riel <riel@xxxxxxxxxx>
CC: Andi Kleen <andi@xxxxxxxxxxxxxx>
CC: Mel Gorman <mel@xxxxxxxxx>
CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
CC: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
CC: Avi Kivity <avi@xxxxxxxxxx>
CC: Michal Nazarewicz <mina86@xxxxxxxxxx>
CC: Kosaki Motohiro <kosaki.motohiro@xxxxxxxxx>
CC: Milton Miller <miltonm@xxxxxxx>
include/linux/vm_event_item.h | 1 +
mm/page_alloc.c | 5 +++++
mm/vmstat.c | 2 ++
3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index 03b90cd..3657f6f 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -58,6 +58,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3ff5aff..09d47eb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1201,6 +1201,11 @@ void drain_all_pages(void)
cpumask_clear_cpu(cpu, &cpus_with_pcps);
on_each_cpu_mask(&cpus_with_pcps, drain_local_pages, NULL, 1);
+ count_vm_event(PCP_GLOBAL_DRAIN);
+ if (cpumask_weight(&cpus_with_pcps) <
+ (cpumask_weight(cpu_online_mask) / 2))
+ count_vm_event(PCP_GLOBAL_IPI_SAVED);

diff --git a/mm/vmstat.c b/mm/vmstat.c
index f600557..3ee5f99 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -786,6 +786,8 @@ const char * const vmstat_text[] = {
+ "pcp_global_drain",
+ "pcp_global_ipi_saved"


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/