From nobody Fri Sep 20 13:04:33 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X9CK40Pq9z5X8d5; Fri, 20 Sep 2024 13:04:40 +0000 (UTC) (envelope-from tuexen@freebsd.org) Received: from drew.franken.de (mail-n.franken.de [193.175.24.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.franken.de", Issuer "Certum Domain Validation CA SHA2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X9CK339Vhz42yh; Fri, 20 Sep 2024 13:04:39 +0000 (UTC) (envelope-from tuexen@freebsd.org) Authentication-Results: mx1.freebsd.org; none Received: from smtpclient.apple (unknown [IPv6:2a02:8109:1140:c3d:e81b:47f0:fa2e:761b]) (Authenticated sender: micmac) by drew.franken.de (Postfix) with ESMTPSA id 9C149721BE01C; Fri, 20 Sep 2024 15:04:33 +0200 (CEST) Content-Type: text/plain; charset=us-ascii List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3818.100.11.1.3\)) Subject: Re: git: 7672cbef2c1e - main - pipes: reserve configured percentage of buffers zone to superuser From: tuexen@freebsd.org In-Reply-To: <202409200646.48K6ku0O009784@gitrepo.freebsd.org> Date: Fri, 20 Sep 2024 15:04:33 +0200 Cc: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <0A45CDBA-14DF-423E-9A1F-74119AD5C808@freebsd.org> References: <202409200646.48K6ku0O009784@gitrepo.freebsd.org> To: Konstantin Belousov X-Mailer: Apple Mail (2.3818.100.11.1.3) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:680, ipnet:193.174.0.0/15, country:DE] X-Rspamd-Queue-Id: 4X9CK339Vhz42yh X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated After building a kernel including these changes, I see a lot of negative pipecnt for uid =3D 0 Installing world also fails due to pipe problems. Is this related to one of these changes? Any configuration change = needed? Best regards Michael > On 20. Sep 2024, at 08:46, Konstantin Belousov = wrote: >=20 > The branch main has been updated by kib: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D7672cbef2c1e1267e42bb3aad6a6da93= 80f4347f >=20 > commit 7672cbef2c1e1267e42bb3aad6a6da9380f4347f > Author: Konstantin Belousov > AuthorDate: 2024-09-15 06:57:34 +0000 > Commit: Konstantin Belousov > CommitDate: 2024-09-20 06:46:07 +0000 >=20 > pipes: reserve configured percentage of buffers zone to superuser >=20 > Sponsored by: The FreeBSD Foundation > MFC after: 1 week > Differential revision: https://reviews.freebsd.org/D46619 > --- > sys/kern/sys_pipe.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) >=20 > diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c > index 7ee2b5c76da3..68b57708d653 100644 > --- a/sys/kern/sys_pipe.c > +++ b/sys/kern/sys_pipe.c > @@ -103,6 +103,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -206,6 +207,7 @@ static int pipeallocfail; > static int piperesizefail; > static int piperesizeallowed =3D 1; > static long pipe_mindirect =3D PIPE_MINDIRECT; > +static int pipebuf_reserv =3D 2; >=20 > SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | = CTLFLAG_NOFETCH, > &maxpipekva, 0, "Pipe KVA limit"); > @@ -219,6 +221,9 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, piperesizefail, = CTLFLAG_RD, > &piperesizefail, 0, "Pipe resize failures"); > SYSCTL_INT(_kern_ipc, OID_AUTO, piperesizeallowed, CTLFLAG_RW, > &piperesizeallowed, 0, "Pipe resizing allowed"); > +SYSCTL_INT(_kern_ipc, OID_AUTO, pipebuf_reserv, CTLFLAG_RW, > + &pipebuf_reserv, 0, > + "Superuser-reserved percentage of the pipe buffers space"); >=20 > static void pipeinit(void *dummy __unused); > static void pipeclose(struct pipe *cpipe); > @@ -586,8 +591,22 @@ retry: > return (ENOMEM); > } >=20 > - error =3D vm_map_find(pipe_map, NULL, 0, (vm_offset_t *)&buffer, = size, 0, > - VMFS_ANY_SPACE, VM_PROT_RW, VM_PROT_RW, 0); > + vm_map_lock(pipe_map); > + if (priv_check(curthread, PRIV_PIPEBUF) !=3D 0 && > + (vm_map_max(pipe_map) - vm_map_min(pipe_map)) * > + (100 - pipebuf_reserv) / 100 < pipe_map->size + size) { > + vm_map_unlock(pipe_map); > + if (cpipe->pipe_buffer.buffer =3D=3D NULL && > + size > SMALL_PIPE_SIZE) { > + size =3D SMALL_PIPE_SIZE; > + pipefragretry++; > + goto retry; > + } > + return (ENOMEM); > + } > + error =3D vm_map_find_locked(pipe_map, NULL, 0, (vm_offset_t = *)&buffer, > + size, 0, VMFS_ANY_SPACE, VM_PROT_RW, VM_PROT_RW, 0); > + vm_map_unlock(pipe_map); > if (error !=3D KERN_SUCCESS) { > chgpipecnt(cpipe->pipe_pair->pp_owner->cr_ruidinfo, -size, 0); > if (cpipe->pipe_buffer.buffer =3D=3D NULL &&