Skip to content

Commit d5dbf8b

Browse files
committed
tracepoint: Support iterating over tracepoints on modules
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) <[email protected]>
1 parent ce4db75 commit d5dbf8b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/linux/tracepoint.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct tp_module {
6464
bool trace_module_has_bad_taint(struct module *mod);
6565
extern int register_tracepoint_module_notifier(struct notifier_block *nb);
6666
extern int unregister_tracepoint_module_notifier(struct notifier_block *nb);
67+
void for_each_module_tracepoint(void (*fct)(struct tracepoint *, void *),
68+
void *priv);
6769
#else
6870
static inline bool trace_module_has_bad_taint(struct module *mod)
6971
{
@@ -79,6 +81,11 @@ int unregister_tracepoint_module_notifier(struct notifier_block *nb)
7981
{
8082
return 0;
8183
}
84+
static inline
85+
void for_each_module_tracepoint(void (*fct)(struct tracepoint *, void *),
86+
void *priv)
87+
{
88+
}
8289
#endif /* CONFIG_MODULES */
8390

8491
/*

kernel/tracepoint.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,27 @@ static __init int init_tracepoints(void)
735735
return ret;
736736
}
737737
__initcall(init_tracepoints);
738+
739+
/**
740+
* for_each_module_tracepoint - iteration on all tracepoints in all modules
741+
* @fct: callback
742+
* @priv: private data
743+
*/
744+
void for_each_module_tracepoint(void (*fct)(struct tracepoint *tp, void *priv),
745+
void *priv)
746+
{
747+
struct tp_module *tp_mod;
748+
struct module *mod;
749+
750+
mutex_lock(&tracepoint_module_list_mutex);
751+
list_for_each_entry(tp_mod, &tracepoint_module_list, list) {
752+
mod = tp_mod->mod;
753+
for_each_tracepoint_range(mod->tracepoints_ptrs,
754+
mod->tracepoints_ptrs + mod->num_tracepoints,
755+
fct, priv);
756+
}
757+
mutex_unlock(&tracepoint_module_list_mutex);
758+
}
738759
#endif /* CONFIG_MODULES */
739760

740761
/**

0 commit comments

Comments
 (0)