From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755105AbbCBQCF (ORCPT ); Mon, 2 Mar 2015 11:02:05 -0500 Received: from mga09.intel.com ([134.134.136.24]:16188 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755034AbbCBQCA (ORCPT ); Mon, 2 Mar 2015 11:02:00 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,676,1418112000"; d="scan'208";a="685612157" From: Tom Zanussi To: rostedt@goodmis.org Cc: masami.hiramatsu.pt@hitachi.com, namhyung@kernel.org, andi@firstfloor.org, ast@plumgrid.com, linux-kernel@vger.kernel.org, Tom Zanussi Subject: [PATCH 08/15] tracing: Make kmem memory allocation tracepoints conditional Date: Mon, 2 Mar 2015 10:01:01 -0600 Message-Id: <3da6d2d62663a0689957d1ed731f0ccca4ed89d7.1425310176.git.tom.zanussi@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making the memory allocation tracepoints conditional allows those events to be traced using the functions containing them e.g. the kmalloc_trace() handler can itself use kmalloc() in the trace path, which otherwise wouldn't be possible. The TP_CONDITION simply tests gfp_flags for the newly introduced ___GFP_NOTRACE and if true, the tracepoint simply returns without tracing. This allows _notrace versions of the memory allocation functions to be defined, which do the same thing as the normal versions but in addition set the ___GFP_NOTRACE flag, and thus avoid the (possibly indirect) recursive calls to themselves. Signed-off-by: Tom Zanussi --- include/trace/events/kmem.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h index aece134..6d34eed 100644 --- a/include/trace/events/kmem.h +++ b/include/trace/events/kmem.h @@ -42,20 +42,24 @@ DECLARE_EVENT_CLASS(kmem_alloc, show_gfp_flags(__entry->gfp_flags)) ); -DEFINE_EVENT(kmem_alloc, kmalloc, +DEFINE_EVENT_CONDITION(kmem_alloc, kmalloc, TP_PROTO(unsigned long call_site, const void *ptr, size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) + TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags), + + TP_CONDITION(!(gfp_flags & ___GFP_NOTRACE)) ); -DEFINE_EVENT(kmem_alloc, kmem_cache_alloc, +DEFINE_EVENT_CONDITION(kmem_alloc, kmem_cache_alloc, TP_PROTO(unsigned long call_site, const void *ptr, size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags), - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags) + TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags), + + TP_CONDITION(!(gfp_flags & ___GFP_NOTRACE)) ); DECLARE_EVENT_CLASS(kmem_alloc_node, @@ -96,22 +100,26 @@ DECLARE_EVENT_CLASS(kmem_alloc_node, __entry->node) ); -DEFINE_EVENT(kmem_alloc_node, kmalloc_node, +DEFINE_EVENT_CONDITION(kmem_alloc_node, kmalloc_node, TP_PROTO(unsigned long call_site, const void *ptr, size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags, int node), - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) + TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node), + + TP_CONDITION(!(gfp_flags & ___GFP_NOTRACE)) ); -DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node, +DEFINE_EVENT_CONDITION(kmem_alloc_node, kmem_cache_alloc_node, TP_PROTO(unsigned long call_site, const void *ptr, size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags, int node), - TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) + TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node), + + TP_CONDITION(!(gfp_flags & ___GFP_NOTRACE)) ); DECLARE_EVENT_CLASS(kmem_free, @@ -191,13 +199,15 @@ TRACE_EVENT(mm_page_free_batched, __entry->cold) ); -TRACE_EVENT(mm_page_alloc, +TRACE_EVENT_CONDITION(mm_page_alloc, TP_PROTO(struct page *page, unsigned int order, gfp_t gfp_flags, int migratetype), TP_ARGS(page, order, gfp_flags, migratetype), + TP_CONDITION(!(gfp_flags & ___GFP_NOTRACE)), + TP_STRUCT__entry( __field( struct page *, page ) __field( unsigned int, order ) -- 1.9.3