mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Rini <trini@kernel.crashing.org>
To: Jan Beulich <JBeulich@novell.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rmmod notifier chain
Date: Thu, 8 Sep 2005 08:33:14 -0700	[thread overview]
Message-ID: <20050908153314.GM3966@smtp.west.cox.net> (raw)
In-Reply-To: <43206EFE0200007800024451@emea1-mh.id2.novell.com>

On Thu, Sep 08, 2005 at 05:03:58PM +0200, Jan Beulich wrote:

> (Note: Patch also attached because the inline version is certain to get
> line wrapped.)
> 
> Debugging and maintenance support code occasionally needs to know not
> only of module insertions, but also modulke removals. This adds a
> notifier
> chain for this purpose.

It's possible to do this a bit differently, if I'm guessing right at
what NLKD does.  The following is from the KGDB patches (trimmed of some
other, unrelated to the notify part code):

diff -puN include/linux/module.h~module include/linux/module.h
--- linux-2.6.13/include/linux/module.h~module	2005-09-01 12:00:49.000000000 -0700
+++ linux-2.6.13-trini/include/linux/module.h	2005-09-01 12:00:49.000000000 -0700
@@ -210,6 +210,7 @@ enum module_state
 	MODULE_STATE_LIVE,
 	MODULE_STATE_COMING,
 	MODULE_STATE_GOING,
+ 	MODULE_STATE_GONE,
 };
 
 /* Similar stuff for section attributes. */
diff -puN kernel/module.c~module kernel/module.c
--- linux-2.6.13/kernel/module.c~module	2005-09-01 12:00:49.000000000 -0700
+++ linux-2.6.13-trini/kernel/module.c	2005-09-01 12:00:49.000000000 -0700
@@ -623,6 +623,12 @@ sys_delete_module(const char __user *nam
 	if (ret != 0)
 		goto out;
 
+	down(&notify_mutex);
+	notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
+        			mod);
+	up(&notify_mutex);
+
+
 	/* Never wait if forced. */
 	if (!forced && module_refcount(mod) != 0)
 		wait_for_zero_refcount(mod);
@@ -635,6 +641,11 @@ sys_delete_module(const char __user *nam
 	}
 	free_module(mod);
 
+	down(&notify_mutex);
+	notifier_call_chain(&module_notify_list, MODULE_STATE_GONE,
+			NULL);
+	up(&notify_mutex);
+
  out:
 	up(&module_mutex);
 	return ret;
@@ -1909,6 +1961,10 @@ sys_init_module(void __user *umod,
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */
 		mod->state = MODULE_STATE_GOING;
+		down(&notify_mutex);
+		notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
+				mod);
+		up(&notify_mutex);
 		synchronize_sched();
 		if (mod->unsafe)
 			printk(KERN_ERR "%s: module is now stuck!\n",
_
-- 
Tom Rini
http://gate.crashing.org/~trini/

  parent reply	other threads:[~2005-09-08 15:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-08 15:03 Jan Beulich
2005-09-08 15:11 ` Patrick McHardy
2005-09-08 15:16   ` Jan Beulich
2005-09-08 15:16 ` Christoph Hellwig
2005-09-08 15:20   ` viro
2005-09-08 15:22   ` Jan Beulich
2005-09-09  1:46     ` Andrew Morton
2005-09-09 12:44       ` Jan Beulich
2005-09-09 13:44         ` Jesper Juhl
2005-09-09 15:37         ` Paul Jackson
2005-09-09 18:27         ` Andrew Morton
2005-09-12  6:49           ` Jan Beulich
2005-09-12  7:10             ` Andrew Morton
2005-09-08 15:33 ` Tom Rini [this message]
2005-09-08 15:48   ` Jan Beulich
2005-09-09  9:42   ` [PATCH] rmmod notifier chain (attempt 2) Jan Beulich

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=20050908153314.GM3966@smtp.west.cox.net \
    --to=trini@kernel.crashing.org \
    --cc=JBeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®