[Devel] [PATCH RHEL7 COMMIT] mm/page_alloc: fix latency in tracepoint.

Konstantin Khorenko khorenko at virtuozzo.com
Thu Mar 7 18:59:23 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.5.1.vz7.84.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.5.1.vz7.84.5
------>
commit 7eff199a7a9e1c99ec183a2861ff3cc7ac2b1589
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Thu Mar 7 18:59:21 2019 +0300

    mm/page_alloc: fix latency in tracepoint.
    
    Since transition from jiffies to sched_clock(), mm_page_alloc
    garbadge since we substract from jiffies nanoseconds.
    Fix this.
    
    Fixes: e9e7602565ab ("mm/page_alloc: use sched_clock() instead of jiffies to
    measure latency")
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 include/trace/events/kmem.h |  2 +-
 mm/page_alloc.c             | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

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



More information about the Devel mailing list