summaryrefslogtreecommitdiffstats
path: root/kernel/tracepoint.c
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2020-08-18 15:57:52 +0200
committerIngo Molnar <mingo@kernel.org>2020-09-01 09:58:06 +0200
commitd25e37d89dd2f41d7acae0429039d2f0ae8b4a07 (patch)
tree16e6d52b374b3907e51dd3a96b30f3c427f9a55f /kernel/tracepoint.c
parenta945c8345ec0decb2f1a7f19a8c5e60bcb1dd1eb (diff)
downloadlinux-d25e37d89dd2f41d7acae0429039d2f0ae8b4a07.tar.bz2
tracepoint: Optimize using static_call()
Currently the tracepoint site will iterate a vector and issue indirect calls to however many handlers are registered (ie. the vector is long). Using static_call() it is possible to optimize this for the common case of only having a single handler registered. In this case the static_call() can directly call this handler. Otherwise, if the vector is longer than 1, call a function that iterates the whole vector like the current code. [peterz: updated to new interface] Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20200818135805.279421092@infradead.org
Diffstat (limited to 'kernel/tracepoint.c')
-rw-r--r--kernel/tracepoint.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 8e05ed2cd39e..e92f3fb8887a 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -221,6 +221,20 @@ static void *func_remove(struct tracepoint_func **funcs,
return old;
}
+static void tracepoint_update_call(struct tracepoint *tp, struct tracepoint_func *tp_funcs)
+{
+ void *func = tp->iterator;
+
+ /* Synthetic events do not have static call sites */
+ if (!tp->static_call_key)
+ return;
+
+ if (!tp_funcs[1].func)
+ func = tp_funcs[0].func;
+
+ __static_call_update(tp->static_call_key, tp->static_call_tramp, func);
+}
+
/*
* Add the probe function to a tracepoint.
*/
@@ -251,8 +265,9 @@ static int tracepoint_add_func(struct tracepoint *tp,
* include/linux/tracepoint.h using rcu_dereference_sched().
*/
rcu_assign_pointer(tp->funcs, tp_funcs);
- if (!static_key_enabled(&tp->key))
- static_key_slow_inc(&tp->key);
+ tracepoint_update_call(tp, tp_funcs);
+ static_key_enable(&tp->key);
+
release_probes(old);
return 0;
}
@@ -281,9 +296,11 @@ static int tracepoint_remove_func(struct tracepoint *tp,
if (tp->unregfunc && static_key_enabled(&tp->key))
tp->unregfunc();
- if (static_key_enabled(&tp->key))
- static_key_slow_dec(&tp->key);
+ static_key_disable(&tp->key);
+ } else {
+ tracepoint_update_call(tp, tp_funcs);
}
+
rcu_assign_pointer(tp->funcs, tp_funcs);
release_probes(old);
return 0;