From owner-svn-src-head@freebsd.org Wed Nov 25 21:41:24 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 74FF8474FC1; Wed, 25 Nov 2020 21:41:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChDq82xxNz4WtL; Wed, 25 Nov 2020 21:41:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 586B718155; Wed, 25 Nov 2020 21:41:24 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0APLfO0n072859; Wed, 25 Nov 2020 21:41:24 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0APLfO8H072858; Wed, 25 Nov 2020 21:41:24 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202011252141.0APLfO8H072858@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Wed, 25 Nov 2020 21:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368038 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 368038 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 21:41:24 -0000 Author: mjg Date: Wed Nov 25 21:41:23 2020 New Revision: 368038 URL: https://svnweb.freebsd.org/changeset/base/368038 Log: pipe: drop spurious pipeunlock/pipelock cycle on write Modified: head/sys/kern/sys_pipe.c Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Wed Nov 25 21:25:17 2020 (r368037) +++ head/sys/kern/sys_pipe.c Wed Nov 25 21:41:23 2020 (r368038) @@ -979,12 +979,8 @@ pipe_direct_write(struct pipe *wpipe, struct uio *uio) retry: PIPE_LOCK_ASSERT(wpipe, MA_OWNED); - error = pipelock(wpipe, 1); - if (error != 0) - goto error1; if ((wpipe->pipe_state & PIPE_EOF) != 0) { error = EPIPE; - pipeunlock(wpipe); goto error1; } if (wpipe->pipe_state & PIPE_DIRECTW) { @@ -997,10 +993,9 @@ retry: pipeunlock(wpipe); error = msleep(wpipe, PIPE_MTX(wpipe), PRIBIO | PCATCH, "pipdww", 0); + pipelock(wpipe, 0); if (error) goto error1; - else - goto retry; } if (wpipe->pipe_buffer.cnt > 0) { if (wpipe->pipe_state & PIPE_WANTR) { @@ -1012,6 +1007,7 @@ retry: pipeunlock(wpipe); error = msleep(wpipe, PIPE_MTX(wpipe), PRIBIO | PCATCH, "pipdwc", 0); + pipelock(wpipe, 0); if (error) goto error1; else @@ -1020,7 +1016,6 @@ retry: error = pipe_build_write_buffer(wpipe, uio); if (error) { - pipeunlock(wpipe); goto error1; } @@ -1050,7 +1045,6 @@ retry: } else { pipe_destroy_write_buffer(wpipe); } - pipeunlock(wpipe); KASSERT((wpipe->pipe_state & PIPE_DIRECTW) == 0, ("pipe %p leaked PIPE_DIRECTW", wpipe)); return (error); @@ -1124,16 +1118,12 @@ pipe_write(struct file *fp, struct uio *uio, struct uc } MPASS(wpipe->pipe_buffer.size != 0); - pipeunlock(wpipe); - orig_resid = uio->uio_resid; while (uio->uio_resid) { int space; - pipelock(wpipe, 0); if (wpipe->pipe_state & PIPE_EOF) { - pipeunlock(wpipe); error = EPIPE; break; } @@ -1151,7 +1141,6 @@ pipe_write(struct file *fp, struct uio *uio, struct uc uio->uio_iov->iov_len >= PIPE_MINDIRECT && wpipe->pipe_buffer.size >= PIPE_MINDIRECT && (fp->f_flag & FNONBLOCK) == 0) { - pipeunlock(wpipe); error = pipe_direct_write(wpipe, uio); if (error) break; @@ -1176,6 +1165,7 @@ pipe_write(struct file *fp, struct uio *uio, struct uc pipeunlock(wpipe); error = msleep(wpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH, "pipbww", 0); + pipelock(wpipe, 0); if (error) break; else @@ -1251,7 +1241,6 @@ pipe_write(struct file *fp, struct uio *uio, struct uc wpipe->pipe_buffer.size, ("Pipe buffer overflow")); } - pipeunlock(wpipe); if (error != 0) break; } else { @@ -1268,7 +1257,6 @@ pipe_write(struct file *fp, struct uio *uio, struct uc */ if (fp->f_flag & FNONBLOCK) { error = EAGAIN; - pipeunlock(wpipe); break; } @@ -1282,12 +1270,13 @@ pipe_write(struct file *fp, struct uio *uio, struct uc pipeunlock(wpipe); error = msleep(wpipe, PIPE_MTX(rpipe), PRIBIO | PCATCH, "pipewr", 0); + pipelock(wpipe, 0); if (error != 0) break; + continue; } } - pipelock(wpipe, 0); --wpipe->pipe_busy; if ((wpipe->pipe_busy == 0) && (wpipe->pipe_state & PIPE_WANT)) {