* [PATCH][RFC] use completions instead of sleep_on for rpciod
@ 2004-02-06 10:55 Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2004-02-06 10:55 UTC (permalink / raw)
To: nfs
The rpciod shutdown code gives ugly sleep_on without BKL warnings in
-mm. And it looks indeed somewhat racy.
The easy fix would be to simply use a completion as in the patch below,
but that removes all the signal fuzzing semantics the current code has.
I don't really understand why we want to cancel the operation by
signals, but I think it'd be better to leave that to people familar with
the code anyway..
--- 1.27/net/sunrpc/sched.c Fri Jun 20 22:16:26 2003
+++ edited/net/sunrpc/sched.c Wed Feb 4 06:29:02 2004
@@ -71,7 +71,7 @@
* rpciod-related stuff
*/
static DECLARE_WAIT_QUEUE_HEAD(rpciod_idle);
-static DECLARE_WAIT_QUEUE_HEAD(rpciod_killer);
+static DECLARE_COMPLETION(rpciod_killer);
static DECLARE_MUTEX(rpciod_sema);
static unsigned int rpciod_users;
static pid_t rpciod_pid;
@@ -950,7 +950,6 @@
static int
rpciod(void *ptr)
{
- wait_queue_head_t *assassin = (wait_queue_head_t*) ptr;
int rounds = 0;
lock_kernel();
@@ -992,11 +991,11 @@
rpciod_killall();
}
- rpciod_pid = 0;
- wake_up(assassin);
-
dprintk("RPC: rpciod exiting\n");
unlock_kernel();
+
+ rpciod_pid = 0;
+ complete_and_exit(&rpciod_killer, 0);
return 0;
}
@@ -1041,7 +1040,7 @@
/*
* Create the rpciod thread and wait for it to start.
*/
- error = kernel_thread(rpciod, &rpciod_killer, 0);
+ error = kernel_thread(rpciod, NULL, 0);
if (error < 0) {
printk(KERN_WARNING "rpciod_up: create thread failed, error=%d\n", error);
rpciod_users--;
@@ -1057,8 +1056,6 @@
void
rpciod_down(void)
{
- unsigned long flags;
-
down(&rpciod_sema);
dprintk("rpciod_down pid %d sema %d\n", rpciod_pid, rpciod_users);
if (rpciod_users) {
@@ -1073,27 +1070,8 @@
}
kill_proc(rpciod_pid, SIGKILL, 1);
- /*
- * Usually rpciod will exit very quickly, so we
- * wait briefly before checking the process id.
- */
- clear_thread_flag(TIF_SIGPENDING);
- yield();
- /*
- * Display a message if we're going to wait longer.
- */
- while (rpciod_pid) {
- 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);
- }
- spin_lock_irqsave(¤t->sighand->siglock, flags);
- recalc_sigpending();
- spin_unlock_irqrestore(¤t->sighand->siglock, flags);
-out:
+ wait_for_completion(&rpciod_killer);
+ out:
up(&rpciod_sema);
}
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH][RFC] use completions instead of sleep_on for rpciod
@ 2004-02-07 14:44 Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2004-02-07 14:44 UTC (permalink / raw)
To: netdev
[let's hope some sunrpc folks are on this list, too, the nfs list
mentioned in MAINTAINERS refuses postings from non-subsribers..]
The rpciod shutdown code gives ugly sleep_on without BKL warnings in
-mm. And it looks indeed somewhat racy.
The easy fix would be to simply use a completion as in the patch below,
but that removes all the signal fuzzing semantics the current code has.
I don't really understand why we want to cancel the operation by
signals, but I think it'd be better to leave that to people familar with
the code anyway..
--- 1.27/net/sunrpc/sched.c Fri Jun 20 22:16:26 2003
+++ edited/net/sunrpc/sched.c Wed Feb 4 06:29:02 2004
@@ -71,7 +71,7 @@
* rpciod-related stuff
*/
static DECLARE_WAIT_QUEUE_HEAD(rpciod_idle);
-static DECLARE_WAIT_QUEUE_HEAD(rpciod_killer);
+static DECLARE_COMPLETION(rpciod_killer);
static DECLARE_MUTEX(rpciod_sema);
static unsigned int rpciod_users;
static pid_t rpciod_pid;
@@ -950,7 +950,6 @@
static int
rpciod(void *ptr)
{
- wait_queue_head_t *assassin = (wait_queue_head_t*) ptr;
int rounds = 0;
lock_kernel();
@@ -992,11 +991,11 @@
rpciod_killall();
}
- rpciod_pid = 0;
- wake_up(assassin);
-
dprintk("RPC: rpciod exiting\n");
unlock_kernel();
+
+ rpciod_pid = 0;
+ complete_and_exit(&rpciod_killer, 0);
return 0;
}
@@ -1041,7 +1040,7 @@
/*
* Create the rpciod thread and wait for it to start.
*/
- error = kernel_thread(rpciod, &rpciod_killer, 0);
+ error = kernel_thread(rpciod, NULL, 0);
if (error < 0) {
printk(KERN_WARNING "rpciod_up: create thread failed, error=%d\n", error);
rpciod_users--;
@@ -1057,8 +1056,6 @@
void
rpciod_down(void)
{
- unsigned long flags;
-
down(&rpciod_sema);
dprintk("rpciod_down pid %d sema %d\n", rpciod_pid, rpciod_users);
if (rpciod_users) {
@@ -1073,27 +1070,8 @@
}
kill_proc(rpciod_pid, SIGKILL, 1);
- /*
- * Usually rpciod will exit very quickly, so we
- * wait briefly before checking the process id.
- */
- clear_thread_flag(TIF_SIGPENDING);
- yield();
- /*
- * Display a message if we're going to wait longer.
- */
- while (rpciod_pid) {
- 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);
- }
- spin_lock_irqsave(¤t->sighand->siglock, flags);
- recalc_sigpending();
- spin_unlock_irqrestore(¤t->sighand->siglock, flags);
-out:
+ wait_for_completion(&rpciod_killer);
+ out:
up(&rpciod_sema);
}
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH][RFC] use completions instead of sleep_on for rpciod
@ 2004-02-07 14:44 Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2004-02-07 14:44 UTC (permalink / raw)
To: netdev
[let's hope some sunrpc folks are on this list, too, the nfs list
mentioned in MAINTAINERS refuses postings from non-subsribers..]
The rpciod shutdown code gives ugly sleep_on without BKL warnings in
-mm. And it looks indeed somewhat racy.
The easy fix would be to simply use a completion as in the patch below,
but that removes all the signal fuzzing semantics the current code has.
I don't really understand why we want to cancel the operation by
signals, but I think it'd be better to leave that to people familar with
the code anyway..
--- 1.27/net/sunrpc/sched.c Fri Jun 20 22:16:26 2003
+++ edited/net/sunrpc/sched.c Wed Feb 4 06:29:02 2004
@@ -71,7 +71,7 @@
* rpciod-related stuff
*/
static DECLARE_WAIT_QUEUE_HEAD(rpciod_idle);
-static DECLARE_WAIT_QUEUE_HEAD(rpciod_killer);
+static DECLARE_COMPLETION(rpciod_killer);
static DECLARE_MUTEX(rpciod_sema);
static unsigned int rpciod_users;
static pid_t rpciod_pid;
@@ -950,7 +950,6 @@
static int
rpciod(void *ptr)
{
- wait_queue_head_t *assassin = (wait_queue_head_t*) ptr;
int rounds = 0;
lock_kernel();
@@ -992,11 +991,11 @@
rpciod_killall();
}
- rpciod_pid = 0;
- wake_up(assassin);
-
dprintk("RPC: rpciod exiting\n");
unlock_kernel();
+
+ rpciod_pid = 0;
+ complete_and_exit(&rpciod_killer, 0);
return 0;
}
@@ -1041,7 +1040,7 @@
/*
* Create the rpciod thread and wait for it to start.
*/
- error = kernel_thread(rpciod, &rpciod_killer, 0);
+ error = kernel_thread(rpciod, NULL, 0);
if (error < 0) {
printk(KERN_WARNING "rpciod_up: create thread failed, error=%d\n", error);
rpciod_users--;
@@ -1057,8 +1056,6 @@
void
rpciod_down(void)
{
- unsigned long flags;
-
down(&rpciod_sema);
dprintk("rpciod_down pid %d sema %d\n", rpciod_pid, rpciod_users);
if (rpciod_users) {
@@ -1073,27 +1070,8 @@
}
kill_proc(rpciod_pid, SIGKILL, 1);
- /*
- * Usually rpciod will exit very quickly, so we
- * wait briefly before checking the process id.
- */
- clear_thread_flag(TIF_SIGPENDING);
- yield();
- /*
- * Display a message if we're going to wait longer.
- */
- while (rpciod_pid) {
- 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);
- }
- spin_lock_irqsave(¤t->sighand->siglock, flags);
- recalc_sigpending();
- spin_unlock_irqrestore(¤t->sighand->siglock, flags);
-out:
+ wait_for_completion(&rpciod_killer);
+ out:
up(&rpciod_sema);
}
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH][RFC] use completions instead of sleep_on for rpciod
@ 2004-02-07 14:44 Christoph Hellwig
2004-02-08 20:43 ` David S. Miller
2004-02-09 10:28 ` Olaf Kirch
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2004-02-07 14:44 UTC (permalink / raw)
To: netdev
[let's hope some sunrpc folks are on this list, too, the nfs list
mentioned in MAINTAINERS refuses postings from non-subsribers..]
The rpciod shutdown code gives ugly sleep_on without BKL warnings in
-mm. And it looks indeed somewhat racy.
The easy fix would be to simply use a completion as in the patch below,
but that removes all the signal fuzzing semantics the current code has.
I don't really understand why we want to cancel the operation by
signals, but I think it'd be better to leave that to people familar with
the code anyway..
--- 1.27/net/sunrpc/sched.c Fri Jun 20 22:16:26 2003
+++ edited/net/sunrpc/sched.c Wed Feb 4 06:29:02 2004
@@ -71,7 +71,7 @@
* rpciod-related stuff
*/
static DECLARE_WAIT_QUEUE_HEAD(rpciod_idle);
-static DECLARE_WAIT_QUEUE_HEAD(rpciod_killer);
+static DECLARE_COMPLETION(rpciod_killer);
static DECLARE_MUTEX(rpciod_sema);
static unsigned int rpciod_users;
static pid_t rpciod_pid;
@@ -950,7 +950,6 @@
static int
rpciod(void *ptr)
{
- wait_queue_head_t *assassin = (wait_queue_head_t*) ptr;
int rounds = 0;
lock_kernel();
@@ -992,11 +991,11 @@
rpciod_killall();
}
- rpciod_pid = 0;
- wake_up(assassin);
-
dprintk("RPC: rpciod exiting\n");
unlock_kernel();
+
+ rpciod_pid = 0;
+ complete_and_exit(&rpciod_killer, 0);
return 0;
}
@@ -1041,7 +1040,7 @@
/*
* Create the rpciod thread and wait for it to start.
*/
- error = kernel_thread(rpciod, &rpciod_killer, 0);
+ error = kernel_thread(rpciod, NULL, 0);
if (error < 0) {
printk(KERN_WARNING "rpciod_up: create thread failed, error=%d\n", error);
rpciod_users--;
@@ -1057,8 +1056,6 @@
void
rpciod_down(void)
{
- unsigned long flags;
-
down(&rpciod_sema);
dprintk("rpciod_down pid %d sema %d\n", rpciod_pid, rpciod_users);
if (rpciod_users) {
@@ -1073,27 +1070,8 @@
}
kill_proc(rpciod_pid, SIGKILL, 1);
- /*
- * Usually rpciod will exit very quickly, so we
- * wait briefly before checking the process id.
- */
- clear_thread_flag(TIF_SIGPENDING);
- yield();
- /*
- * Display a message if we're going to wait longer.
- */
- while (rpciod_pid) {
- 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);
- }
- spin_lock_irqsave(¤t->sighand->siglock, flags);
- recalc_sigpending();
- spin_unlock_irqrestore(¤t->sighand->siglock, flags);
-out:
+ wait_for_completion(&rpciod_killer);
+ out:
up(&rpciod_sema);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][RFC] use completions instead of sleep_on for rpciod
2004-02-07 14:44 Christoph Hellwig
@ 2004-02-08 20:43 ` David S. Miller
2004-02-09 10:28 ` Olaf Kirch
1 sibling, 0 replies; 6+ messages in thread
From: David S. Miller @ 2004-02-08 20:43 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: netdev
On Sat, 7 Feb 2004 15:44:05 +0100
Christoph Hellwig <hch@lst.de> wrote:
> The rpciod shutdown code gives ugly sleep_on without BKL warnings in
> -mm. And it looks indeed somewhat racy.
>
> The easy fix would be to simply use a completion as in the patch below,
> but that removes all the signal fuzzing semantics the current code has.
> I don't really understand why we want to cancel the operation by
> signals, but I think it'd be better to leave that to people familar with
> the code anyway..
I think your patch is fine, and there are no signal issues (such code looks
merely to be some abberation rather than anything else).
So I've added it to my tree.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][RFC] use completions instead of sleep_on for rpciod
2004-02-07 14:44 Christoph Hellwig
2004-02-08 20:43 ` David S. Miller
@ 2004-02-09 10:28 ` Olaf Kirch
1 sibling, 0 replies; 6+ messages in thread
From: Olaf Kirch @ 2004-02-09 10:28 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: netdev, nfs
On Sat, Feb 07, 2004 at 03:44:05PM +0100, Christoph Hellwig wrote:
> The rpciod shutdown code gives ugly sleep_on without BKL warnings in
> -mm. And it looks indeed somewhat racy.
Yes, this code is indeed one of the areas that breaks when you use
the sunrpc code without the BKL. Another one was the missing spinlock
in xprt_alloc_xid. The code in fs/nfs/unlink.c is probably also racy
without BKL.
So if you remove the sunrpc BKL be prepared for lots and lots
of bug reports :)
Olaf
--
Olaf Kirch | Stop wasting entropy - start using predictable
okir@suse.de | tempfile names today!
---------------+
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
NFS maillist - NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-02-09 10:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-06 10:55 [PATCH][RFC] use completions instead of sleep_on for rpciod Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2004-02-07 14:44 Christoph Hellwig
2004-02-07 14:44 Christoph Hellwig
2004-02-08 20:43 ` David S. Miller
2004-02-09 10:28 ` Olaf Kirch
2004-02-07 14:44 Christoph Hellwig
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.