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

Submitted by Andrey Ryabinin on March 6, 2019, 4:12 p.m.

Details

Message ID 20190306161226.10217-1-aryabinin@virtuozzo.com
State New
Series "mm/page_alloc: fix latency in tracepoint."
Headers show

Commit Message

Andrey Ryabinin March 6, 2019, 4:12 p.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 af1a8ffb106b..9ecda0f99463 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -213,7 +213,7 @@  TRACE_EVENT(mm_page_alloc,
 		__entry->migratetype	= migratetype;
 	),
 
-	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=%lld",
 		__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:
 	/*

Comments

Denis Lunev March 6, 2019, 4:28 p.m.
On 3/6/19 7:12 PM, Andrey Ryabinin wrote:
> 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(-)
>
> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> index af1a8ffb106b..9ecda0f99463 100644
> --- a/include/trace/events/kmem.h
> +++ b/include/trace/events/kmem.h
> @@ -213,7 +213,7 @@ TRACE_EVENT(mm_page_alloc,
>  		__entry->migratetype	= migratetype;
>  	),
>  
> -	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=%lld",
>  		__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:
>  	/*
no, llu!