linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.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,
	"Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Subject: Re: [PATCH 2/3] tracing: Add trace_irqsoff tracepoints
Date: Thu, 18 Aug 2016 10:44:12 +0200	[thread overview]
Message-ID: <20160818084412.b24japksnn6hq45n@nobby.bmw-carit.de> (raw)
In-Reply-To: <1471504166-27665-3-git-send-email-binoy.jayan@linaro.org>

On Thu, Aug 18, 2016 at 12:39:25PM +0530, Binoy Jayan wrote:
>  static struct trace_array		*irqsoff_trace __read_mostly;
>  static int				tracer_enabled __read_mostly;
>  
>  static DEFINE_PER_CPU(int, tracing_cpu);
> -
> +static DEFINE_PER_CPU(cycle_t, ts_irqs);
> +static DEFINE_PER_CPU(cycle_t, ts_preempt);
> +static DEFINE_PER_CPU(cycle_t, ts_critical_timings);
>  static DEFINE_RAW_SPINLOCK(max_trace_lock);

What about creating cycle_t array and introduce only one tracepoint
type which containts the type? I think it should be possible to get
the right plot via hist's filter option:

'hist:key=latency.bucket:val=hitcount:sort=latency if cpu==0 && type==0'

Obviously, there is a performance impact. It would be good to see some
numbers.

cheers,
daniel

Just as rough idea (not tested):

diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 03cdff8..012544c 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -19,7 +19,15 @@
 static struct trace_array		*irqsoff_trace __read_mostly;
 static int				tracer_enabled __read_mostly;
 
+enum latency_type {
+	LAT_IRQ,
+	LAT_PREEMPT,
+	LAT_CRITTIME,
+	LAT_MAX
+};
+
 static DEFINE_PER_CPU(int, tracing_cpu);
+static DEFINE_PER_CPU(cycle_t[LAT_MAX], lat_data);
 
 static DEFINE_RAW_SPINLOCK(max_trace_lock);
 
@@ -350,6 +358,19 @@ out:
 	__trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
 }
 
+static inline void lat_timestamp(enum latency_type type)
+{
+	int cpu = raw_smp_processor_id();
+	per_cpu(lat_data[type], cpu) = ftrace_now(cpu);
+}
+
+static inline void lat_trace(enum latency_type type)
+{
+	int cpu = raw_smp_processor_id();
+	trace_latency_preempt(type,
+			ftrace_now(cpu) - per_cpu(lat_data[type], cpu));
+}
+
 static inline void
 start_critical_timing(unsigned long ip, unsigned long parent_ip)
 {
@@ -422,6 +443,9 @@ stop_critical_timing(unsigned long ip, unsigned long parent_ip)
 /* start and stop critical timings used to for stoppage (in idle) */
 void start_critical_timings(void)
 {
+	if (trace_latency_preempt_enabled())
+		lat_timestamp(LAT_CRITTIME);
+
 	if (preempt_trace() || irq_trace())
 		start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
 }
@@ -431,6 +455,9 @@ void stop_critical_timings(void)
 {
 	if (preempt_trace() || irq_trace())
 		stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
+
+	if (trace_latency_preempt_enabled())
+		lat_trace(LAT_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_enable())
+		lat_trace(LAT_CRITTIME);
+
 	if (!preempt_trace() && irq_trace())
 		stop_critical_timing(a0, a1);
 }
@@ -446,6 +476,9 @@ 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())
+		lat_timestamp(LAT_IRQ);
 }
 
 #else /* !CONFIG_PROVE_LOCKING */

  reply	other threads:[~2016-08-18  8:44 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 [this message]
2016-08-18 14:21   ` Steven Rostedt
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=20160818084412.b24japksnn6hq45n@nobby.bmw-carit.de \
    --to=wagi@monom.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 \
    --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;
as well as URLs for NNTP newsgroup(s).