Simple Performance Counters: __alloc_pages instrumentation Instrument __alloc_pages with a performance counter. Allows the investigation of various allocation scenarios on page allocator performance. Signed-off-by: Christoph Lameter --- include/linux/perf.h | 1 + kernel/perf.c | 1 + mm/page_alloc.c | 3 +++ 3 files changed, 5 insertions(+) Index: linux-2.6.23-rc1/mm/page_alloc.c =================================================================== --- linux-2.6.23-rc1.orig/mm/page_alloc.c 2007-07-27 21:47:50.000000000 -0700 +++ linux-2.6.23-rc1/mm/page_alloc.c 2007-07-27 21:51:37.000000000 -0700 @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -1223,6 +1224,7 @@ struct page * fastcall __alloc_pages(gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist) { + INIT_PC(pc); const gfp_t wait = gfp_mask & __GFP_WAIT; struct zone **z; struct page *page; @@ -1383,6 +1385,7 @@ nopage: show_mem(); } got_pg: + pc_bytes(&pc, PAGE_SIZE << order, PC_ALLOC_PAGES); return page; } Index: linux-2.6.23-rc1/include/linux/perf.h =================================================================== --- linux-2.6.23-rc1.orig/include/linux/perf.h 2007-07-27 21:50:11.000000000 -0700 +++ linux-2.6.23-rc1/include/linux/perf.h 2007-07-27 23:09:13.000000000 -0700 @@ -15,6 +15,7 @@ enum pc_item { PC_UPDATE_PROCESS_TIMES, + PC_ALLOC_PAGES, NR_PC_ITEMS }; Index: linux-2.6.23-rc1/kernel/perf.c =================================================================== --- linux-2.6.23-rc1.orig/kernel/perf.c 2007-07-27 21:48:35.000000000 -0700 +++ linux-2.6.23-rc1/kernel/perf.c 2007-07-27 23:09:13.000000000 -0700 @@ -22,6 +22,7 @@ static int unsynced_get_cycles = 1; const char *var_id[NR_PC_ITEMS] = { "update_process_times", + "__alloc_pages" }; struct perf_counter {