* Spinlocking patch for in xprt.c
@ 2001-01-12 12:45 Trond Myklebust
2001-01-13 23:10 ` David S. Miller
0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2001-01-12 12:45 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Linux Kernel, NFS devel
The following patch (taken from the zero copy networking) upgrades the
spinlocking of the xprt_(up|down)_transmit() 'semaphores' in order to
work safely with the networking bottom halves. Several of the latter
(cf. xprt.c:tcp_write_space() & friends) do want to test the value of
'xprt->snd_task'.
Cheers,
Trond
diff -u --recursive --new-file linux-2.4.1-fh_align/net/sunrpc/xprt.c linux-2.4.1-xprt/net/sunrpc/xprt.c
--- linux-2.4.1-fh_align/net/sunrpc/xprt.c Wed Nov 29 07:34:01 2000
+++ linux-2.4.1-xprt/net/sunrpc/xprt.c Fri Jan 12 11:58:42 2001
@@ -1116,7 +1116,7 @@
struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
struct rpc_rqst *req = task->tk_rqstp;
- spin_lock(&xprt_lock);
+ spin_lock_bh(&xprt_sock_lock);
if (xprt->snd_task && xprt->snd_task != task) {
dprintk("RPC: %4d TCP write queue full (task %d)\n",
task->tk_pid, xprt->snd_task->tk_pid);
@@ -1130,7 +1130,7 @@
#endif
req->rq_bytes_sent = 0;
}
- spin_unlock(&xprt_lock);
+ spin_unlock_bh(&xprt_sock_lock);
return xprt->snd_task == task;
}
@@ -1143,10 +1143,10 @@
struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
if (xprt->snd_task && xprt->snd_task == task) {
- spin_lock(&xprt_lock);
+ spin_lock_bh(&xprt_sock_lock);
xprt->snd_task = NULL;
rpc_wake_up_next(&xprt->sending);
- spin_unlock(&xprt_lock);
+ spin_unlock_bh(&xprt_sock_lock);
}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Spinlocking patch for in xprt.c
2001-01-12 12:45 Spinlocking patch for in xprt.c Trond Myklebust
@ 2001-01-13 23:10 ` David S. Miller
2001-01-14 18:45 ` Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: David S. Miller @ 2001-01-13 23:10 UTC (permalink / raw)
To: trond.myklebust; +Cc: Linus Torvalds, Linux Kernel, NFS devel
Trond, did you actually look at how this code works before
you made modifications to my fixes?
xprt_lock serializes sleep/wakeup sequences in the xprt code, so you
cannot remove xprt_lock from the sections where I added holding of
xprt_sock_lock to protect the state of xprt->snd_task. So for
example, this part of your patch is completely bogus and will create
new corruptions and crashes:
@@ -1143,10 +1143,10 @@
struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
if (xprt->snd_task && xprt->snd_task == task) {
- spin_lock(&xprt_lock);
+ spin_lock_bh(&xprt_sock_lock);
xprt->snd_task = NULL;
rpc_wake_up_next(&xprt->sending);
- spin_unlock(&xprt_lock);
+ spin_unlock_bh(&xprt_sock_lock);
}
}
You _must_ hold both xprt_lock and xprt_sock_lock in this
section of code, not just one or just the other.
Linus, please do not apply this patch until these issues
are addressed.
Later,
David S. Miller
davem@redhat.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Spinlocking patch for in xprt.c
2001-01-13 23:10 ` David S. Miller
@ 2001-01-14 18:45 ` Trond Myklebust
0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2001-01-14 18:45 UTC (permalink / raw)
To: David S. Miller; +Cc: Linus Torvalds, Linux Kernel, NFS devel
>>>>> " " == David S Miller <davem@redhat.com> writes:
> Trond, did you actually look at how this code works before you
> made modifications to my fixes?
> xprt_lock serializes sleep/wakeup sequences in the xprt code,
> so you cannot remove xprt_lock from the sections where I added
> holding of xprt_sock_lock to protect the state of
> xprt->snd_task. So for example, this part of your patch is
> completely bogus and will create new corruptions and crashes:
IIRC xprt_lock is there for 2 purposes:
- serialize access to the TCP connect code
- gate access to the *socket* via the xprt_(up|down)_transmit() (and
hence setting xprt->snd_task which is a pointer to the task that
currently is allowed to access the socket.)
Those 2 tasks are completely orthogonal to one another, so we should
be quite free to drop xprt_lock in the second case.
I can see no other places where we're using xprt_lock to protect a
sleep/wakeup of xprt->snd_task unless you're introducing it? If so for
what purpose?
Cheers,
Trond
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-01-14 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-12 12:45 Spinlocking patch for in xprt.c Trond Myklebust
2001-01-13 23:10 ` David S. Miller
2001-01-14 18:45 ` Trond Myklebust
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®