mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
To: Binoy Jayan <binoy.jayan@linaro.org>,
	"Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
	<linaro-kernel@lists.linaro.org>, Carsten Emde <C.Emde@osadl.org>,
	<linux-kernel@vger.kernel.org>,
	Masami <masami.hiramatsu@linaro.org>
Subject: Re: [PATCH v3 2/3] tracing: Add trace_irqsoff tracepoints
Date: Mon, 29 Aug 2016 11:43:50 +0200	[thread overview]
Message-ID: <fe9ddd6d-e36b-e43b-9d2c-9d09f2aed9de@bmw-carit.de> (raw)
In-Reply-To: <1472453728-577-3-git-send-email-binoy.jayan@linaro.org>

Hi Binoy,

Some minor nitpicking.

On 08/29/2016 08:55 AM, Binoy Jayan wrote:
> +DECLARE_EVENT_CLASS(latency_template,
> +	TP_PROTO(int ltype, int cpu, cycles_t latency),
> +
> +	TP_ARGS(ltype, cpu, latency),
> +
> +	TP_STRUCT__entry(
> +		__field(int,		ltype)
> +		__field(int,		cpu)
> +		__field(cycles_t,	latency)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->ltype		= ltype;
> +		__entry->cpu		= cpu;
> +		__entry->latency	= latency;
> +	),
> +
> +	TP_printk("ltype=%d, cpu=%d, latency=%lu",
> +		__entry->ltype, __entry->cpu, (unsigned long) __entry->latency)
> +);

As Steven already pointed out, the cpu field is available in all traces. 
It's one of the predefined fields (see 
kernel/trace/trace_events.c/trace_define_generic_fields()). Just drop it.

> +
> +DEFINE_EVENT(latency_template, latency_preempt,
> +	    TP_PROTO(int ltype, int cpu, cycles_t latency),
> +	    TP_ARGS(ltype, cpu, latency));
> +
> +#endif /* _TRACE_HIST_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
> diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
> index 03cdff8..d4f2b25 100644
> --- a/kernel/trace/trace_irqsoff.c
> +++ b/kernel/trace/trace_irqsoff.c
> @@ -13,14 +13,27 @@
>  #include <linux/uaccess.h>
>  #include <linux/module.h>
>  #include <linux/ftrace.h>
> +#include <linux/percpu-defs.h>
> +
> +#include <trace/events/sched.h>
>
>  #include "trace.h"
>
> +#define CREATE_TRACE_POINTS
> +#include <trace/events/latency.h>
> +
>  static struct trace_array		*irqsoff_trace __read_mostly;
>  static int				tracer_enabled __read_mostly;
>
> -static DEFINE_PER_CPU(int, tracing_cpu);
> +enum latency_type {
> +        TS_IRQ,
> +        TS_PREEMPT,
> +        TS_CRITTIME,
> +        TS_MAX
> +};

Come to think of it, the TS_ prefix doesn't really make sense, maybe LT_ 
would be more consistent (short hand for latency type).

> +static DEFINE_PER_CPU(int, tracing_cpu);
> +static DEFINE_PER_CPU(cycle_t, lat_ts[TS_MAX]);
>  static DEFINE_RAW_SPINLOCK(max_trace_lock);
>
>  enum {
> @@ -419,9 +432,19 @@ stop_critical_timing(unsigned long ip, unsigned long parent_ip)
>  	atomic_dec(&data->disabled);
>  }
>
> +static inline void latency_trace(enum latency_type type)
> +{
> +	trace_latency_preempt(type, raw_smp_processor_id(),
> +		(cycle_t) trace_clock_local() - this_cpu_read(lat_ts[type]));
> +
> +}

empty line here

>  /* start and stop critical timings used to for stoppage (in idle) */
>  void start_critical_timings(void)
>  {
> +	if (trace_latency_preempt_enabled())
> +		this_cpu_write(lat_ts[TS_CRITTIME],
> +			(cycle_t) trace_clock_local());
> +

Introduce a inline function like the latency_trace() function. No need 
to open code this logic 3 times.

>  	if (preempt_trace() || irq_trace())
>  		start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
>  }
> @@ -431,6 +454,10 @@ void stop_critical_timings(void)
>  {
>  	if (preempt_trace() || irq_trace())
>  		stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
> +
> +	if (trace_latency_preempt_enabled())
> +		latency_trace(TS_CRITTIME);
> +
>  }
>  EXPORT_SYMBOL_GPL(stop_critical_timings);
>
> @@ -438,6 +465,9 @@ EXPORT_SYMBOL_GPL(stop_critical_timings);
>  #ifdef CONFIG_PROVE_LOCKING
>  void time_hardirqs_on(unsigned long a0, unsigned long a1)
>  {
> +	if (trace_latency_preempt_enabled()) {
> +		latency_trace(TS_IRQ);
> +	}

Please follow the style of the rest of the file. Just drop the brackets.

>  	if (!preempt_trace() && irq_trace())
>  		stop_critical_timing(a0, a1);
>  }
> @@ -446,6 +476,11 @@ void time_hardirqs_off(unsigned long a0, unsigned long a1)
>  {
>  	if (!preempt_trace() && irq_trace())
>  		start_critical_timing(a0, a1);
> +
> +	if (trace_latency_preempt_enabled()) {
> +		this_cpu_write(lat_ts[TS_IRQ],
> +			(cycle_t) trace_clock_local());
> +	}

Same thing.

>  }
>
>  #else /* !CONFIG_PROVE_LOCKING */
> @@ -503,6 +538,9 @@ EXPORT_SYMBOL(trace_hardirqs_off_caller);
>  #ifdef CONFIG_PREEMPT_TRACER
>  void trace_preempt_on(unsigned long a0, unsigned long a1)
>  {
> +	if (trace_latency_preempt_enabled())
> +		latency_trace(TS_PREEMPT);
> +
>  	if (preempt_trace() && !irq_trace())
>  		stop_critical_timing(a0, a1);
>  }
> @@ -511,6 +549,11 @@ 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()) {
> +		this_cpu_write(lat_ts[TS_PREEMPT],
> +			(cycle_t) trace_clock_local());
> +	}

And here too.

>  }
>  #endif /* CONFIG_PREEMPT_TRACER */


cheers,
daniel

  reply	other threads:[~2016-08-29  9:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29  6:55 [PATCH v3 0/3] *** Latency histograms - IRQSOFF,PREEMPTOFF *** Binoy Jayan
2016-08-29  6:55 ` [PATCH v3 1/3] tracing: Deference pointers without RCU checks Binoy Jayan
2016-08-29  6:55 ` [PATCH v3 2/3] tracing: Add trace_irqsoff tracepoints Binoy Jayan
2016-08-29  9:43   ` Daniel Wagner [this message]
2016-08-30  9:41     ` Binoy Jayan
2016-08-30 13:52       ` Steven Rostedt
2016-08-30 14:01         ` Daniel Wagner
2016-08-30 14:20           ` Daniel Wagner
2016-08-30 15:02             ` Daniel Wagner
2016-08-30 21:06               ` Steven Rostedt
2016-08-31  6:05               ` Binoy Jayan
2016-08-29  6:55 ` [PATCH v3 3/3] tracing: Histogram for missed timer offsets Binoy Jayan

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=fe9ddd6d-e36b-e43b-9d2c-9d09f2aed9de@bmw-carit.de \
    --to=daniel.wagner@bmw-carit.de \
    --cc=C.Emde@osadl.org \
    --cc=arnd@arndb.de \
    --cc=binoy.jayan@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu@linaro.org \
    --cc=mingo@redhat.com \
    --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

all inboxes | Powered by JetHome®