On 2025-06-13 11:22, Sebastian Andrzej Siewior wrote:
This is a follow-up on
https://lore.kernel.org/all/20241206120709.736f9...@gandalf.local.home/T/#u
The problem is that trace points disable preemption due to sched-RCU.
The arguments passed to tracepoints may used locks (yes, they should
not) and eBPF programs can be attached to tracepoints which may use
locks which become sleeping locks on PREEMPT_RT.
Mathieu said regarding the need for preempt_notrace:
| There are a few things to consider here about the constraints of the
| callsites where the tracepoints are inserted. In general, those need to
| be:
|
| - NMI-safe
| - notrace
| - usable from the scheduler (with rq lock held)
| - usable to trace the RCU implementation
This is covered by the here suggested rcu_read_lock_notrace().
Mathieu's suggested steps were:
| Well the first step would be to introduce a rcu_read_lock/unlock_notrace.
Patch #1
| This solves the problem at the tracepoint level, but requires that we
| initially move the preempt disable to the tracer callbacks. Then we
| can figure out within each tracer what needs to be done to further
| reduce the preempt off critical section.
Here I am stuck. Patch #2 is probably not correct due to "move the
preempt disable to the tracer callbacks". I didn't figure out where they
areā¦
As part of the faultable syscall tracepoint series, I've identified
those sites for perf and ftrace. See those relevant commits:
commit 65e7462a16cea593025ca3b34c5d74e69b027ee0
Author: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>
Date: Tue Oct 8 21:07:13 2024 -0400
tracing/perf: disable preemption in syscall probe
commit 13d750c2c03e9861e15268574ed2c239cca9c9d5
Author: Mathieu Desnoyers <mathieu.desnoy...@efficios.com>
Date: Tue Oct 8 21:07:12 2024 -0400
tracing/ftrace: disable preemption in syscall probe
You'll want to make sure the DECLARE_EVENT_CLASS also
does the preempt_{disable,enable}_notrace similarly
to the DECLARE_EVENT_SYSCALL_CLASS.
AFAIR something also had to be done to make sure migration
was disabled for ebpf syscall probes. There too you will want
to disable migration for normal tracepoints as well.
Hoping this helps,
Mathieu
Sebastian Andrzej Siewior (2):
rcu: Add rcu_read_lock_notrace()
trace: Use rcu_read_lock() instead preempt_disable()
include/linux/rcupdate.h | 41 +++++++++++++++++++++++++++++++++++++
include/linux/tracepoint.h | 2 +-
kernel/rcu/tree_plugin.h | 14 +++++++++++++
kernel/trace/trace_events.c | 8 +-------
4 files changed, 57 insertions(+), 8 deletions(-)
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com