Skip to content

Commit

Permalink
tracepoint: Support iterating over tracepoints on modules
Browse files Browse the repository at this point in the history
Add for_each_module_tracepoint() for iterating over tracepoints
on modules. This is similar to the for_each_kernel_tracepoint()
but only for the tracepoints on modules (not including kernel
built-in tracepoints).

Link: https://lore.kernel.org/all/172397777800.286558.14554748203446214056.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
  • Loading branch information
Masami Hiramatsu (Google) committed Sep 25, 2024
1 parent ce4db75 commit d5dbf8b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/linux/tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct tp_module {
bool trace_module_has_bad_taint(struct module *mod);
extern int register_tracepoint_module_notifier(struct notifier_block *nb);
extern int unregister_tracepoint_module_notifier(struct notifier_block *nb);
void for_each_module_tracepoint(void (*fct)(struct tracepoint *, void *),
void *priv);
#else
static inline bool trace_module_has_bad_taint(struct module *mod)
{
Expand All @@ -79,6 +81,11 @@ int unregister_tracepoint_module_notifier(struct notifier_block *nb)
{
return 0;
}
static inline
void for_each_module_tracepoint(void (*fct)(struct tracepoint *, void *),
void *priv)
{
}
#endif /* CONFIG_MODULES */

/*
Expand Down
21 changes: 21 additions & 0 deletions kernel/tracepoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,27 @@ static __init int init_tracepoints(void)
return ret;
}
__initcall(init_tracepoints);

/**
* 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 *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);
}
mutex_unlock(&tracepoint_module_list_mutex);
}
#endif /* CONFIG_MODULES */

/**
Expand Down

0 comments on commit d5dbf8b

Please sign in to comment.