public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Joel Fernandes <joelaf@google.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@android.com,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH v7 2/2] tracing: Add support for preempt and irq enable/disable events
Date: Wed, 4 Oct 2017 18:01:51 +0200	[thread overview]
Message-ID: <20171004160151.noficzcd4ef5ydml@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20170929212245.24168-2-joelaf@google.com>

On Fri, Sep 29, 2017 at 02:22:45PM -0700, Joel Fernandes wrote:
> diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
> index 0e3033c00474..515ac851841a 100644
> --- a/kernel/trace/trace_irqsoff.c
> +++ b/kernel/trace/trace_irqsoff.c
> @@ -16,6 +16,9 @@
>  
>  #include "trace.h"
>  
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/preemptirq.h>
> +
>  #if defined(CONFIG_IRQSOFF_TRACER) || defined(CONFIG_PREEMPT_TRACER)
>  static struct trace_array		*irqsoff_trace __read_mostly;
>  static int				tracer_enabled __read_mostly;
> @@ -776,27 +779,60 @@ static inline void tracer_preempt_on(unsigned long a0, unsigned long a1) { }
>  static inline void tracer_preempt_off(unsigned long a0, unsigned long a1) { }
>  #endif
>  
> +/*
> + * trace_hardirqs_off can be called even when IRQs are already off.

In fact it must be.. otherwise you'll get a complaint.

>     It is
> + * pointless and inconsistent with trace_preempt_enable and
> + * trace_preempt_disable to trace this, lets prevent double counting it with a
> + * per-cpu variable. Also reuse the per-cpu variable for other trace_hardirqs_*
> + * functions since we already define it.

Lockdep ignores redundant calls. But I'm not entirely sure what the
above is trying to say.

> + */
> +static DEFINE_PER_CPU(int, tracing_irq_cpu);
> +
>  #if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PROVE_LOCKING)
>  void trace_hardirqs_on(void)
>  {
> +	if (!this_cpu_read(tracing_irq_cpu))
> +		return;
> +
> +	trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
>  	tracer_hardirqs_on();
> +
> +	this_cpu_write(tracing_irq_cpu, 0);
>  }
>  EXPORT_SYMBOL(trace_hardirqs_on);
>  
>  void trace_hardirqs_off(void)
>  {
> +	if (this_cpu_read(tracing_irq_cpu))
> +		return;
> +
> +	this_cpu_write(tracing_irq_cpu, 1);
> +
> +	trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1);
>  	tracer_hardirqs_off();
>  }
>  EXPORT_SYMBOL(trace_hardirqs_off);
>  
>  __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
>  {
> +	if (!this_cpu_read(tracing_irq_cpu))
> +		return;
> +
> +	trace_irq_enable_rcuidle(CALLER_ADDR0, caller_addr);
>  	tracer_hardirqs_on_caller(caller_addr);
> +
> +	this_cpu_write(tracing_irq_cpu, 0);
>  }
>  EXPORT_SYMBOL(trace_hardirqs_on_caller);
>  
>  __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
>  {
> +	if (this_cpu_read(tracing_irq_cpu))
> +		return;
> +
> +	this_cpu_write(tracing_irq_cpu, 1);
> +
> +	trace_irq_disable_rcuidle(CALLER_ADDR0, caller_addr);
>  	tracer_hardirqs_off_caller(caller_addr);
>  }
>  EXPORT_SYMBOL(trace_hardirqs_off_caller);

lockdep implements the trace_hardirq_*() in terms of *_caller(). Would
that make sense here?

  reply	other threads:[~2017-10-04 16:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 21:22 [PATCH v7 1/2] tracing: Prepare to add preempt and irq trace events Joel Fernandes
2017-09-29 21:22 ` [PATCH v7 2/2] tracing: Add support for preempt and irq enable/disable events Joel Fernandes
2017-10-04 16:01   ` Peter Zijlstra [this message]
2017-10-04 16:43     ` Joel Fernandes
2017-10-06  8:59       ` Joel Fernandes
2017-10-05 23:28     ` Joel Fernandes
2017-10-05 23:29       ` Joel Fernandes
2017-10-06  7:07       ` Peter Zijlstra
2017-10-06  7:28         ` Joel Fernandes
2017-10-06 13:38           ` Steven Rostedt
2017-10-06 17:27             ` Joel Fernandes
2017-10-04 16:04   ` Peter Zijlstra
2017-10-04 16:31     ` Joel Fernandes
2017-10-04 16:44     ` Steven Rostedt
2017-10-04 16:56       ` Joel Fernandes
2017-10-04 17:03         ` Steven Rostedt
2017-10-04 20:13           ` Joel Fernandes

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=20171004160151.noficzcd4ef5ydml@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=joelaf@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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