From owner-dev-commits-src-all@freebsd.org Sat Apr 24 19:05:07 2021 Return-Path: Delivered-To: dev-commits-src-all@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 2B7CB627312; Sat, 24 Apr 2021 19:05:07 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FSLFb0hQ8z3hfx; Sat, 24 Apr 2021 19:05:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0646125A6E; Sat, 24 Apr 2021 19:05:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13OJ56xO048259; Sat, 24 Apr 2021 19:05:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13OJ56Pi048258; Sat, 24 Apr 2021 19:05:06 GMT (envelope-from git) Date: Sat, 24 Apr 2021 19:05:06 GMT Message-Id: <202104241905.13OJ56Pi048258@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Watson Subject: git: af14713d49fd - main - Support run-time configuration of the PIPE_MINDIRECT threshold. PIPE_MINDIRECT determines at what (blocking) write size one-copy optimizations are applied in pipe(2) I/O. That threshold hasn't been tuned since the 1990s when this code was originally committed, and allowing run-time reconfiguration will make it easier to assess whether contemporary microarchitectures would prefer a different threshold. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rwatson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: af14713d49fdb30c84969588f6e5cb66d65dc4c4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Apr 2021 19:05:07 -0000 The branch main has been updated by rwatson: URL: https://cgit.FreeBSD.org/src/commit/?id=af14713d49fdb30c84969588f6e5cb66d65dc4c4 commit af14713d49fdb30c84969588f6e5cb66d65dc4c4 Author: Robert Watson AuthorDate: 2021-01-02 16:42:28 +0000 Commit: Robert Watson CommitDate: 2021-04-24 19:04:28 +0000 Support run-time configuration of the PIPE_MINDIRECT threshold. PIPE_MINDIRECT determines at what (blocking) write size one-copy optimizations are applied in pipe(2) I/O. That threshold hasn't been tuned since the 1990s when this code was originally committed, and allowing run-time reconfiguration will make it easier to assess whether contemporary microarchitectures would prefer a different threshold. (On our local RPi4 baords, the 8k default would ideally be at least 32k, but it's not clear how generalizable that observation is.) MFC after: 3 weeks Reviewers: jrtc27, arichardson Differential Revision: https://reviews.freebsd.org/D29819 --- sys/kern/sys_pipe.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 558337794950..fee9d95e179c 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -209,6 +209,7 @@ static int pipefragretry; static int pipeallocfail; static int piperesizefail; static int piperesizeallowed = 1; +static long pipe_mindirect = PIPE_MINDIRECT; SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxpipekva, 0, "Pipe KVA limit"); @@ -263,6 +264,29 @@ pipeinit(void *dummy __unused) KASSERT(pipedev_ino > 0, ("pipe dev inode not initialized")); } +static int +sysctl_handle_pipe_mindirect(SYSCTL_HANDLER_ARGS) +{ + int error = 0; + long tmp_pipe_mindirect = pipe_mindirect; + + error = sysctl_handle_long(oidp, &tmp_pipe_mindirect, arg2, req); + if (error != 0 || req->newptr == NULL) + return (error); + + /* + * Don't allow pipe_mindirect to be set so low that we violate + * atomicity requirements. + */ + if (tmp_pipe_mindirect <= PIPE_BUF) + return (EINVAL); + pipe_mindirect = tmp_pipe_mindirect; + return (0); +} +SYSCTL_OID(_kern_ipc, OID_AUTO, pipe_mindirect, CTLTYPE_LONG | CTLFLAG_RW, + &pipe_mindirect, 0, sysctl_handle_pipe_mindirect, "L", + "Minimum write size triggering VM optimization"); + static int pipe_zone_ctor(void *mem, int size, void *arg, int flags) { @@ -1140,8 +1164,8 @@ pipe_write(struct file *fp, struct uio *uio, struct ucred *active_cred, * away on us. */ if (uio->uio_segflg == UIO_USERSPACE && - uio->uio_iov->iov_len >= PIPE_MINDIRECT && - wpipe->pipe_buffer.size >= PIPE_MINDIRECT && + uio->uio_iov->iov_len >= pipe_mindirect && + wpipe->pipe_buffer.size >= pipe_mindirect && (fp->f_flag & FNONBLOCK) == 0) { error = pipe_direct_write(wpipe, uio); if (error != 0)