From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1768238AbcHROWT (ORCPT ); Thu, 18 Aug 2016 10:22:19 -0400 Received: from smtprelay0088.hostedemail.com ([216.40.44.88]:52483 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1767438AbcHROVj (ORCPT ); Thu, 18 Aug 2016 10:21:39 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3355:3622:3865:3867:3868:3870:3871:3872:3873:3874:4605:5007:6261:7875:7903:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12294:12296:12438:12517:12519:12740:13161:13184:13229:13439:14096:14097:14181:14659:14721:21080:21433:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: self43_e1cceb3cc354 X-Filterd-Recvd-Size: 4431 Date: Thu, 18 Aug 2016 10:21:35 -0400 From: Steven Rostedt To: Binoy Jayan Cc: Arnd Bergmann , linaro-kernel@lists.linaro.org, Daniel Wagner , Carsten Emde , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] tracing: Add trace_irqsoff tracepoints Message-ID: <20160818102135.549efeea@gandalf.local.home> In-Reply-To: <1471504166-27665-3-git-send-email-binoy.jayan@linaro.org> References: <1471504166-27665-1-git-send-email-binoy.jayan@linaro.org> <1471504166-27665-3-git-send-email-binoy.jayan@linaro.org> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Aug 2016 12:39:25 +0530 Binoy Jayan wrote: > > +static inline void mark_timestamp(cycle_t __percpu *ts) > +{ > + int cpu = raw_smp_processor_id(); > + per_cpu(*ts, cpu) = ftrace_now(cpu); Just an FYI. ftrace_now() is whatever the clock source is that is specified by /sys/kernel/tracing/trace_clock. Which could be a slower "global" clock, or even cycles. If that's what you want then this is the right approach. But if you want something more accurate per cpu (may not be accurate across CPUs) then you may want to use trace_clock_local() (which is the "[local]" clock in the trace_clock file. Also, you should convert the above to: this_cpu_write(ts, ftrace_now(raw_smp_processor_id())); As this_cpu_write is optimized over a per_cpu() use. > +} > + > +static inline cycle_t get_delta(int cpu, cycle_t __percpu *ts) > +{ > + return ftrace_now(cpu) - per_cpu(*ts, cpu); Use this_cpu_read(ts) > +} > /* start and stop critical timings used to for stoppage (in idle) */ > void start_critical_timings(void) > { > + if (trace_latency_critical_timings_enabled()) > + mark_timestamp(&ts_critical_timings); > + > if (preempt_trace() || irq_trace()) > start_critical_timing(CALLER_ADDR0, CALLER_ADDR1); > } > @@ -431,6 +451,13 @@ void stop_critical_timings(void) > { > if (preempt_trace() || irq_trace()) > stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1); > + > + if (trace_latency_critical_timings_enabled()) { > + int cpu = raw_smp_processor_id(); > + trace_latency_critical_timings(cpu, > + get_delta(cpu, &ts_critical_timings)); > + } > + > } > EXPORT_SYMBOL_GPL(stop_critical_timings); > > @@ -438,6 +465,10 @@ EXPORT_SYMBOL_GPL(stop_critical_timings); > #ifdef CONFIG_PROVE_LOCKING > void time_hardirqs_on(unsigned long a0, unsigned long a1) > { > + if (trace_latency_irqs_enabled()) { > + int cpu = raw_smp_processor_id(); > + trace_latency_irqs(cpu, get_delta(cpu, &ts_irqs)); > + } > if (!preempt_trace() && irq_trace()) > stop_critical_timing(a0, a1); > } > @@ -446,6 +477,10 @@ void time_hardirqs_off(unsigned long a0, unsigned long a1) > { > if (!preempt_trace() && irq_trace()) > start_critical_timing(a0, a1); > + > + if (trace_latency_irqs_enabled()) { > + mark_timestamp(&ts_irqs); > + } > } > > #else /* !CONFIG_PROVE_LOCKING */ > @@ -500,9 +535,16 @@ EXPORT_SYMBOL(trace_hardirqs_off_caller); > #endif /* CONFIG_PROVE_LOCKING */ > #endif /* CONFIG_IRQSOFF_TRACER */ > > +int count = 0; > + > #ifdef CONFIG_PREEMPT_TRACER > void trace_preempt_on(unsigned long a0, unsigned long a1) > { > + if (trace_latency_preempt_enabled()) { > + int cpu = raw_smp_processor_id(); > + trace_latency_preempt(cpu, get_delta(cpu, &ts_preempt)); If cpu in the tracepoint will always be smp_processor_id() you don't need to do that. It's already saved by the tracer. -- Steve > + } > + > if (preempt_trace() && !irq_trace()) > stop_critical_timing(a0, a1); > } > @@ -511,6 +553,10 @@ void trace_preempt_off(unsigned long a0, unsigned long a1) > { > if (preempt_trace() && !irq_trace()) > start_critical_timing(a0, a1); > + > + if (trace_latency_preempt_enabled()) { > + mark_timestamp(&ts_preempt); > + } > } > #endif /* CONFIG_PREEMPT_TRACER */ >