Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing: Introduce tracepoint_is_faultable()

Introduce a "faultable" flag within the extended structure to know
whether a tracepoint needs rcu tasks trace grace period before reclaim.
This can be queried using tracepoint_is_faultable().

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Jordan Rife <jrife@google.com>
Cc: Michael Jeanson <mjeanson@efficios.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Yonghong Song <yhs@fb.com>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Jordan Rife <jrife@google.com>
Cc: linux-trace-kernel@vger.kernel.org
Link: https://lore.kernel.org/20241031152056.744137-3-mathieu.desnoyers@efficios.com
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Mathieu Desnoyers and committed by
Steven Rostedt (Google)
654ced4a a9cfb877

+27 -1
+2
include/linux/tracepoint-defs.h
··· 32 32 struct tracepoint_ext { 33 33 int (*regfunc)(void); 34 34 void (*unregfunc)(void); 35 + /* Flags. */ 36 + unsigned int faultable:1; 35 37 }; 36 38 37 39 struct tracepoint {
+24
include/linux/tracepoint.h
··· 104 104 * tracepoint_synchronize_unregister must be called between the last tracepoint 105 105 * probe unregistration and the end of module exit to make sure there is no 106 106 * caller executing a probe when it is freed. 107 + * 108 + * An alternative is to use the following for batch reclaim associated 109 + * with a given tracepoint: 110 + * 111 + * - tracepoint_is_faultable() == false: call_rcu() 112 + * - tracepoint_is_faultable() == true: call_rcu_tasks_trace() 107 113 */ 108 114 #ifdef CONFIG_TRACEPOINTS 109 115 static inline void tracepoint_synchronize_unregister(void) ··· 117 111 synchronize_rcu_tasks_trace(); 118 112 synchronize_rcu(); 119 113 } 114 + static inline bool tracepoint_is_faultable(struct tracepoint *tp) 115 + { 116 + return tp->ext && tp->ext->faultable; 117 + } 120 118 #else 121 119 static inline void tracepoint_synchronize_unregister(void) 122 120 { } 121 + static inline bool tracepoint_is_faultable(struct tracepoint *tp) 122 + { 123 + return false; 124 + } 123 125 #endif 124 126 125 127 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS ··· 359 345 static struct tracepoint_ext __tracepoint_ext_##_name = { \ 360 346 .regfunc = _reg, \ 361 347 .unregfunc = _unreg, \ 348 + .faultable = false, \ 349 + }; \ 350 + __DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args)); 351 + 352 + #define DEFINE_TRACE_SYSCALL(_name, _reg, _unreg, _proto, _args) \ 353 + static struct tracepoint_ext __tracepoint_ext_##_name = { \ 354 + .regfunc = _reg, \ 355 + .unregfunc = _unreg, \ 356 + .faultable = true, \ 362 357 }; \ 363 358 __DEFINE_TRACE_EXT(_name, &__tracepoint_ext_##_name, PARAMS(_proto), PARAMS(_args)); 364 359 ··· 412 389 #define __DECLARE_TRACE_SYSCALL __DECLARE_TRACE 413 390 414 391 #define DEFINE_TRACE_FN(name, reg, unreg, proto, args) 392 + #define DEFINE_TRACE_SYSCALL(name, reg, unreg, proto, args) 415 393 #define DEFINE_TRACE(name, proto, args) 416 394 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) 417 395 #define EXPORT_TRACEPOINT_SYMBOL(name)
+1 -1
include/trace/define_trace.h
··· 48 48 49 49 #undef TRACE_EVENT_SYSCALL 50 50 #define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign, print, reg, unreg) \ 51 - DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args)) 51 + DEFINE_TRACE_SYSCALL(name, reg, unreg, PARAMS(proto), PARAMS(args)) 52 52 53 53 #undef TRACE_EVENT_NOP 54 54 #define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)