diff options
author | 2017-03-03 09:41:20 +0000 | |
---|---|---|
committer | 2017-03-03 09:41:20 +0000 | |
commit | c93bdfa37b16b2ae363ba9b488f93c710d13a095 (patch) | |
tree | efff4dc45c7dcf1f615929e1c80b13633bafa5a0 | |
parent | Undefined behavior: Variable 'user' was used as parameter and (diff) | |
download | wireguard-openbsd-c93bdfa37b16b2ae363ba9b488f93c710d13a095.tar.xz wireguard-openbsd-c93bdfa37b16b2ae363ba9b488f93c710d13a095.zip |
Prevent a recursion in the socket layer.
Always defere soreceive() to an nfsd(8) process instead of doing it in
the 'softnet' thread. Avoiding this recursion ensure that we do not
introduce a new sleeping point by releasing and grabbing the netlock.
Tested by many, committing now in order to find possible performance
regression.
-rw-r--r-- | sys/kern/uipc_socket.c | 8 | ||||
-rw-r--r-- | sys/nfs/nfs_socket.c | 23 |
2 files changed, 8 insertions, 23 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a12d868e2cd..1affe913afc 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.177 2017/02/14 09:46:21 mpi Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.178 2017/03/03 09:41:20 mpi Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -1529,12 +1529,8 @@ sorwakeup(struct socket *so) return; #endif sowakeup(so, &so->so_rcv); - if (so->so_upcall) { - /* XXXSMP breaks atomicity */ - rw_exit_write(&netlock); + if (so->so_upcall) (*(so->so_upcall))(so, so->so_upcallarg, M_DONTWAIT); - rw_enter_write(&netlock); - } } void diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 4abf85c41cf..c562aae7327 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.113 2017/02/22 11:42:46 mpi Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.114 2017/03/03 09:41:20 mpi Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -1580,27 +1580,16 @@ nfsrv_rcv(struct socket *so, caddr_t arg, int waitflag) if ((slp->ns_flag & SLP_VALID) == 0) return; -#ifdef notdef - /* - * Define this to test for nfsds handling this under heavy load. - */ + + /* Defer soreceive() to an nfsd. */ if (waitflag == M_DONTWAIT) { - slp->ns_flag |= SLP_NEEDQ; goto dorecs; + slp->ns_flag |= SLP_NEEDQ; + goto dorecs; } -#endif + auio.uio_procp = NULL; if (so->so_type == SOCK_STREAM) { /* - * If there are already records on the queue, defer soreceive() - * to an nfsd so that there is feedback to the TCP layer that - * the nfs servers are heavily loaded. - */ - if (slp->ns_rec && waitflag == M_DONTWAIT) { - slp->ns_flag |= SLP_NEEDQ; - goto dorecs; - } - - /* * Do soreceive(). */ auio.uio_resid = 1000000000; |