summaryrefslogtreecommitdiffstats
path: root/kernel/tracepoint.c
diff options
context:
space:
mode:
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>2024-08-18 12:43:07 +0200
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>2024-09-25 16:23:44 +0200
commitd4df54f338e43c790460674a3cc7db35b8395421 (patch)
tree98e1cb8212aced07c1cea62b492673863b696be7 /kernel/tracepoint.c
parenttracepoint: Support iterating over tracepoints on modules (diff)
downloadlinux-d4df54f338e43c790460674a3cc7db35b8395421.tar.xz
linux-d4df54f338e43c790460674a3cc7db35b8395421.zip
tracepoint: Support iterating tracepoints in a loading module
Add for_each_tracepoint_in_module() function to iterate tracepoints in a module. This API is needed for handling tracepoints in a loading module from tracepoint_module_notifier callback function. This also update for_each_module_tracepoint() to pass the module to callback function so that it can find module easily. Link: https://lore.kernel.org/all/172397778740.286558.15781131277732977643.stgit@devnote2/ Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Diffstat (limited to '')
-rw-r--r--kernel/tracepoint.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index bed4aad36d92..8879da16ef4d 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -737,23 +737,44 @@ static __init int init_tracepoints(void)
__initcall(init_tracepoints);
/**
+ * for_each_tracepoint_in_module - iteration on all tracepoints in a module
+ * @mod: module
+ * @fct: callback
+ * @priv: private data
+ */
+void for_each_tracepoint_in_module(struct module *mod,
+ void (*fct)(struct tracepoint *tp,
+ struct module *mod, void *priv),
+ void *priv)
+{
+ tracepoint_ptr_t *begin, *end, *iter;
+
+ lockdep_assert_held(&tracepoint_module_list_mutex);
+
+ if (!mod)
+ return;
+
+ begin = mod->tracepoints_ptrs;
+ end = mod->tracepoints_ptrs + mod->num_tracepoints;
+
+ for (iter = begin; iter < end; iter++)
+ fct(tracepoint_ptr_deref(iter), mod, priv);
+}
+
+/**
* for_each_module_tracepoint - iteration on all tracepoints in all modules
* @fct: callback
* @priv: private data
*/
-void for_each_module_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
+void for_each_module_tracepoint(void (*fct)(struct tracepoint *tp,
+ struct module *mod, void *priv),
void *priv)
{
struct tp_module *tp_mod;
- struct module *mod;
mutex_lock(&tracepoint_module_list_mutex);
- list_for_each_entry(tp_mod, &tracepoint_module_list, list) {
- mod = tp_mod->mod;
- for_each_tracepoint_range(mod->tracepoints_ptrs,
- mod->tracepoints_ptrs + mod->num_tracepoints,
- fct, priv);
- }
+ list_for_each_entry(tp_mod, &tracepoint_module_list, list)
+ for_each_tracepoint_in_module(tp_mod->mod, fct, priv);
mutex_unlock(&tracepoint_module_list_mutex);
}
#endif /* CONFIG_MODULES */