[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y5NpDF0AnY9ibwEl@google.com>
Date: Fri, 9 Dec 2022 09:57:48 -0700
From: Ross Zwisler <zwisler@...gle.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@...r.kernel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] ring-buffer: Handle resize in early boot up
On Fri, Dec 09, 2022 at 10:11:51AM -0500, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@...dmis.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@...gle.com>
> Signed-off-by: Steven Rostedt <rostedt@...dmis.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).
Powered by blists - more mailing lists