linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Janani Ravichandran <janani.rvchndrn@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	riel@surriel.com, akpm@linux-foundation.org, hannes@compxchg.org,
	vdavydov@virtuozzo.com, mhocko@suse.com, vbabka@suse.cz,
	mgorman@techsingularity.net, kirill.shutemov@linux.intel.com,
	bywxiaobai@163.com
Subject: Re: [PATCH 1/2] mm: page_alloc.c: Add tracepoints for slowpath
Date: Wed, 27 Jul 2016 11:23:03 -0400	[thread overview]
Message-ID: <20160727112303.11409a4e@gandalf.local.home> (raw)
In-Reply-To: <6b12aed89ad75cb2b3525a24265fa1d622409b42.1469629027.git.janani.rvchndrn@gmail.com>

On Wed, 27 Jul 2016 10:47:59 -0400
Janani Ravichandran <janani.rvchndrn@gmail.com> wrote:

> Add tracepoints to the slowpath code to gather some information.
> The tracepoints can also be used to find out how much time was spent in
> the slowpath.
> 
> Signed-off-by: Janani Ravichandran <janani.rvchndrn@gmail.com>
> ---
>  include/trace/events/kmem.h | 40 ++++++++++++++++++++++++++++++++++++++++
>  mm/page_alloc.c             |  5 +++++
>  2 files changed, 45 insertions(+)
> 
> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> index 6b2e154..c19ab9f 100644
> --- a/include/trace/events/kmem.h
> +++ b/include/trace/events/kmem.h
> @@ -169,6 +169,46 @@ TRACE_EVENT(mm_page_free,
>  			__entry->order)
>  );
>  
> +TRACE_EVENT(mm_slowpath_begin,
> +
> +	TP_PROTO(gfp_t gfp_mask, int order),
> +
> +	TP_ARGS(gfp_mask, order),
> +
> +	TP_STRUCT__entry(
> +		__field(gfp_t, gfp_mask)
> +		__field(int, order)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->gfp_mask = gfp_mask;
> +		__entry->order = order;
> +	),
> +
> +	TP_printk("gfp_mask:%s order=%d",
> +		show_gfp_flags(__entry->gfp_mask),
> +		__entry->order)
> +);
> +
> +TRACE_EVENT(mm_slowpath_end,
> +
> +	TP_PROTO(struct page *page),
> +
> +	TP_ARGS(page),
> +
> +	TP_STRUCT__entry(
> +		__field(unsigned long, pfn)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->pfn = page ? page_to_pfn(page) : -1UL;
> +	),
> +
> +	TP_printk("page=%p pfn=%lu",
> +		__entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,

Note, userspace tools will not be able to do this conversion (like
trace-cmd or perf).

> +		__entry->pfn != -1UL ? __entry->pfn : 0)
> +);
> +
>  TRACE_EVENT(mm_page_free_batched,
>  
>  	TP_PROTO(struct page *page, int cold),
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 8b3e134..be9c688 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3595,6 +3595,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>  				(__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)))
>  		gfp_mask &= ~__GFP_ATOMIC;
>  
> +	trace_mm_slowpath_begin(gfp_mask, order);
> +
>  retry:
>  	if (gfp_mask & __GFP_KSWAPD_RECLAIM)
>  		wake_all_kswapds(order, ac);
> @@ -3769,6 +3771,9 @@ noretry:
>  nopage:
>  	warn_alloc_failed(gfp_mask, order, NULL);
>  got_pg:
> +
> +	trace_mm_slowpath_end(page);
> +

I'm thinking you only need one tracepoint, and use function_graph
tracer for the length of the function call.

 # cd /sys/kernel/debug/tracing
 # echo __alloc_pages_nodemask > set_ftrace_filter
 # echo function_graph > current_tracer
 # echo 1 > events/kmem/trace_mm_slowpath/enable

-- Steve


>  	return page;
>  }
>  

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-07-27 15:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27 14:43 [PATCH 0/2] New tracepoints for slowpath and memory compaction Janani Ravichandran
2016-07-27 14:47 ` [PATCH 1/2] mm: page_alloc.c: Add tracepoints for slowpath Janani Ravichandran
2016-07-27 15:23   ` Steven Rostedt [this message]
2016-07-27 17:20     ` Dave Hansen
2016-07-27 17:30       ` Steven Rostedt
2016-07-28 20:11     ` Janani Ravichandran
2016-08-04 15:19       ` Steven Rostedt
2016-08-05 16:03         ` Janani Ravichandran
2016-08-05 16:30           ` Steven Rostedt
2016-08-07 10:36             ` Janani Ravichandran
2016-07-27 16:33   ` Michal Hocko
2016-07-27 18:16     ` Rik van Riel
2016-07-27 18:28       ` Steven Rostedt
2016-07-27 18:44       ` Michal Hocko
2016-07-27 18:57         ` Rik van Riel
2016-07-27 14:51 ` [PATCH 2/2] mm: compaction.c: Add/Modify direct compaction tracepoints Janani Ravichandran
2016-07-27 15:24   ` Steven Rostedt
2016-08-01 13:25   ` Vlastimil Babka
2016-08-07 12:32     ` Janani Ravichandran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160727112303.11409a4e@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=bywxiaobai@163.com \
    --cc=hannes@compxchg.org \
    --cc=janani.rvchndrn@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=riel@surriel.com \
    --cc=vbabka@suse.cz \
    --cc=vdavydov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox