#define __DO_TRACE_CALL(name, args) __traceiter_##name(NULL, args)
#endif /* CONFIG_HAVE_STATIC_CALL */
- /*
- * it_func[0] is never NULL because there is at least one element in the array
- * when the array itself is non NULL.
- *
- * With @syscall=0, the tracepoint callback array dereference is
- * protected by disabling preemption.
- * With @syscall=1, the tracepoint callback array dereference is
- * protected by Tasks Trace RCU, which allows probes to handle page
- * faults.
- */
- #define __DO_TRACE(name, args, cond, syscall) \
- do { \
- int __maybe_unused __idx = 0; \
- \
- if (!(cond)) \
- return; \
- \
- if (syscall) \
- rcu_read_lock_trace(); \
- else \
- preempt_disable_notrace(); \
- \
- __DO_TRACE_CALL(name, TP_ARGS(args)); \
- \
- if (syscall) \
- rcu_read_unlock_trace(); \
- else \
- preempt_enable_notrace(); \
- } while (0)
-
+/*
+ * Declare an exported function that Rust code can call to trigger this
+ * tracepoint. This function does not include the static branch; that is done
+ * in Rust to avoid a function call when the tracepoint is disabled.
+ */
+#define DEFINE_RUST_DO_TRACE(name, proto, args)
+#define __DEFINE_RUST_DO_TRACE(name, proto, args) \
+ notrace void rust_do_trace_##name(proto) \
+ { \
+ __rust_do_trace_##name(args); \
+ }
+
/*
* Make sure the alignment of the structure in the __tracepoints section will
* not add unwanted padding between the beginning of the section and the
}
#define __DECLARE_TRACE(name, proto, args, cond, data_proto) \
- __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \
+ __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
+ static inline void __rust_do_trace_##name(proto) \
+ { \
- __DO_TRACE(name, \
- TP_ARGS(args), \
- TP_CONDITION(cond), 0); \
++ if (cond) { \
++ guard(preempt_notrace)(); \
++ __DO_TRACE_CALL(name, TP_ARGS(args)); \
++ } \
+ } \
static inline void trace_##name(proto) \
{ \
- if (static_branch_unlikely(&__tracepoint_##name.key)) \
- __DO_TRACE(name, \
- TP_ARGS(args), \
- TP_CONDITION(cond), 0); \
+ if (static_branch_unlikely(&__tracepoint_##name.key)) { \
+ if (cond) { \
+ guard(preempt_notrace)(); \
+ __DO_TRACE_CALL(name, TP_ARGS(args)); \
+ } \
+ } \
if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
WARN_ONCE(!rcu_is_watching(), \
"RCU not watching for tracepoint"); \
} \
}
- #define __DECLARE_TRACE_SYSCALL(name, proto, args, cond, data_proto) \
- __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \
+ #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \
+ __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \
+ static inline void __rust_do_trace_##name(proto) \
+ { \
- __DO_TRACE(name, \
- TP_ARGS(args), \
- TP_CONDITION(cond), 1); \
++ guard(rcu_tasks_trace)(); \
++ __DO_TRACE_CALL(name, TP_ARGS(args)); \
+ } \
static inline void trace_##name(proto) \
{ \
might_fault(); \