* [PATCH] remove sleep_on from sunrpc
@ 2004-01-17 18:43 Manfred Spraul
2004-01-18 1:45 ` Peter Osterlund
0 siblings, 1 reply; 2+ messages in thread
From: Manfred Spraul @ 2004-01-17 18:43 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
sunrpc uses sleep_on to wait until the rpciod thread has died. This
could race if rpciod_down is called without lock_kernel. Right now all
calls in the main tree are under lock_kernel, but rpciod is an exported
function and sleep_on should die.
Additionally, I've replaced spin_lock_irqsave() with spin_lock_irq():
rpciod_down sleeps, interrupts are guaranteed to be enabled.
--
Manfred
[-- Attachment #2: patch-sleep_on_sunrpc --]
[-- Type: text/plain, Size: 1100 bytes --]
--- 2.6/net/sunrpc/sched.c 2004-01-17 12:19:50.000000000 +0100
+++ build-2.6/net/sunrpc/sched.c 2004-01-17 12:52:33.000000000 +0100
@@ -1060,7 +1060,7 @@
void
rpciod_down(void)
{
- unsigned long flags;
+ DECLARE_WAITQUEUE(wait, current);
down(&rpciod_sema);
dprintk("rpciod_down pid %d sema %d\n", rpciod_pid, rpciod_users);
@@ -1085,17 +1085,22 @@
/*
* Display a message if we're going to wait longer.
*/
- while (rpciod_pid) {
+ add_wait_queue(&rpciod_killer, &wait);
+ for (;;) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (rpciod_pid == 0)
+ break;
dprintk("rpciod_down: waiting for pid %d to exit\n", rpciod_pid);
if (signalled()) {
dprintk("rpciod_down: caught signal\n");
break;
}
- interruptible_sleep_on(&rpciod_killer);
+ schedule();
}
- spin_lock_irqsave(¤t->sighand->siglock, flags);
+ remove_wait_queue(&rpciod_killer, &wait);
+ spin_lock_irq(¤t->sighand->siglock);
recalc_sigpending();
- spin_unlock_irqrestore(¤t->sighand->siglock, flags);
+ spin_unlock_irq(¤t->sighand->siglock);
out:
up(&rpciod_sema);
}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] remove sleep_on from sunrpc
2004-01-17 18:43 [PATCH] remove sleep_on from sunrpc Manfred Spraul
@ 2004-01-18 1:45 ` Peter Osterlund
0 siblings, 0 replies; 2+ messages in thread
From: Peter Osterlund @ 2004-01-18 1:45 UTC (permalink / raw)
To: Manfred Spraul; +Cc: linux-kernel
Manfred Spraul <manfred@colorfullife.com> writes:
> - while (rpciod_pid) {
> + add_wait_queue(&rpciod_killer, &wait);
> + for (;;) {
> + set_current_state(TASK_INTERRUPTIBLE);
> + if (rpciod_pid == 0)
> + break;
> dprintk("rpciod_down: waiting for pid %d to exit\n", rpciod_pid);
> if (signalled()) {
> dprintk("rpciod_down: caught signal\n");
> break;
> }
> - interruptible_sleep_on(&rpciod_killer);
> + schedule();
> }
> - spin_lock_irqsave(¤t->sighand->siglock, flags);
> + remove_wait_queue(&rpciod_killer, &wait);
> + spin_lock_irq(¤t->sighand->siglock);
> recalc_sigpending();
> - spin_unlock_irqrestore(¤t->sighand->siglock, flags);
> + spin_unlock_irq(¤t->sighand->siglock);
> out:
> up(&rpciod_sema);
> }
Aren't you forgetting to set_current_state(TASK_RUNNING) after the
loop?
--
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-01-18 1:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-17 18:43 [PATCH] remove sleep_on from sunrpc Manfred Spraul
2004-01-18 1:45 ` Peter Osterlund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox