FAILED: patch "[PATCH] tracing: Disable snapshot buffer when stopping instance" failed to apply to 5.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y
git checkout FETCH_HEAD
git cherry-pick -x b538bf7d0ec11ca49f536dfda742a5f6db90a798
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023120908-crisply-trash-d37e@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^..
Possible dependencies:
b538bf7d0ec1 ("tracing: Disable snapshot buffer when stopping instance tracers") 13292494379f ("tracing: Make struct ring_buffer less ambiguous") 1c5eb4481e01 ("tracing: Rename trace_buffer to array_buffer") 2d6425af6116 ("tracing: Declare newly exported APIs in include/linux/trace.h")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From b538bf7d0ec11ca49f536dfda742a5f6db90a798 Mon Sep 17 00:00:00 2001
From: "Steven Rostedt (Google)" <[email protected]>
Date: Tue, 5 Dec 2023 16:52:11 -0500
Subject: [PATCH] tracing: Disable snapshot buffer when stopping instance
tracers
It use to be that only the top level instance had a snapshot buffer (for latency tracers like wakeup and irqsoff). When stopping a tracer in an instance would not disable the snapshot buffer. This could have some unintended consequences if the irqsoff tracer is enabled.
Consolidate the tracing_start/stop() with tracing_start/stop_tr() so that all instances behave the same. The tracing_start/stop() functions will just call their respective tracing_start/stop_tr() with the global_array passed in.
kernel/trace/trace.c +53 -95
@@ -2360,49 +2360,6 @@ int is_tracing_stopped(void)return global_trace.stop_count; } -/** -* tracing_start - quick start of the tracer -* -* If tracing is enabled but was stopped by tracing_stop, -* this will start the tracer back up. -*/ -void tracing_start (void ) -{ -struct trace_buffer *buffer; -unsigned long flags; - -if (tracing_disabled) -return ; - -raw_spin_lock_irqsave (&global_trace.start_lock, flags); -if (--global_trace.stop_count) { -if (global_trace.stop_count <0 ) { -/* Someone screwed up their debugging */ -WARN_ON_ONCE (1 ); - global_trace.stop_count =0 ; - } - goto out; - } - -/* Prevent the buffers from switching */ -arch_spin_lock (&global_trace.max_lock); - - buffer = global_trace.array_buffer.buffer; -if (buffer) -ring_buffer_record_enable (buffer); - -#ifdef CONFIG_TRACER_MAX_TRACE - buffer = global_trace.max_buffer.buffer; -if (buffer) -ring_buffer_record_enable (buffer); -#endif - -arch_spin_unlock (&global_trace.max_lock); - - out: -raw_spin_unlock_irqrestore (&global_trace.start_lock, flags); -} -static void tracing_start_tr (struct trace_array *tr) {struct trace_buffer *buffer;
@@ -2411,25 +2368,70 @@ static void tracing_start_tr(struct trace_array *tr)if (tracing_disabled)return ; -/* If global, we need to also start the max tracer */ -if (tr->flags &TRACE_ARRAY_FL_GLOBAL ) -return tracing_start (); -raw_spin_lock_irqsave (&tr->start_lock, flags); -if (--tr->stop_count) { -if (tr->stop_count <0 ) { +if (WARN_ON_ONCE (tr->stop_count <0 )) {/* Someone screwed up their debugging */ -WARN_ON_ONCE (1 ); tr->stop_count =0 ; } goto out; } +/* Prevent the buffers from switching */ +arch_spin_lock (&tr->max_lock); + buffer = tr->array_buffer.buffer;if (buffer)ring_buffer_record_enable (buffer); +#ifdef CONFIG_TRACER_MAX_TRACE + buffer = tr->max_buffer.buffer; +if (buffer) +ring_buffer_record_enable (buffer); +#endif + +arch_spin_unlock (&tr->max_lock); + + out: +raw_spin_unlock_irqrestore (&tr->start_lock, flags); +} + +/** +* tracing_start - quick start of the tracer +* +* If tracing is enabled but was stopped by tracing_stop, +* this will start the tracer back up. +*/ +void tracing_start (void ) + +{ +return tracing_start_tr (&global_trace); +} + +static void tracing_stop_tr (struct trace_array *tr) +{ +struct trace_buffer *buffer; +unsigned long flags; + +raw_spin_lock_irqsave (&tr->start_lock, flags); +if (tr->stop_count++) + goto out; + +/* Prevent the buffers from switching */ +arch_spin_lock (&tr->max_lock); + + buffer = tr->array_buffer.buffer; +if (buffer) +ring_buffer_record_disable (buffer); + +#ifdef CONFIG_TRACER_MAX_TRACE + buffer = tr->max_buffer.buffer; +if (buffer) +ring_buffer_record_disable (buffer); +#endif + +arch_spin_unlock (&tr->max_lock); + out:raw_spin_unlock_irqrestore (&tr->start_lock, flags); }
@@ -2442,51 +2444,7 @@ static void tracing_start_tr(struct trace_array *tr)*/ void tracing_stop (void ) { -struct trace_buffer *buffer; -unsigned long flags; - -raw_spin_lock_irqsave (&global_trace.start_lock, flags); -if (global_trace.stop_count++) - goto out; - -/* Prevent the buffers from switching */ -arch_spin_lock (&global_trace.max_lock); - - buffer = global_trace.array_buffer.buffer; -if (buffer) -ring_buffer_record_disable (buffer); - -#ifdef CONFIG_TRACER_MAX_TRACE - buffer = global_trace.max_buffer.buffer; -if (buffer) -ring_buffer_record_disable (buffer); -#endif - -arch_spin_unlock (&global_trace.max_lock); - - out: -raw_spin_unlock_irqrestore (&global_trace.start_lock, flags); -} - -static void tracing_stop_tr (struct trace_array *tr) -{ -struct trace_buffer *buffer; -unsigned long flags; - -/* If global, we need to also stop the max tracer */ -if (tr->flags &TRACE_ARRAY_FL_GLOBAL ) -return tracing_stop (); - -raw_spin_lock_irqsave (&tr->start_lock, flags); -if (tr->stop_count++) - goto out; - - buffer = tr->array_buffer.buffer; -if (buffer) -ring_buffer_record_disable (buffer); - - out: -raw_spin_unlock_irqrestore (&tr->start_lock, flags); +return tracing_stop_tr (&global_trace); }static int trace_save_cmdline (struct task_struct *tsk)
Steven Rostedt
maintainerQuoted 25 lines · On Sat, 09 Dec 2023 13:27:08 +0100 <[email protected]> wrote:
The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y
git checkoutFETCH_HEAD
git cherry-pick -xb538bf7d0ec11ca49f536dfda742a5f6db90a798
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023120908-crisply-trash-d37e@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^..Possible dependencies:
b538bf7d0ec1("tracing: Disable snapshot buffer when stopping instance tracers")13292494379f("tracing: Make structring_bufferless ambiguous")1c5eb4481e01("tracing: Renametrace_buffertoarray_buffer")2d6425af6116("tracing: Declare newly exported APIs ininclude/linux/trace.h")thanks,
greg k-h
Quoted 8 lines
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
b538bf7d0ec11ca49f536dfda742a5f6db90a798Mon Sep 17 00:00:00 2001From: "Steven Rostedt (Google)" <[email protected]>
Date: Tue, 5 Dec 2023 16:52:11 -0500
Subject: [PATCH] tracing: Disable snapshot buffer when stopping instance
tracers
This is the fix for 5.4.265, although running tests on it, there appears to be other issues with snapshot and 5.4.265 with and without this patch.
I don't have time to investigate though.
-- Steve
kernel/trace/trace.c +34 -76
@@ -2039,13 +2039,7 @@ int is_tracing_stopped(void)return global_trace.stop_count; } -/** -* tracing_start - quick start of the tracer -* -* If tracing is enabled but was stopped by tracing_stop, -* this will start the tracer back up. -*/ -void tracing_start (void ) +static void tracing_start_tr (struct trace_array *tr) {struct ring_buffer *buffer;unsigned long flags;
@@ -2053,119 +2047,83 @@ void tracing_start(void)if (tracing_disabled)return ; -raw_spin_lock_irqsave (&global_trace.start_lock, flags); -if (--global_trace.stop_count) { -if (global_trace.stop_count <0 ) { +raw_spin_lock_irqsave (&tr->start_lock, flags); +if (--tr->stop_count) { +if (WARN_ON_ONCE (tr->stop_count <0 )) {/* Someone screwed up their debugging */ -WARN_ON_ONCE (1 ); - global_trace.stop_count =0 ; + tr->stop_count =0 ; } goto out; }/* Prevent the buffers from switching */ -arch_spin_lock (&global_trace.max_lock); +arch_spin_lock (&tr->max_lock); - buffer = global_trace.trace_buffer.buffer; + buffer = tr->trace_buffer.buffer;if (buffer)ring_buffer_record_enable (buffer);#ifdef CONFIG_TRACER_MAX_TRACE - buffer = global_trace.max_buffer.buffer; + buffer = tr->max_buffer.buffer;if (buffer)ring_buffer_record_enable (buffer);#endif -arch_spin_unlock (&global_trace.max_lock); - - out: -raw_spin_unlock_irqrestore (&global_trace.start_lock, flags); -} - -static void tracing_start_tr (struct trace_array *tr) -{ -struct ring_buffer *buffer; -unsigned long flags; - -if (tracing_disabled) -return ; - -/* If global, we need to also start the max tracer */ -if (tr->flags &TRACE_ARRAY_FL_GLOBAL ) -return tracing_start (); - -raw_spin_lock_irqsave (&tr->start_lock, flags); - -if (--tr->stop_count) { -if (tr->stop_count <0 ) { -/* Someone screwed up their debugging */ -WARN_ON_ONCE (1 ); - tr->stop_count =0 ; - } - goto out; - } - - buffer = tr->trace_buffer.buffer; -if (buffer) -ring_buffer_record_enable (buffer); +arch_spin_unlock (&tr->max_lock); out:raw_spin_unlock_irqrestore (&tr->start_lock, flags); }/** -* tracing_stop - quick stop of the tracer +* tracing_start - quick start of the tracer * -* Light weight way to stop tracing. Use in conjunction with -* tracing_start. +* If tracing is enabled but was stopped by tracing_stop, +* this will start the tracer back up. */ -void tracing_stop (void ) +void tracing_start (void ) + +{ +return tracing_start_tr (&global_trace); +} + +static void tracing_stop_tr (struct trace_array *tr) {struct ring_buffer *buffer;unsigned long flags; -raw_spin_lock_irqsave (&global_trace.start_lock, flags); -if (global_trace.stop_count++) +raw_spin_lock_irqsave (&tr->start_lock, flags); +if (tr->stop_count++) goto out;/* Prevent the buffers from switching */ -arch_spin_lock (&global_trace.max_lock); +arch_spin_lock (&tr->max_lock); - buffer = global_trace.trace_buffer.buffer; + buffer = tr->trace_buffer.buffer;if (buffer)ring_buffer_record_disable (buffer);#ifdef CONFIG_TRACER_MAX_TRACE - buffer = global_trace.max_buffer.buffer; + buffer = tr->max_buffer.buffer;if (buffer)ring_buffer_record_disable (buffer);#endif -arch_spin_unlock (&global_trace.max_lock); +arch_spin_unlock (&tr->max_lock); out: -raw_spin_unlock_irqrestore (&global_trace.start_lock, flags); +raw_spin_unlock_irqrestore (&tr->start_lock, flags); } -static void tracing_stop_tr (struct trace_array *tr) +/** +* tracing_stop - quick stop of the tracer +* +* Light weight way to stop tracing. Use in conjunction with +* tracing_start. +*/ +void tracing_stop (void ) { -struct ring_buffer *buffer; -unsigned long flags; - -/* If global, we need to also stop the max tracer */ -if (tr->flags &TRACE_ARRAY_FL_GLOBAL ) -return tracing_stop (); - -raw_spin_lock_irqsave (&tr->start_lock, flags); -if (tr->stop_count++) - goto out; - - buffer = tr->trace_buffer.buffer; -if (buffer) -ring_buffer_record_disable (buffer); - - out: -raw_spin_unlock_irqrestore (&tr->start_lock, flags); +return tracing_stop_tr (&global_trace); }static int trace_save_cmdline (struct task_struct *tsk)