From: Petr Mladek <pmladek@suse.cz>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Jiri Kosina <jkosina@suse.cz>,
linux-kernel@vger.kernel.org, Petr Mladek <pmladek@suse.cz>
Subject: [PATCH v4 2/3] trace: process entire stop_critical_timing() on the same CPU
Date: Tue, 29 Jul 2014 14:31:42 +0200 [thread overview]
Message-ID: <1406637103-15435-3-git-send-email-pmladek@suse.cz> (raw)
In-Reply-To: <1406637103-15435-1-git-send-email-pmladek@suse.cz>
The interrupts off latency tracing heavily depends on disabled interrupts.
This is also the case of stop_critical_timings(). There is the following
nested call:
+ stop_critical_timing()
+ check_critical_timing()
+ update_max_tr_single()
+ ring_buffer_swap_cpu()
, where ring_buffer_swap_cpu() works with disabled interrupts only when
the swap is done for this cpu.
This patch solves the problem by disabling preemption early in
stop_critical_timings() and doing the whole job on the same CPU.
Note that big part was done with disabled preemption even before.
See raw_spin_lock_irqsave() in check_critical_timing(). The extended
scope affects only few fast operations and should not cause any harm
to the system.
Signed-off-by: Petr Mladek <pmladek@suse.cz>
---
kernel/trace/trace_irqsoff.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 9bb104f748d0..1d4eeb304583 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -405,21 +405,26 @@ stop_critical_timing(unsigned long ip, unsigned long parent_ip)
struct trace_array_cpu *data;
unsigned long flags;
- cpu = raw_smp_processor_id();
+ /*
+ * We need to call ring_buffer_swap_cpu() with disabled interrupts.
+ * Let's make sure that it works with this CPU buffer.
+ */
+ cpu = get_cpu();
+
/* Always clear the tracing cpu on stopping the trace */
if (unlikely(per_cpu(tracing_cpu, cpu)))
per_cpu(tracing_cpu, cpu) = 0;
else
- return;
+ goto out;
if (!tracer_enabled || !tracing_is_enabled())
- return;
+ goto out;
data = per_cpu_ptr(tr->trace_buffer.data, cpu);
if (unlikely(!data) ||
!data->critical_start || atomic_read(&data->disabled))
- return;
+ goto out;
atomic_inc(&data->disabled);
@@ -428,6 +433,8 @@ stop_critical_timing(unsigned long ip, unsigned long parent_ip)
check_critical_timing(tr, data, parent_ip ? : ip, cpu);
data->critical_start = 0;
atomic_dec(&data->disabled);
+out:
+ put_cpu();
}
/* start and stop critical timings used to for stoppage (in idle) */
--
1.8.4
next prev parent reply other threads:[~2014-07-29 12:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 12:31 [PATCH v4 0/3] ring-buffer/ftrace: Race when writing and swapping cpu buffer in parallel Petr Mladek
2014-07-29 12:31 ` [PATCH v4 1/3] ring-buffer: " Petr Mladek
2014-07-29 12:31 ` Petr Mladek [this message]
2014-07-29 12:31 ` [PATCH v4 3/3] trace: Allow to call update_max_tr_single() from another CPU Petr Mladek
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=1406637103-15435-3-git-send-email-pmladek@suse.cz \
--to=pmladek@suse.cz \
--cc=fweisbec@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.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®