]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Disable interrupt or preemption before acquiring arch_spinlock_t
authorWaiman Long <longman@redhat.com>
Thu, 22 Sep 2022 14:56:22 +0000 (10:56 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:21 +0000 (13:22 +0200)
commit4be561dcc46cd5e2d074e100396cb5b5e442c791
treeb9fb018119f1779b58d9c9f21c76eeed5031f09d
parent1a08e7da7e94acc71702c98bb7ae420a4847eafd
tracing: Disable interrupt or preemption before acquiring arch_spinlock_t

commit 1712d593d2c43dbe2bf22d2a4a74be790f20f4c5 upstream.

It was found that some tracing functions in kernel/trace/trace.c acquire
an arch_spinlock_t with preemption and irqs enabled. An example is the
tracing_saved_cmdlines_size_read() function which intermittently causes
a "BUG: using smp_processor_id() in preemptible" warning when the LTP
read_all_proc test is run.

That can be problematic in case preemption happens after acquiring the
lock. Add the necessary preemption or interrupt disabling code in the
appropriate places before acquiring an arch_spinlock_t.

The convention here is to disable preemption for trace_cmdline_lock and
interupt for max_lock.

Link: https://lkml.kernel.org/r/20220922145622.1744826-1-longman@redhat.com
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Will Deacon <will@kernel.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: stable@vger.kernel.org
Fixes: 117601251602 ("tracing: Add conditional snapshot")
Fixes: ed5a83df142d ("tracing: Introduce saved_cmdlines_size file")
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace.c