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

Submitted by Andrey Ryabinin on Dec. 17, 2018, 10:04 a.m.

Details

Message ID 20181217100410.23229-1-aryabinin@virtuozzo.com
State New
Series "mm/page_alloc: add latency to the page_alloc tracepoint"
Headers show

Commit Message

Andrey Ryabinin Dec. 17, 2018, 10:04 a.m.
Add 'lat' field to the mm_page_alloc tracepoint. It shows allocation
latency in microseconds (0.000001 second).

Signed-off-by: Andrey Ryabinin <aryabinin@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(-)

Patch hide | download patch | download mbox

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:
 	/*

Comments

Kirill Gorkunov Dec. 17, 2018, 10:13 a.m.
On Mon, Dec 17, 2018 at 01:04:10PM +0300, Andrey Ryabinin wrote:
> Add 'lat' field to the mm_page_alloc tracepoint. It shows allocation
> latency in microseconds (0.000001 second).
... 
>  
>  	TP_STRUCT__entry(
>  		__field(	struct page *,	page		)
>  		__field(	unsigned int,	order		)
>  		__field(	gfp_t,		gfp_flags	)
>  		__field(	int,		migratetype	)
> +		__field(	u64,		time		)
>  	),
...
> -	trace_mm_page_alloc(page, order, gfp_mask, migratetype);
> +	trace_mm_page_alloc(page, order, gfp_mask, migratetype,
> +			jiffies_to_usecs(jiffies - start));

jiffies_to_usecs provides u32 result, why do you need u64 here?