lkml.org 
[lkml]   [2006]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] EDAC: core EDAC support code
Al Viro <viro@ftp.linux.org.uk> wrote:
>
> On Mon, Mar 06, 2006 at 01:53:44PM -0800, Greg KH wrote:
> > > rmmod your_turd </sys/spew/from/your_turd
> > > and there you go. rmmod can _NOT_ wait for sysfs references to go away.
> >
> > To be fair, the only part of the kernel that supports the above process,
> > is the network stack. And they implemented a special kind of lock to
> > handle just this kind of thing.
> >
> > That is not something that I want the rest of the kernel to have to use.
> > If your code blocks when doing the above thing, that's fine with me.
>
> One word: fail. With -EBUSY.

It seems quite simple to make wait_for_zero_refcount() interruptible?
Something like...



--- devel/kernel/module.c~modules-make-wait_for_zero_refcount-interruptible 2006-03-07 02:36:46.000000000 -0800
+++ devel-akpm/kernel/module.c 2006-03-07 02:39:18.000000000 -0800
@@ -578,8 +578,8 @@ static void wait_for_zero_refcount(struc
mutex_unlock(&module_mutex);
for (;;) {
DEBUGP("Looking at refcount...\n");
- set_current_state(TASK_UNINTERRUPTIBLE);
- if (module_refcount(mod) == 0)
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (module_refcount(mod) == 0 || signal_pending(current))
break;
schedule();
}
@@ -645,8 +645,18 @@ sys_delete_module(const char __user *nam
goto out;

/* Never wait if forced. */
- if (!forced && module_refcount(mod) != 0)
+ if (!forced && module_refcount(mod) != 0) {
wait_for_zero_refcount(mod);
+ if (module_refcount(mod)) {
+ /*
+ * Signalled: back out
+ */
+ mod->state = MODULE_STATE_LIVE;
+ mod->waiter = NULL;
+ ret = -EINTR;
+ goto out;
+ }
+ }

/* Final destruction now noone is using it. */
if (mod->exit != NULL) {
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-07 11:46    [from the cache]
©2003-2011 Jasper Spaans