All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Jan Glauber <jang@linux.vnet.ibm.com>
Cc: Miles Lane <miles.lane@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-usb@vger.kernel.org
Subject: [PATCH 1/2] modules: Fix module waiting for dependent modules' init.
Date: Tue, 4 Mar 2008 23:21:01 +1100	[thread overview]
Message-ID: <200803042321.01683.rusty@rustcorp.com.au> (raw)

Commit c9a3ba55 (module: wait for dependent modules doing init.)
didn't quite work because the waiter holds the module lock, meaning
that the state of the module it's waiting for cannot change.

Fortunately, it's fairly simple to update the state outside the lock
and do the wakeup.

Thanks to Jan Glauber <jang@linux.vnet.ibm.com> for tracking this down
and testing (qdio and qeth).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 kernel/module.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff -r 1198dd206438 kernel/module.c
--- a/kernel/module.c	Tue Mar 04 11:18:59 2008 +1100
+++ b/kernel/module.c	Tue Mar 04 13:23:22 2008 +1100
@@ -2172,9 +2172,11 @@ sys_init_module(void __user *umod,
 		return ret;
 	}
 
-	/* Now it's a first class citizen! */
+	/* Now it's a first class citizen!  Wake up anyone waiting for it. */
+	mod->state = MODULE_STATE_LIVE;
+	wake_up(&module_wq);
+
 	mutex_lock(&module_mutex);
-	mod->state = MODULE_STATE_LIVE;
 	/* Drop initial reference. */
 	module_put(mod);
 	unwind_remove_table(mod->unwind_info, 1);
@@ -2183,7 +2185,6 @@ sys_init_module(void __user *umod,
 	mod->init_size = 0;
 	mod->init_text_size = 0;
 	mutex_unlock(&module_mutex);
-	wake_up(&module_wq);
 
 	return 0;
 }

             reply	other threads:[~2008-03-04 12:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 12:21 Rusty Russell [this message]
2008-03-04 12:22 ` [PATCH 2/2] modules: Whine about suspicious return values from module's ->init() hook Rusty Russell
2008-03-05 23:04   ` Adrian Bunk
2008-03-06  0:32     ` 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=200803042321.01683.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=jang@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=miles.lane@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.