From: Mete Durlu <meted@linux.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Sven Schnelle <svens@linux.ibm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: use ring_buffer_record_is_set_on() in tracer_tracing_is_on()
Date: Thu, 8 Feb 2024 11:25:50 +0100 [thread overview]
Message-ID: <8c986cb3-61b3-4f65-81c9-ffcfa994390f@linux.ibm.com> (raw)
In-Reply-To: <20240207104703.071ee985@rorschach.local.home>
On 2/7/24 16:47, Steven Rostedt wrote:
> On Wed, 07 Feb 2024 14:33:21 +0100
> Sven Schnelle <svens@linux.ibm.com> wrote:
>
>> My assumption without reading the code is that something like this
>> happens:
>>
>> CPU0 CPU1
>> [ringbuffer enabled]
>> ring_buffer_write()
>> if (atomic_read(&buffer->record_disabled))
>> goto out;
>> echo 0 > tracing_on
>> record_disabled |= RB_BUFFER_OFF
>> csum1=`md5sum trace`
>
> Note, the CPU1 is performing with preemption disabled, so for this to
> happen, something really bad happened on CPU0 to delay preempt disabled
> section so long to allow the trace to be read. Perhaps we should have
> the return of the echo 0 > tracing_on require a synchronize_rcu() to
> make sure all ring buffers see it disabled before it returns.
>
> But unless your system is doing something really stressed to cause the
> preempt disabled section to take so long, I highly doubt this was the
> race.
>
I have been only able to reliably reproduce this issue when the system
is under load from stressors. But I am not sure if it can be considered
as *really stressed*.
system : 8 cpus (4 physical cores)
load : stress-ng --fanotify 1 (or --context 2)
result : ~5/10 test fails
of course as load increases test starts to fail more often, but a
single stressor doesn't seem like much to me for a 4 core machine.
after adding synchronize_rcu() + patch from Sven, I am no longer seeing
failures with the setup above. So it seems like synchronize_rcu() did
the trick(or at least it helps a lot) for the case described on the
previous mail. I couldn't trigger the failure yet, not even with
increased load(but now the test case takes > 5mins to finish :) ).
Here is the diff:
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
@@ -9328,10 +9328,12 @@ rb_simple_write(struct file *filp, const char
__user *ubuf,
val = 0; /* do nothing */
} else if (val) {
tracer_tracing_on(tr);
+ synchronize_rcu();
if (tr->current_trace->start)
tr->current_trace->start(tr);
} else {
tracer_tracing_off(tr);
+ synchronize_rcu();
if (tr->current_trace->stop)
tr->current_trace->stop(tr);
Not 100% sure if these were the correct places to add them.
next prev parent reply other threads:[~2024-02-08 10:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-05 6:53 Sven Schnelle
2024-02-05 12:55 ` Steven Rostedt
2024-02-05 13:16 ` Sven Schnelle
2024-02-05 14:23 ` Steven Rostedt
2024-02-05 15:09 ` Sven Schnelle
2024-02-06 6:32 ` Sven Schnelle
2024-02-06 8:48 ` Sven Schnelle
2024-02-06 11:01 ` Steven Rostedt
2024-02-07 5:50 ` Sven Schnelle
2024-02-07 11:09 ` Steven Rostedt
2024-02-07 12:07 ` Mete Durlu
2024-02-07 12:28 ` Steven Rostedt
2024-02-07 13:33 ` Sven Schnelle
2024-02-07 15:47 ` Steven Rostedt
2024-02-08 10:25 ` Mete Durlu [this message]
2024-02-12 18:53 ` Steven Rostedt
2024-02-12 22:54 ` Mete Durlu
2024-02-12 23:12 ` Steven Rostedt
2024-02-06 7:05 ` Mete Durlu
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=8c986cb3-61b3-4f65-81c9-ffcfa994390f@linux.ibm.com \
--to=meted@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=svens@linux.ibm.com \
/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®