From: Ross Zwisler <zwisler@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] ring-buffer: Handle resize in early boot up
Date: Fri, 9 Dec 2022 09:57:48 -0700 [thread overview]
Message-ID: <Y5NpDF0AnY9ibwEl@google.com> (raw)
In-Reply-To: <20221209101151.1fec1167@gandalf.local.home>
On Fri, Dec 09, 2022 at 10:11:51AM -0500, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> With the new command line option that allows trace event triggers to be
> added at boot, the "snapshot" trigger will allocate the snapshot buffer
> very early, when interrupts can not be enabled. Allocating the ring buffer
> is not the problem, but it also resizes it, which is, as the resize code
> does synchronization that can not be preformed at early boot.
>
> To handle this, first change the raw_spin_lock_irq() in rb_insert_pages()
> to raw_spin_lock_irqsave(), such that the unlocking of that spin lock will
> not enable interrupts.
>
> Next, where it calls schedule_work_on(), disable migration and check if
> the CPU to update is the current CPU, and if so, perform the work
> directly, otherwise re-enable migration and call the schedule_work_on() to
> the CPU that is being updated. The rb_insert_pages() just needs to be run
> on the CPU that it is updating, and does not need preemption nor
> interrupts disabled when calling it.
>
> Link: https://lore.kernel.org/lkml/Y5J%2FCajlNh1gexvo@google.com/
>
> Fixes: a01fdc897fa5 ("tracing: Add trace_trigger kernel command line option")
> Reported-by: Ross Zwisler <zwisler@google.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
<>
> @@ -2298,9 +2308,17 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
> if (!cpu_online(cpu_id))
> rb_update_pages(cpu_buffer);
> else {
> - schedule_work_on(cpu_id,
> - &cpu_buffer->update_pages_work);
> - wait_for_completion(&cpu_buffer->update_done);
> + /* Run directly if possible. */
> + migrate_disable();
> + if (cpu_id == smp_processor_id()) {
> + rb_update_pages(cpu_buffer);
> + migrate_enable();
> + } else {
> + migrate_enable();
> + schedule_work_on(cpu_id,
> + &cpu_buffer->update_pages_work);
> + wait_for_completion(&cpu_buffer->update_done);
I ran with this patch on my test VM and hit the same Oops from the original
report.
I think the problem is that we're still trying to enable interrupts via
wait_for_completion():
wait_for_completion()
wait_for_common()
__wait_for_common()
raw_spin_unlock_irq()
_raw_spin_unlock_irq()
__raw_spin_unlock_irq()
local_irq_enable()
I'm testing on a QEMU VM with 4 virtual CPUs, if that helps WRT where work is
being scheduled (cpu_id == smp_processor_id).
next prev parent reply other threads:[~2022-12-09 16:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 15:11 [PATCH] ring-buffer: Handle resize in early boot up Steven Rostedt
2022-12-09 16:57 ` Ross Zwisler [this message]
2022-12-09 18:13 ` Steven Rostedt
2022-12-09 18:32 ` Ross Zwisler
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=Y5NpDF0AnY9ibwEl@google.com \
--to=zwisler@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@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