[Devel] [PATCH rh7 v2] mm/page_alloc: add latency to the page_alloc tracepoint

Andrey Ryabinin aryabinin at virtuozzo.com
Mon Dec 17 13:04:10 MSK 2018


Add 'lat' field to the mm_page_alloc tracepoint. It shows allocation
latency in microseconds (0.000001 second).

Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---

Changes since v1:
 - s/%ld/%lld

 include/trace/events/kmem.h | 10 ++++++----
 mm/page_alloc.c             |  3 ++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 6bc943ecb841..a9e293fe0c8c 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -194,15 +194,16 @@ TRACE_EVENT(mm_page_free_batched,
 TRACE_EVENT(mm_page_alloc,
 
 	TP_PROTO(struct page *page, unsigned int order,
-			gfp_t gfp_flags, int migratetype),
+			gfp_t gfp_flags, int migratetype, u64 time),
 
-	TP_ARGS(page, order, gfp_flags, migratetype),
+	TP_ARGS(page, order, gfp_flags, migratetype, time),
 
 	TP_STRUCT__entry(
 		__field(	struct page *,	page		)
 		__field(	unsigned int,	order		)
 		__field(	gfp_t,		gfp_flags	)
 		__field(	int,		migratetype	)
+		__field(	u64,		time		)
 	),
 
 	TP_fast_assign(
@@ -212,12 +213,13 @@ TRACE_EVENT(mm_page_alloc,
 		__entry->migratetype	= migratetype;
 	),
 
-	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
+	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s lat=%lld",
 		__entry->page,
 		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
 		__entry->migratetype,
-		show_gfp_flags(__entry->gfp_flags))
+		show_gfp_flags(__entry->gfp_flags),
+		__entry->time)
 );
 
 DECLARE_EVENT_CLASS(mm_page,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 47889c7b6ac4..63d723bff3a9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3616,7 +3616,8 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
 	}
 
 	__alloc_collect_stats(gfp_mask, order, page, start);
-	trace_mm_page_alloc(page, order, gfp_mask, migratetype);
+	trace_mm_page_alloc(page, order, gfp_mask, migratetype,
+			jiffies_to_usecs(jiffies - start));
 
 out:
 	/*
-- 
2.19.2



More information about the Devel mailing list