Skip to contentSkip to conversation

Simple Performance Counters: __alloc_pages instrumentation

PATCH In review Christoph Lameter 1 participant 1 message Jul 31, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/7 Simple Performance Counters: __alloc_pages instrumentation

Instrument __alloc_pages with a performance counter.

Allows the investigation of various allocation scenarios on page allocator performance.

---
 include/linux/perf.h |    1 +
 kernel/perf.c        |    1 +
 mm/page_alloc.c      |    3 +++
 3 files changed, 5 insertions(+), 0 deletions(-)
include/linux/perf.h +1 -0
index 2958c81..795b7ec 100644
@@ -15,6 +15,7 @@
 
 enum pc_item {
 	PC_UPDATE_PROCESS_TIMES,
+	PC_ALLOC_PAGES,
 	NR_PC_ITEMS
 };
 
kernel/perf.c +1 -0
index 14cba9c..dd4e850 100644
@@ -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 {
mm/page_alloc.c +3 -0
index 3da85b8..69d34b7 100644
@@ -41,6 +41,7 @@
 #include <linux/pfn.h>
 #include <linux/backing-dev.h>
 #include <linux/fault-inject.h>
+#include <linux/perf.h>
 
 #include <asm/tlbflush.h>
 #include <asm/div64.h>
@@ -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;
@@ -1387,6 +1389,7 @@ nopage:
 		show_mem();
 	}
 got_pg:
+	pc_bytes(&pc, PAGE_SIZE << order, PC_ALLOC_PAGES);
 	return page;
 }
 
Signature · 1 line
1.5.2.4