]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tracepoints: Do not punish non static call users
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 8 Feb 2021 20:09:24 +0000 (15:09 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 9 Feb 2021 17:16:27 +0000 (12:16 -0500)
With static calls, a tracepoint can call the callback directly if there is
only one callback registered to that tracepoint. When there is more than
one, the static call will call the tracepoint's "iterator" function, which
needs to reload the tracepoint's "funcs" array again, as it could have
changed since the first time it was loaded.

But an arch without static calls is punished by having to load the
tracepoint's "funcs" array twice. Once in the DO_TRACE macro, and once
again in the iterator macro.

For archs without static calls, there's no reason to load the array macro
in the first place, since the iterator function will do it anyway.

Change the __DO_TRACE_CALL() macro to do the load and call of the
tracepoints funcs array only for architectures with static calls, and just
call the iterator function directly for architectures without static calls.

Link: https://lkml.kernel.org/r/20210208201050.909329787@goodmis.org
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
include/linux/tracepoint.h

index 42bb5b753b338628fad7a8327abf9818345b103c..2aad1c10821a16df52541f0f402aa6bc03dc223f 100644 (file)
@@ -152,9 +152,19 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 #ifdef TRACEPOINTS_ENABLED
 
 #ifdef CONFIG_HAVE_STATIC_CALL
-#define __DO_TRACE_CALL(name)  static_call(tp_func_##name)
+#define __DO_TRACE_CALL(name, args)                                    \
+       do {                                                            \
+               struct tracepoint_func *it_func_ptr;                    \
+               void *__data;                                           \
+               it_func_ptr =                                           \
+                       rcu_dereference_raw((&__tracepoint_##name)->funcs); \
+               if (it_func_ptr) {                                      \
+                       __data = (it_func_ptr)->data;                   \
+                       static_call(tp_func_##name)(__data, args);      \
+               }                                                       \
+       } while (0)
 #else
-#define __DO_TRACE_CALL(name)  __traceiter_##name
+#define __DO_TRACE_CALL(name, args)    __traceiter_##name(NULL, args)
 #endif /* CONFIG_HAVE_STATIC_CALL */
 
 /*
@@ -163,9 +173,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
  */
 #define __DO_TRACE(name, args, cond, rcuidle)                          \
        do {                                                            \
-               struct tracepoint_func *it_func_ptr;                    \
                int __maybe_unused __idx = 0;                           \
-               void *__data;                                           \
                                                                        \
                if (!(cond))                                            \
                        return;                                         \
@@ -185,12 +193,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
                        rcu_irq_enter_irqson();                         \
                }                                                       \
                                                                        \
-               it_func_ptr =                                           \
-                       rcu_dereference_raw((&__tracepoint_##name)->funcs); \
-               if (it_func_ptr) {                                      \
-                       __data = (it_func_ptr)->data;                   \
-                       __DO_TRACE_CALL(name)(__data, args);            \
-               }                                                       \
+               __DO_TRACE_CALL(name, TP_ARGS(args));                   \
                                                                        \
                if (rcuidle) {                                          \
                        rcu_irq_exit_irqson();                          \