[rh7,v2,2/2] mm/page_alloc: fix latency in tracepoint.

Submitted by Andrey Ryabinin on March 7, 2019, 10:36 a.m.

Details

Message ID 20190307103623.21271-2-aryabinin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrey Ryabinin March 7, 2019, 10:36 a.m.
Since transition from jiffies to sched_clock(), mm_page_alloc
garbadge since we substract from jiffies nanoseconds.
Fix this.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 include/trace/events/kmem.h |  2 +-
 mm/page_alloc.c             | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 74f69db5d2f7..7963e3f1c66f 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -214,7 +214,7 @@  TRACE_EVENT(mm_page_alloc,
 		__entry->time		= time;
 	),
 
-	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s lat=%d",
+	TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s lat=%llu",
 		__entry->page,
 		__entry->page ? page_to_pfn(__entry->page) : 0,
 		__entry->order,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 362c2a2235c1..134c93a1962b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3464,14 +3464,13 @@  void update_maxlat(struct kstat_lat_snap_struct *alloc_lat,
 }
 
 static void __alloc_collect_stats(gfp_t gfp_mask, unsigned int order,
-		struct page *page, u64 time)
+		struct page *page, u64 time, u64 current_clock)
 {
 #ifdef CONFIG_VE
 	unsigned long flags;
-	u64 current_clock, delta;
+	u64 delta;
 	int ind, cpu;
 
-	current_clock = sched_clock();
 	delta = current_clock - time;
 	if (!(gfp_mask & __GFP_WAIT)) {
 		if (in_task())
@@ -3547,7 +3546,7 @@  __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
 	int migratetype = allocflags_to_migratetype(gfp_mask);
 	unsigned int cpuset_mems_cookie;
 	int alloc_flags = ALLOC_WMARK_LOW|ALLOC_CPUSET|ALLOC_FAIR;
-	u64 start;
+	u64 start, current_clock;
 
 	gfp_mask &= gfp_allowed_mask;
 
@@ -3618,9 +3617,10 @@  __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
 				preferred_zone, migratetype);
 	}
 
-	__alloc_collect_stats(gfp_mask, order, page, start);
+	current_clock = sched_clock();
+	__alloc_collect_stats(gfp_mask, order, page, start, current_clock);
 	trace_mm_page_alloc(page, order, gfp_mask, migratetype,
-			jiffies_to_usecs(jiffies - start));
+			(current_clock - start));
 
 out:
 	/*