From patchwork Mon Feb 6 21:18:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 6672 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A087123EB0 for ; Mon, 6 Feb 2012 21:18:40 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 46B23A1841E for ; Mon, 6 Feb 2012 21:18:40 +0000 (UTC) Received: by iabz7 with SMTP id z7so12192152iab.11 for ; Mon, 06 Feb 2012 13:18:39 -0800 (PST) Received: by 10.42.57.148 with SMTP id d20mr18818582ich.33.1328563119595; Mon, 06 Feb 2012 13:18:39 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.169.210 with SMTP id a18cs103406ibz; Mon, 6 Feb 2012 13:18:38 -0800 (PST) Received: by 10.236.189.105 with SMTP id b69mr27930472yhn.90.1328563118257; Mon, 06 Feb 2012 13:18:38 -0800 (PST) Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com. [71.74.56.123]) by mx.google.com with ESMTP id b48si3327154yhm.65.2012.02.06.13.18.38; Mon, 06 Feb 2012 13:18:38 -0800 (PST) Received-SPF: neutral (google.com: 71.74.56.123 is neither permitted nor denied by best guess record for domain of rostedt@goodmis.org) client-ip=71.74.56.123; Authentication-Results: mx.google.com; spf=neutral (google.com: 71.74.56.123 is neither permitted nor denied by best guess record for domain of rostedt@goodmis.org) smtp.mail=rostedt@goodmis.org X-Authority-Analysis: v=2.0 cv=MaXuSuDf c=1 sm=0 a=ZycB6UtQUfgMyuk2+PxD7w==:17 a=dizoWrGHR7EA:10 a=5SG0PmZfjMsA:10 a=Q9fys5e9bTEA:10 a=meVymXHHAAAA:8 a=h_Lbw3XGcgpDxCBp4RAA:9 a=KP1uKegEW9Yhfx1plHAA:7 a=PUjeQqilurYA:10 a=jeBq3FmKZ4MA:10 a=ZycB6UtQUfgMyuk2+PxD7w==:117 X-Cloudmark-Score: 0 X-Originating-IP: 74.67.80.29 Received: from [74.67.80.29] ([74.67.80.29:41674] helo=[192.168.23.10]) by hrndva-oedge02.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id FE/EE-05484-9A3403F4; Mon, 06 Feb 2012 21:18:37 +0000 Message-ID: <1328563113.2200.39.camel@gandalf.stny.rr.com> Subject: [PATCH][RFC] tracing/rcu: Add trace_##name##__rcuidle() static tracepoint for inside rcu_idle_exit() sections From: Steven Rostedt To: paulmck@linux.vnet.ibm.com Cc: Rob Herring , Kevin Hilman , Nicolas Pitre , mathieu.desnoyers@polymtl.ca, peterz@infradead.org, fweisbec@gmail.com, Nicolas Ferre , dhowells@redhat.com, Lennert Buytenhek , Kukjin Kim , Russell King , eric.dumazet@gmail.com, H Hartley Sweeten , Magnus Damm , Will Deacon , Tony Lindgren , dipankar@in.ibm.com, darren@dvhart.com, mingo@elte.hu, Jean-Christophe Plagniol-Villard , Len Brown , Amit Kucheria , patches@linaro.org, Sekhar Nori , josh@joshtriplett.org, niv@us.ibm.com, linux-samsung-soc@vger.kernel.org, Barry Song , tglx@linutronix.de, linux-omap@vger.kernel.org, Andrew Victor , linux-arm-kernel@lists.infradead.org, Deepthi Dharwar , Trinabh Gupta , Valdis.Kletnieks@vt.edu, laijs@cn.fujitsu.com, linux-kernel@vger.kernel.org, "Paul E. McKenney" , Paul Mundt , Sascha Hauer , Andrew Morton , Shawn Guo Date: Mon, 06 Feb 2012 16:18:33 -0500 In-Reply-To: <20120203194005.GK2382@linux.vnet.ibm.com> References: <20120202174337.GS2518@linux.vnet.ibm.com> <20120202190708.GE2518@linux.vnet.ibm.com> <87obtgc1xx.fsf@ti.com> <4F2B1307.5010207@gmail.com> <1328223819.5882.133.camel@gandalf.stny.rr.com> <20120202232736.GL2518@linux.vnet.ibm.com> <1328237131.5882.135.camel@gandalf.stny.rr.com> <20120203060458.GF2380@linux.vnet.ibm.com> <1328295309.5882.178.camel@gandalf.stny.rr.com> <20120203194005.GK2382@linux.vnet.ibm.com> X-Mailer: Evolution 3.2.2-1 Mime-Version: 1.0 As I have said, I may find a better solution than to create a TRACE_EVENT_IDLE(), and I believe I have :-) A added a new static inline function that lets *any* tracepoint be used inside a rcu_idle_exit() section. And this also solves the problem where the same tracepoint may be used inside a rcu_idle_exit() section as well as outside of one. I added a new tracepoint function with a "_rcuidle" extension. All tracepoints can be used with either the normal "trace_foobar()" function, or the "trace_foobar_rcuidle()" function when inside a rcu_idle_exit() section. Ideally, this patch would be broken up into two commits. The first would change the tracepoint.h to introduce the new trace_foobar_rcuidle() static inline, and the second patch would change the power tracepoints to use this tracepoint function. For the RFC, I'm keeping it as a single patch. Another nice aspect about this patch is that "static inline"s are not compiled into text when not used. So only the tracepoints that actually use the _rcuidle() version will have them defined in the actual text that is booted. -- Steve Signed-off-by: Steven Rostedt Acked-by: Paul E. McKenney Reviewed-by: Josh Triplett Acked-by: Frederic Weisbecker Index: linux-trace.git/include/linux/tracepoint.h =================================================================== --- linux-trace.git.orig/include/linux/tracepoint.h +++ linux-trace.git/include/linux/tracepoint.h @@ -114,7 +114,7 @@ static inline void tracepoint_synchroniz * as "(void *, void)". The DECLARE_TRACE_NOARGS() will pass in just * "void *data", where as the DECLARE_TRACE() will pass in "void *data, proto". */ -#define __DO_TRACE(tp, proto, args, cond) \ +#define __DO_TRACE(tp, proto, args, cond, pre, post) \ do { \ struct tracepoint_func *it_func_ptr; \ void *it_func; \ @@ -123,6 +123,7 @@ static inline void tracepoint_synchroniz if (!(cond)) \ return; \ rcu_read_lock_sched_notrace(); \ + pre; \ it_func_ptr = rcu_dereference_sched((tp)->funcs); \ if (it_func_ptr) { \ do { \ @@ -132,6 +133,7 @@ static inline void tracepoint_synchroniz } while ((++it_func_ptr)->func); \ } \ rcu_read_unlock_sched_notrace(); \ + post; \ } while (0) /* @@ -139,7 +141,7 @@ static inline void tracepoint_synchroniz * not add unwanted padding between the beginning of the section and the * structure. Force alignment to the same alignment as the section start. */ -#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ extern struct tracepoint __tracepoint_##name; \ static inline void trace_##name(proto) \ { \ @@ -147,7 +149,17 @@ static inline void tracepoint_synchroniz __DO_TRACE(&__tracepoint_##name, \ TP_PROTO(data_proto), \ TP_ARGS(data_args), \ - TP_CONDITION(cond)); \ + TP_CONDITION(cond),,); \ + } \ + static inline void trace_##name##_rcuidle(proto) \ + { \ + if (static_branch(&__tracepoint_##name.key)) \ + __DO_TRACE(&__tracepoint_##name, \ + TP_PROTO(data_proto), \ + TP_ARGS(data_args), \ + TP_CONDITION(cond), \ + rcu_idle_exit(), \ + rcu_idle_enter()); \ } \ static inline int \ register_trace_##name(void (*probe)(data_proto), void *data) \ @@ -190,7 +202,7 @@ static inline void tracepoint_synchroniz EXPORT_SYMBOL(__tracepoint_##name) #else /* !CONFIG_TRACEPOINTS */ -#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ static inline void trace_##name(proto) \ { } \ static inline int \ Index: linux-trace.git/arch/x86/kernel/process.c =================================================================== --- linux-trace.git.orig/arch/x86/kernel/process.c +++ linux-trace.git/arch/x86/kernel/process.c @@ -377,8 +377,8 @@ static inline int hlt_use_halt(void) void default_idle(void) { if (hlt_use_halt()) { - trace_power_start(POWER_CSTATE, 1, smp_processor_id()); - trace_cpu_idle(1, smp_processor_id()); + trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id()); + trace_cpu_idle_rcuidle(1, smp_processor_id()); current_thread_info()->status &= ~TS_POLLING; /* * TS_POLLING-cleared state must be visible before we @@ -391,7 +391,7 @@ void default_idle(void) else local_irq_enable(); current_thread_info()->status |= TS_POLLING; - trace_power_end(smp_processor_id()); + trace_power_end_rcuidle(smp_processor_id()); trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); } else { local_irq_enable(); @@ -450,8 +450,8 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait); static void mwait_idle(void) { if (!need_resched()) { - trace_power_start(POWER_CSTATE, 1, smp_processor_id()); - trace_cpu_idle(1, smp_processor_id()); + trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id()); + trace_cpu_idle_rcuidle(1, smp_processor_id()); if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) clflush((void *)¤t_thread_info()->flags); @@ -461,8 +461,8 @@ static void mwait_idle(void) __sti_mwait(0, 0); else local_irq_enable(); - trace_power_end(smp_processor_id()); - trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); + trace_power_end_rcuidle(smp_processor_id()); + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); } else local_irq_enable(); } @@ -474,13 +474,13 @@ static void mwait_idle(void) */ static void poll_idle(void) { - trace_power_start(POWER_CSTATE, 0, smp_processor_id()); - trace_cpu_idle(0, smp_processor_id()); + trace_power_start_rcuidle(POWER_CSTATE, 0, smp_processor_id()); + trace_cpu_idle_rcuidle(0, smp_processor_id()); local_irq_enable(); while (!need_resched()) cpu_relax(); - trace_power_end(smp_processor_id()); - trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); + trace_power_end_rcuidle(smp_processor_id()); + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); } /*