markers: use module notifier
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 14 Nov 2008 22:47:38 +0000 (17:47 -0500)
committerIngo Molnar <mingo@elte.hu>
Sun, 16 Nov 2008 08:01:28 +0000 (09:01 +0100)
Impact: cleanup

Use module notifiers instead of adding a hook in module.c.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/marker.c
kernel/module.c

index 22cd7bae63e05e307e09282ebcfaa65ab65fe885..348e70cc355abcdbf1d684bf55f12f9537bf711d 100644 (file)
@@ -846,3 +846,32 @@ void *marker_get_private_data(const char *name, marker_probe_func *probe,
        return ERR_PTR(-ENOENT);
 }
 EXPORT_SYMBOL_GPL(marker_get_private_data);
+
+int marker_module_notify(struct notifier_block *self,
+                        unsigned long val, void *data)
+{
+       struct module *mod = data;
+
+       switch (val) {
+       case MODULE_STATE_COMING:
+               marker_update_probe_range(mod->markers,
+                       mod->markers + mod->num_markers);
+               break;
+       case MODULE_STATE_GOING:
+               marker_update_probe_range(mod->markers,
+                       mod->markers + mod->num_markers);
+               break;
+       }
+       return 0;
+}
+
+struct notifier_block marker_module_nb = {
+       .notifier_call = marker_module_notify,
+       .priority = 0,
+};
+
+static int init_markers(void)
+{
+       return register_module_notifier(&marker_module_nb);
+}
+__initcall(init_markers);
index 1f4cc00e0c200b7c69272694d121558fd6a10d06..72c6ca5742113f5ac38527032a2469ff3d82aa0d 100644 (file)
@@ -2184,10 +2184,6 @@ static noinline struct module *load_module(void __user *umod,
                struct mod_debug *debug;
                unsigned int num_debug;
 
-#ifdef CONFIG_MARKERS
-               marker_update_probe_range(mod->markers,
-                       mod->markers + mod->num_markers);
-#endif
                debug = section_objs(hdr, sechdrs, secstrings, "__verbose",
                                     sizeof(*debug), &num_debug);
                dynamic_printk_setup(debug, num_debug);