From fc8352ee23579c2d3747bff8326959d6287993ba Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Sat, 28 Jul 2007 12:35:30 -0700 Subject: [PATCH] Simple Performance Counters: Reclaim instrumentation Add some performance counters that display the performance of memory reclaim (both direct and background) Signed-off-by: Christoph Lameter --- include/linux/perf.h | 4 ++++ kernel/perf.c | 6 +++++- mm/vmscan.c | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletions(-) diff --git a/include/linux/perf.h b/include/linux/perf.h index 3be5c4a..2cafdad 100644 --- a/include/linux/perf.h +++ b/include/linux/perf.h @@ -16,6 +16,10 @@ enum pc_item { PC_UPDATE_PROCESS_TIMES, PC_ALLOC_PAGES, + PC_DIRECT_RECLAIM_SCANNED, + PC_DIRECT_RECLAIM_RECLAIMED, + PC_RECLAIM_SCANNED, + PC_RECLAIM_RECLAIMED, NR_PC_ITEMS }; diff --git a/kernel/perf.c b/kernel/perf.c index dd4e850..ecb768b 100644 --- a/kernel/perf.c +++ b/kernel/perf.c @@ -22,7 +22,11 @@ static int unsynced_get_cycles = 1; const char *var_id[NR_PC_ITEMS] = { "update_process_times", - "__alloc_pages" + "__alloc_pages", + "direct_reclaim_scanned", + "direct_reclaim_reclaimed", + "reclaim_scanned", + "reclaim_reclaimed", }; struct perf_counter { diff --git a/mm/vmscan.c b/mm/vmscan.c index d419e10..2836317 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -1118,6 +1119,8 @@ static unsigned long shrink_zones(int priority, struct zone **zones, */ unsigned long try_to_free_pages(struct zone **zones, int order, gfp_t gfp_mask) { + INIT_PC(pc_scanned); + INIT_PC(pc_reclaimed); int priority; int ret = 0; unsigned long total_scanned = 0; @@ -1200,6 +1203,10 @@ out: zone->prev_priority = priority; } + pc_bytes(&pc_scanned, PAGE_SIZE * sc.nr_scanned, + PC_DIRECT_RECLAIM_SCANNED); + pc_bytes(&pc_reclaimed, PAGE_SIZE * nr_reclaimed, + PC_DIRECT_RECLAIM_RECLAIMED); return ret; } @@ -1226,6 +1233,8 @@ out: */ static unsigned long balance_pgdat(pg_data_t *pgdat, int order) { + INIT_PC(pc_reclaim_scanned); + INIT_PC(pc_reclaim_reclaimed); int all_zones_ok; int priority; int i; @@ -1376,6 +1385,10 @@ out: goto loop_again; } + pc_bytes(&pc_reclaim_scanned, total_scanned * PAGE_SIZE, + PC_RECLAIM_SCANNED); + pc_bytes(&pc_reclaim_reclaimed, nr_reclaimed * PAGE_SIZE, + PC_RECLAIM_RECLAIMED); return nr_reclaimed; } -- 1.5.2.4