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

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Declare system call tracepoints with TRACE_EVENT_SYSCALL

In preparation for allowing system call tracepoints to handle page
faults, introduce TRACE_EVENT_SYSCALL to declare the sys_enter/sys_exit
tracepoints.

Move the common code between __DECLARE_TRACE and __DECLARE_TRACE_SYSCALL
into __DECLARE_TRACE_COMMON.

This change is not meant to alter the generated code, and only prepares
the following modifications.

Cc: Michael Jeanson <mjeanson@efficios.com>
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>
Link: https://lore.kernel.org/20241009010718.2050182-2-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)
0e6caab8 e53244e2

+81 -15
+40 -13
include/linux/tracepoint.h
··· 197 197 * it_func[0] is never NULL because there is at least one element in the array 198 198 * when the array itself is non NULL. 199 199 */ 200 - #define __DO_TRACE(name, args, cond) \ 200 + #define __DO_TRACE(name, args, cond, syscall) \ 201 201 do { \ 202 202 int __maybe_unused __idx = 0; \ 203 203 \ ··· 222 222 * site if it is not watching, as it will need to be active when the 223 223 * tracepoint is enabled. 224 224 */ 225 - #define __DECLARE_TRACE(name, proto, args, cond, data_proto) \ 225 + #define __DECLARE_TRACE_COMMON(name, proto, args, cond, data_proto) \ 226 226 extern int __traceiter_##name(data_proto); \ 227 227 DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name); \ 228 228 extern struct tracepoint __tracepoint_##name; \ 229 - static inline void trace_##name(proto) \ 230 - { \ 231 - if (static_branch_unlikely(&__tracepoint_##name.key)) \ 232 - __DO_TRACE(name, \ 233 - TP_ARGS(args), \ 234 - TP_CONDITION(cond)); \ 235 - if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ 236 - WARN_ONCE(!rcu_is_watching(), \ 237 - "RCU not watching for tracepoint"); \ 238 - } \ 239 - } \ 240 229 static inline int \ 241 230 register_trace_##name(void (*probe)(data_proto), void *data) \ 242 231 { \ ··· 253 264 trace_##name##_enabled(void) \ 254 265 { \ 255 266 return static_branch_unlikely(&__tracepoint_##name.key);\ 267 + } 268 + 269 + #define __DECLARE_TRACE(name, proto, args, cond, data_proto) \ 270 + __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ 271 + static inline void trace_##name(proto) \ 272 + { \ 273 + if (static_branch_unlikely(&__tracepoint_##name.key)) \ 274 + __DO_TRACE(name, \ 275 + TP_ARGS(args), \ 276 + TP_CONDITION(cond), 0); \ 277 + if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ 278 + WARN_ONCE(!rcu_is_watching(), \ 279 + "RCU not watching for tracepoint"); \ 280 + } \ 281 + } 282 + 283 + #define __DECLARE_TRACE_SYSCALL(name, proto, args, cond, data_proto) \ 284 + __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ 285 + static inline void trace_##name(proto) \ 286 + { \ 287 + if (static_branch_unlikely(&__tracepoint_##name.key)) \ 288 + __DO_TRACE(name, \ 289 + TP_ARGS(args), \ 290 + TP_CONDITION(cond), 1); \ 291 + if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ 292 + WARN_ONCE(!rcu_is_watching(), \ 293 + "RCU not watching for tracepoint"); \ 294 + } \ 256 295 } 257 296 258 297 /* ··· 365 348 return false; \ 366 349 } 367 350 351 + #define __DECLARE_TRACE_SYSCALL __DECLARE_TRACE 352 + 368 353 #define DEFINE_TRACE_FN(name, reg, unreg, proto, args) 369 354 #define DEFINE_TRACE(name, proto, args) 370 355 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) ··· 427 408 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \ 428 409 cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \ 429 410 PARAMS(void *__data, proto)) 411 + 412 + #define DECLARE_TRACE_SYSCALL(name, proto, args) \ 413 + __DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args), \ 414 + cpu_online(raw_smp_processor_id()), \ 415 + PARAMS(void *__data, proto)) 430 416 431 417 #define TRACE_EVENT_FLAGS(event, flag) 432 418 ··· 570 546 struct, assign, print) \ 571 547 DECLARE_TRACE_CONDITION(name, PARAMS(proto), \ 572 548 PARAMS(args), PARAMS(cond)) 549 + #define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign, \ 550 + print, reg, unreg) \ 551 + DECLARE_TRACE_SYSCALL(name, PARAMS(proto), PARAMS(args)) 573 552 574 553 #define TRACE_EVENT_FLAGS(event, flag) 575 554
+3
include/trace/bpf_probe.h
··· 53 53 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ 54 54 __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) 55 55 56 + #undef DECLARE_EVENT_SYSCALL_CLASS 57 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 58 + 56 59 /* 57 60 * This part is compiled out, it is only here as a build time check 58 61 * to make sure that if the tracepoint handling changes, the
+5
include/trace/define_trace.h
··· 46 46 assign, print, reg, unreg) \ 47 47 DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args)) 48 48 49 + #undef TRACE_EVENT_SYSCALL 50 + #define TRACE_EVENT_SYSCALL(name, proto, args, struct, assign, print, reg, unreg) \ 51 + DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args)) 52 + 49 53 #undef TRACE_EVENT_NOP 50 54 #define TRACE_EVENT_NOP(name, proto, args, struct, assign, print) 51 55 ··· 111 107 #undef TRACE_EVENT 112 108 #undef TRACE_EVENT_FN 113 109 #undef TRACE_EVENT_FN_COND 110 + #undef TRACE_EVENT_SYSCALL 114 111 #undef TRACE_EVENT_CONDITION 115 112 #undef TRACE_EVENT_NOP 116 113 #undef DEFINE_EVENT_NOP
+2 -2
include/trace/events/syscalls.h
··· 15 15 16 16 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS 17 17 18 - TRACE_EVENT_FN(sys_enter, 18 + TRACE_EVENT_SYSCALL(sys_enter, 19 19 20 20 TP_PROTO(struct pt_regs *regs, long id), 21 21 ··· 41 41 42 42 TRACE_EVENT_FLAGS(sys_enter, TRACE_EVENT_FL_CAP_ANY) 43 43 44 - TRACE_EVENT_FN(sys_exit, 44 + TRACE_EVENT_SYSCALL(sys_exit, 45 45 46 46 TP_PROTO(struct pt_regs *regs, long ret), 47 47
+3
include/trace/perf.h
··· 55 55 head, __task); \ 56 56 } 57 57 58 + #undef DECLARE_EVENT_SYSCALL_CLASS 59 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 60 + 58 61 /* 59 62 * This part is compiled out, it is only here as a build time check 60 63 * to make sure that if the tracepoint handling changes, the
+28
include/trace/trace_events.h
··· 45 45 PARAMS(print)); \ 46 46 DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)); 47 47 48 + #undef TRACE_EVENT_SYSCALL 49 + #define TRACE_EVENT_SYSCALL(name, proto, args, tstruct, assign, print, reg, unreg) \ 50 + DECLARE_EVENT_SYSCALL_CLASS(name, \ 51 + PARAMS(proto), \ 52 + PARAMS(args), \ 53 + PARAMS(tstruct), \ 54 + PARAMS(assign), \ 55 + PARAMS(print)); \ 56 + DEFINE_EVENT(name, name, PARAMS(proto), PARAMS(args)); 57 + 48 58 #include "stages/stage1_struct_define.h" 49 59 50 60 #undef DECLARE_EVENT_CLASS ··· 66 56 }; \ 67 57 \ 68 58 static struct trace_event_class event_class_##name; 59 + 60 + #undef DECLARE_EVENT_SYSCALL_CLASS 61 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 69 62 70 63 #undef DEFINE_EVENT 71 64 #define DEFINE_EVENT(template, name, proto, args) \ ··· 129 116 struct trace_event_data_offsets_##call { \ 130 117 tstruct; \ 131 118 }; 119 + 120 + #undef DECLARE_EVENT_SYSCALL_CLASS 121 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 132 122 133 123 #undef DEFINE_EVENT 134 124 #define DEFINE_EVENT(template, name, proto, args) ··· 224 208 .trace = trace_raw_output_##call, \ 225 209 }; 226 210 211 + #undef DECLARE_EVENT_SYSCALL_CLASS 212 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 213 + 227 214 #undef DEFINE_EVENT_PRINT 228 215 #define DEFINE_EVENT_PRINT(template, call, proto, args, print) \ 229 216 static notrace enum print_line_t \ ··· 283 264 \ 284 265 return __data_size; \ 285 266 } 267 + 268 + #undef DECLARE_EVENT_SYSCALL_CLASS 269 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 286 270 287 271 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 288 272 ··· 431 409 * fail to compile unless it too is updated. 432 410 */ 433 411 412 + #undef DECLARE_EVENT_SYSCALL_CLASS 413 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 414 + 434 415 #undef DEFINE_EVENT 435 416 #define DEFINE_EVENT(template, call, proto, args) \ 436 417 static inline void ftrace_test_probe_##call(void) \ ··· 458 433 .reg = trace_event_reg, \ 459 434 _TRACE_PERF_INIT(call) \ 460 435 }; 436 + 437 + #undef DECLARE_EVENT_SYSCALL_CLASS 438 + #define DECLARE_EVENT_SYSCALL_CLASS DECLARE_EVENT_CLASS 461 439 462 440 #undef DEFINE_EVENT 463 441 #define DEFINE_EVENT(template, call, proto, args) \