linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Gerd Knorr <kraxel@suse.de>
Cc: Johannes Stezenbach <js@convergence.de>,
	Johannes Stezenbach <js@linuxtv.org>,
	Takashi Iwai <tiwai@suse.de>,
	"Alexander E. Patrakov" <patrakov@ums.usu.ru>,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: modprobe + request_module() deadlock
Date: Wed, 24 Nov 2004 16:02:31 +1100	[thread overview]
Message-ID: <1101272551.6186.25.camel@localhost.localdomain> (raw)
In-Reply-To: <20041122165201.GA2060@bytesex>

On Mon, 2004-11-22 at 17:52 +0100, Gerd Knorr wrote:
> > > I can fix that in the driver, by delaying the request_module() somehow
> > > until the saa7134 module initialization is finished.  I don't think that
> > > this is a good idea through as it looks like I'm not the only one with
> > > that problem ...
> > 
> > Delaying request_module() sounds ugly. Anyway, if you can
> > get it to work reliably...
> 
> I think I can, havn't tried yet through.

I still don't really like it as a solution, but this patch (pending
anyway) should help.

Rusty.

Name: More Module Notifiers
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Status: Trivial

Put in the rest of the module notifiers, esp. one when a module is
being removed.

Index: linux-2.6.10-rc2-bk8-Module/kernel/module.c
===================================================================
--- linux-2.6.10-rc2-bk8-Module.orig/kernel/module.c	2004-11-16 15:30:10.000000000 +1100
+++ linux-2.6.10-rc2-bk8-Module/kernel/module.c	2004-11-24 15:28:10.745436776 +1100
@@ -82,6 +82,13 @@
 }
 EXPORT_SYMBOL(unregister_module_notifier);
 
+static void module_notify(struct module *mod, enum module_state state)
+{
+	down(&notify_mutex);
+	notifier_call_chain(&module_notify_list, state, mod);
+	up(&notify_mutex);
+}
+
 /* We require a truly strong try_module_get() */
 static inline int strong_try_module_get(struct module *mod)
 {
@@ -579,6 +586,8 @@
 	if (ret != 0)
 		goto out;
 
+	module_notify(mod, MODULE_STATE_GOING);
+
 	/* Never wait if forced. */
 	if (!forced && module_refcount(mod) != 0)
 		wait_for_zero_refcount(mod);
@@ -589,6 +598,7 @@
 		mod->exit();
 		down(&module_mutex);
 	}
+	module_notify(mod, MODULE_STATE_GONE);
 	free_module(mod);
 
  out:
@@ -1792,9 +1802,7 @@
 	/* Drop lock so they can recurse */
 	up(&module_mutex);
 
-	down(&notify_mutex);
-	notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
-	up(&notify_mutex);
+	module_notify(mod, MODULE_STATE_COMING);
 
 	/* Start the module */
 	if (mod->init != NULL)
@@ -1803,12 +1811,14 @@
 		/* Init routine failed: abort.  Try to protect us from
                    buggy refcounters. */
 		mod->state = MODULE_STATE_GOING;
+		module_notify(mod, MODULE_STATE_GOING);
 		synchronize_kernel();
 		if (mod->unsafe)
 			printk(KERN_ERR "%s: module is now stuck!\n",
 			       mod->name);
 		else {
 			module_put(mod);
+			module_notify(mod, MODULE_STATE_GONE);
 			down(&module_mutex);
 			free_module(mod);
 			up(&module_mutex);
@@ -1826,6 +1836,7 @@
 	mod->init_size = 0;
 	mod->init_text_size = 0;
 	up(&module_mutex);
+	module_notify(mod, MODULE_STATE_LIVE);
 
 	return 0;
 }
Index: linux-2.6.10-rc2-bk8-Module/include/linux/module.h
===================================================================
--- linux-2.6.10-rc2-bk8-Module.orig/include/linux/module.h	2004-11-16 15:30:07.000000000 +1100
+++ linux-2.6.10-rc2-bk8-Module/include/linux/module.h	2004-11-24 15:28:10.767433432 +1100
@@ -220,6 +220,7 @@
 	MODULE_STATE_LIVE,
 	MODULE_STATE_COMING,
 	MODULE_STATE_GOING,
+	MODULE_STATE_GONE, /* Only for notifier: module about to be freed */
 };
 
 /* Similar stuff for section attributes. */

-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman


  reply	other threads:[~2004-11-24  5:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-17 22:29 modprobe + request_module() deadlock Johannes Stezenbach
2004-11-18  3:48 ` Rusty Russell
2004-11-18 13:55   ` Johannes Stezenbach
2004-11-18 19:05     ` Takashi Iwai
2004-11-19  4:04       ` Alexander E. Patrakov
2004-11-19 11:10         ` Takashi Iwai
2004-11-19 11:50           ` Gerd Knorr
2004-11-19 12:42             ` Alexander E. Patrakov
2004-11-21  8:39             ` Rusty Russell
2004-11-22 10:25               ` Gerd Knorr
2004-11-22 14:16                 ` Johannes Stezenbach
2004-11-22 14:44                   ` Gerd Knorr
2004-11-22 15:36                     ` Johannes Stezenbach
2004-11-22 16:52                       ` Gerd Knorr
2004-11-24  5:02                         ` Rusty Russell [this message]
2004-11-24 12:11                           ` Gerd Knorr
2004-11-25 16:03                           ` Gerd Knorr
2004-11-26  0:34                             ` 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=1101272551.6186.25.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=js@convergence.de \
    --cc=js@linuxtv.org \
    --cc=kraxel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patrakov@ums.usu.ru \
    --cc=tiwai@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).