linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Binoy Jayan <binoy.jayan@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linaro-kernel@lists.linaro.org,
	Daniel Wagner <daniel.wagner@bmw-carit.de>,
	Carsten Emde <C.Emde@osadl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] tracing: Add trace_irqsoff tracepoints
Date: Thu, 18 Aug 2016 10:21:35 -0400	[thread overview]
Message-ID: <20160818102135.549efeea@gandalf.local.home> (raw)
In-Reply-To: <1471504166-27665-3-git-send-email-binoy.jayan@linaro.org>

On Thu, 18 Aug 2016 12:39:25 +0530
Binoy Jayan <binoy.jayan@linaro.org> 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 */
>  

  parent reply	other threads:[~2016-08-18 14:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18  7:09 [PATCH 0/3] *** Latency trace events - irqs, preempt, critical timing *** Binoy Jayan
2016-08-18  7:09 ` [PATCH 1/3] tracing: Deference pointers without RCU checks Binoy Jayan
2016-08-18  7:37   ` Daniel Wagner
2016-08-18  7:09 ` [PATCH 2/3] tracing: Add trace_irqsoff tracepoints Binoy Jayan
2016-08-18  8:44   ` Daniel Wagner
2016-08-18 14:21   ` Steven Rostedt [this message]
2016-08-22  6:00   ` kbuild test robot
2016-08-22  7:37   ` kbuild test robot
2016-08-18  7:09 ` [PATCH 3/3] tracing: Histogram for missed timer offsets Binoy Jayan
2016-08-22  6:41   ` kbuild test robot
2016-08-22  8:44   ` kbuild test robot

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=20160818102135.549efeea@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=C.Emde@osadl.org \
    --cc=arnd@arndb.de \
    --cc=binoy.jayan@linaro.org \
    --cc=daniel.wagner@bmw-carit.de \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).