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

Denis Lunev den at virtuozzo.com
Wed Mar 6 21:38:30 MSK 2019


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 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 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:
>  	/*
and this is 120% not enough!!

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index af1a8ffb106b..49153bbacb95 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -211,6 +211,7 @@ TRACE_EVENT(mm_page_alloc,
                __entry->order          = order;
                __entry->gfp_flags      = gfp_flags;
                __entry->migratetype    = migratetype;
+               __entry->time       = time;
        ),
 
        TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s
lat=%d",
iris ~/src/git/linux-vz7 $

This hunk __MUST__ be added to RK!

Den



More information about the Devel mailing list