tracing: Disable preemption when using the filter buffer
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 30 Nov 2021 02:39:47 +0000 (21:39 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 6 Dec 2021 20:37:22 +0000 (15:37 -0500)
commit6c536d76cfe63b79e9e468ef0876315420a19074
treecadb655ecb226c9c6a1b4e32dde49ea3f685ded8
parente07a1d576239cf836070e740d4bd7c5e8a64868f
tracing: Disable preemption when using the filter buffer

In case trace_event_buffer_lock_reserve() is called with preemption
enabled, the algorithm that defines the usage of the per cpu filter buffer
may fail if the task schedules to another CPU after determining which
buffer it will use.

Disable preemption when using the filter buffer. And because that same
buffer must be used throughout the call, keep preemption disabled until
the filter buffer is released.

This will also keep the semantics between the use case of when the filter
buffer is used, and when the ring buffer itself is used, as that case also
disables preemption until the ring buffer is released.

Link: https://lkml.kernel.org/r/20211130024318.880190623@goodmis.org
[ Fixed warning of assignment in if statement
Reported-by: kernel test robot <lkp@intel.com> ]
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace.c
kernel/trace/trace.h