Skip to content

Commit a363d27

Browse files
compudjrostedt
authored andcommitted
tracing: Allow system call tracepoints to handle page faults
Use Tasks Trace RCU to protect iteration of system call enter/exit tracepoint probes to allow those probes to handle page faults. In preparation for this change, all tracers registering to system call enter/exit tracepoints should expect those to be called with preemption enabled. This allows tracers to fault-in userspace system call arguments such as path strings within their probe callbacks. Cc: Michael Jeanson <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Yonghong Song <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: [email protected] Cc: Joel Fernandes <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 4aadde8 commit a363d27

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

include/linux/tracepoint.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/errno.h>
1818
#include <linux/types.h>
1919
#include <linux/rcupdate.h>
20+
#include <linux/rcupdate_trace.h>
2021
#include <linux/tracepoint-defs.h>
2122
#include <linux/static_call.h>
2223

@@ -107,6 +108,7 @@ void for_each_tracepoint_in_module(struct module *mod,
107108
#ifdef CONFIG_TRACEPOINTS
108109
static inline void tracepoint_synchronize_unregister(void)
109110
{
111+
synchronize_rcu_tasks_trace();
110112
synchronize_rcu();
111113
}
112114
#else
@@ -196,6 +198,12 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
196198
/*
197199
* it_func[0] is never NULL because there is at least one element in the array
198200
* when the array itself is non NULL.
201+
*
202+
* With @syscall=0, the tracepoint callback array dereference is
203+
* protected by disabling preemption.
204+
* With @syscall=1, the tracepoint callback array dereference is
205+
* protected by Tasks Trace RCU, which allows probes to handle page
206+
* faults.
199207
*/
200208
#define __DO_TRACE(name, args, cond, syscall) \
201209
do { \
@@ -204,11 +212,17 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
204212
if (!(cond)) \
205213
return; \
206214
\
207-
preempt_disable_notrace(); \
215+
if (syscall) \
216+
rcu_read_lock_trace(); \
217+
else \
218+
preempt_disable_notrace(); \
208219
\
209220
__DO_TRACE_CALL(name, TP_ARGS(args)); \
210221
\
211-
preempt_enable_notrace(); \
222+
if (syscall) \
223+
rcu_read_unlock_trace(); \
224+
else \
225+
preempt_enable_notrace(); \
212226
} while (0)
213227

214228
/*

init/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,7 @@ config BINDGEN_VERSION_TEXT
19851985
#
19861986
config TRACEPOINTS
19871987
bool
1988+
select TASKS_TRACE_RCU
19881989

19891990
source "kernel/Kconfig.kexec"
19901991

0 commit comments

Comments
 (0)