[patch 13/16] Tracepoints : use modules notifiers

Mathieu Desnoyers
2008-11-14T23:01:45Z

[-- Attachment #1: tracepoints-use-modules-notifiers.patch --]
[-- Type: text/plain, Size: 2226 bytes --]

Use module notifiers for tracepoint updates rather than adding a hook in
module.c.

Impact: cleanup.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: 'Ingo Molnar' <mingo@elte.hu>
CC: Lai Jiangshan <laijs@cn.fujitsu.com>
---
kernel/module.c | 5 -----
kernel/tracepoint.c | 29 +++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 5 deletions(-)

Index: linux.trees.git/kernel/tracepoint.c
===================================================================
--- linux.trees.git.orig/kernel/tracepoint.c 2008-11-14 17:39:56.000000000 -0500
+++ linux.trees.git/kernel/tracepoint.c 2008-11-14 17:40:39.000000000 -0500
@@ -541,3 +541,32 @@ void tracepoint_iter_reset(struct tracep
iter->tracepoint = NULL;
}
EXPORT_SYMBOL_GPL(tracepoint_iter_reset);
+
+int tracepoint_module_notify(struct notifier_block *self,
+ unsigned long val, void *data)
+{
+ struct module *mod = data;
+
+ switch (val) {
+ case MODULE_STATE_COMING:
+ tracepoint_update_probe_range(mod->tracepoints,
+ mod->tracepoints + mod->num_tracepoints);
+ break;
+ case MODULE_STATE_GOING:
+ tracepoint_update_probe_range(mod->tracepoints,
+ mod->tracepoints + mod->num_tracepoints);
+ break;
+ }
+ return 0;
+}
+
+struct notifier_block tracepoint_module_nb = {
+ .notifier_call = tracepoint_module_notify,
+ .priority = 0,
+};
+
+static int init_tracepoints(void)
+{
+ return register_module_notifier(&tracepoint_module_nb);
+}
+__initcall(init_tracepoints);
Index: linux.trees.git/kernel/module.c
===================================================================
--- linux.trees.git.orig/kernel/module.c 2008-11-14 17:39:28.000000000 -0500
+++ linux.trees.git/kernel/module.c 2008-11-14 17:40:39.000000000 -0500
@@ -2188,11 +2188,6 @@ static noinline struct module *load_modu
debug = section_objs(hdr, sechdrs, secstrings, "__verbose",
sizeof(*debug), &num_debug);
dynamic_printk_setup(debug, num_debug);
-
-#ifdef CONFIG_TRACEPOINTS
- tracepoint_update_probe_range(mod->tracepoints,
- mod->tracepoints + mod->num_tracepoints);
-#endif
}

/* sechdrs[0].sh_size is always zero */