From: Rusty Russell <rusty@rustcorp.com.au>
To: John Levon <levon@movementarian.org>
Cc: oprofile-list@lists.sf.net, torvalds@transmeta.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] Module load notification take 3
Date: Tue, 25 Mar 2003 17:32:33 +1100 [thread overview]
Message-ID: <20030325063320.843BD2C04C@lists.samba.org> (raw)
In-Reply-To: Your message of "Tue, 25 Mar 2003 02:03:16 -0000." <20030325020316.GA95492@compsoc.man.ac.uk>
In message <20030325020316.GA95492@compsoc.man.ac.uk> you write:
>
> Implement a module load notifier for the benefit of OProfile, tested
> with .66 on UP.
Minor change to make unregister_module_notifier return void.
Either way Linus, don't really mind. Please apply.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: Module Notifier Patch
Author: John Levon
Status: Experimental
D: Adds a notifier for when modules are inserted, for use of oprofile.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17066-linux-2.5.66/include/linux/module.h .17066-linux-2.5.66.updated/include/linux/module.h
--- .17066-linux-2.5.66/include/linux/module.h 2003-03-25 12:17:31.000000000 +1100
+++ .17066-linux-2.5.66.updated/include/linux/module.h 2003-03-25 17:31:06.000000000 +1100
@@ -138,6 +138,7 @@ struct exception_table
const struct exception_table_entry *entry;
};
+struct notifier_block;
#ifdef CONFIG_MODULES
@@ -348,6 +349,9 @@ const char *module_address_lookup(unsign
/* For extable.c to search modules' exception tables. */
const struct exception_table_entry *search_module_extables(unsigned long addr);
+int register_module_notifier(struct notifier_block *nb);
+void unregister_module_notifier(struct notifier_block *nb);
+
#else /* !CONFIG_MODULES... */
#define EXPORT_SYMBOL(sym)
#define EXPORT_SYMBOL_GPL(sym)
@@ -392,6 +396,17 @@ static inline const char *module_address
{
return NULL;
}
+
+static inline int register_module_notifier(struct notifier_block *nb)
+{
+ /* no events will happen anyway, so this can always succeed */
+ return 0;
+}
+
+static inline void unregister_module_notifier(struct notifier_block *nb)
+{
+}
+
#endif /* CONFIG_MODULES */
#ifdef MODULE
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17066-linux-2.5.66/kernel/module.c .17066-linux-2.5.66.updated/kernel/module.c
--- .17066-linux-2.5.66/kernel/module.c 2003-03-18 05:01:52.000000000 +1100
+++ .17066-linux-2.5.66.updated/kernel/module.c 2003-03-25 17:31:06.000000000 +1100
@@ -31,6 +31,7 @@
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/vermagic.h>
+#include <linux/notifier.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
#include <asm/pgalloc.h>
@@ -61,6 +62,27 @@ static LIST_HEAD(modules);
static LIST_HEAD(symbols);
static LIST_HEAD(extables);
+static DECLARE_MUTEX(notify_mutex);
+static struct notifier_block *module_notify_list;
+
+int register_module_notifier(struct notifier_block * nb)
+{
+ int err;
+ down(¬ify_mutex);
+ err = notifier_chain_register(&module_notify_list, nb);
+ up(¬ify_mutex);
+ return err;
+}
+EXPORT_SYMBOL(register_module_notifier);
+
+void unregister_module_notifier(struct notifier_block * nb)
+{
+ down(¬ify_mutex);
+ notifier_chain_unregister(&module_notify_list, nb);
+ up(¬ify_mutex);
+}
+EXPORT_SYMBOL(unregister_module_notifier);
+
/* We require a truly strong try_module_get() */
static inline int strong_try_module_get(struct module *mod)
{
@@ -1368,6 +1390,10 @@ sys_init_module(void *umod,
/* Drop lock so they can recurse */
up(&module_mutex);
+ down(¬ify_mutex);
+ notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
+ up(¬ify_mutex);
+
/* Start the module */
ret = mod->init();
if (ret < 0) {
next prev parent reply other threads:[~2003-03-25 6:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-25 2:03 [PATCH 1/2] Module load notification take 3 John Levon
2003-03-25 2:13 ` [PATCH 2/2] " John Levon
2003-03-25 6:32 ` Rusty Russell [this message]
2003-03-25 11:41 ` [PATCH 1/2] " John Levon
2003-03-27 2:20 ` Rusty Russell
2003-03-27 4:17 ` John Levon
2003-03-27 5:26 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030325063320.843BD2C04C@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=levon@movementarian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oprofile-list@lists.sf.net \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox