Re: eval: Pipe call failed: Cannot allocate memory

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Fri, 20 Sep 2024 19:34:34 UTC
On Sat, Sep 21, 2024 at 04:01:29AM +0900, Yasuhiro Kimura wrote:
> From: Konstantin Belousov <kostikbel@gmail.com>
> Subject: Re: eval: Pipe call failed: Cannot allocate memory
> Date: Fri, 20 Sep 2024 14:37:09 +0300
> 
> > Did the poudriere run itself finished successfully?
> 
> Yes, it finished successfully.
> 
> > Can you show the output from 'sysctl kern.ipc | grep pipe' before and
> > after the poudriere run?
> 
> Before:
> # sysctl kern.ipc | grep pipe                                                                ~
> kern.ipc.pipe_mindirect: 8192
> kern.ipc.pipebuf_reserv: 2
> kern.ipc.piperesizeallowed: 1
> kern.ipc.piperesizefail: 0
> kern.ipc.pipeallocfail: 0
> kern.ipc.pipefragretry: 0
> kern.ipc.pipekva: 778240
> kern.ipc.maxpipekva: 535846912
> 
> After:
> # sysctl kern.ipc | grep pipe                                                                ~
> kern.ipc.pipe_mindirect: 8192
> kern.ipc.pipebuf_reserv: 2
> kern.ipc.piperesizeallowed: 1
> kern.ipc.piperesizefail: 0
> kern.ipc.pipeallocfail: 0
> kern.ipc.pipefragretry: 0
> kern.ipc.pipekva: 778240
> kern.ipc.maxpipekva: 535846912

Thanks.  Can you please try the following on top of the latest kernel
(there were 40769168a5ee227b96ea917 and d6074f73af5c813524022cf6)

diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index d1a1d3ea3811..58723289af21 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -1510,6 +1510,18 @@ uifree(struct uidinfo *uip)
 	if (uip->ui_vmsize != 0)
 		printf("freeing uidinfo: uid = %d, swapuse = %lld\n",
 		    uip->ui_uid, (unsigned long long)uip->ui_vmsize);
+	if (uip->ui_ptscnt != 0)
+		printf("freeing uidinfo: uid = %d, ptscnt = %ld\n",
+		    uip->ui_uid, uip->ui_ptscnt);
+	if (uip->ui_kqcnt != 0)
+		printf("freeing uidinfo: uid = %d, kqcnt = %ld\n",
+		    uip->ui_uid, uip->ui_kqcnt);
+	if (uip->ui_umtxcnt != 0)
+		printf("freeing uidinfo: uid = %d, umtxcnt = %ld\n",
+		    uip->ui_uid, uip->ui_umtxcnt);
+	if (uip->ui_pipecnt != 0)
+		printf("freeing uidinfo: uid = %d, pipecnt = %ld\n",
+		    uip->ui_uid, uip->ui_pipecnt);
 	free(uip, M_UIDINFO);
 }
 
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 2b81d08f7077..83d6f6cf48cf 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -581,7 +581,7 @@ pipespace_new(struct pipe *cpipe, int size)
 	size = round_page(size);
 	buffer = (caddr_t) vm_map_min(pipe_map);
 
-	if (!chgpipecnt(cpipe->pipe_pair->pp_owner->cr_ruidinfo,
+	if (!chgpipecnt(cpipe->pipe_pair->pp_owner->cr_uidinfo,
 	    size, lim_cur(curthread, RLIMIT_PIPEBUF))) {
 		if (cpipe->pipe_buffer.buffer == NULL &&
 		    size > SMALL_PIPE_SIZE) {
@@ -595,7 +595,7 @@ pipespace_new(struct pipe *cpipe, int size)
 	if (priv_check(curthread, PRIV_PIPEBUF) != 0 && maxpipekva / 100 *
 	    (100 - pipebuf_reserv) < amountpipekva + size) {
 		vm_map_unlock(pipe_map);
-		chgpipecnt(cpipe->pipe_pair->pp_owner->cr_ruidinfo, -size, 0);
+		chgpipecnt(cpipe->pipe_pair->pp_owner->cr_uidinfo, -size, 0);
 		if (cpipe->pipe_buffer.buffer == NULL &&
 		    size > SMALL_PIPE_SIZE) {
 			size = SMALL_PIPE_SIZE;
@@ -608,7 +608,7 @@ pipespace_new(struct pipe *cpipe, int size)
 	    size, 0, VMFS_ANY_SPACE, VM_PROT_RW, VM_PROT_RW, 0);
 	vm_map_unlock(pipe_map);
 	if (error != KERN_SUCCESS) {
-		chgpipecnt(cpipe->pipe_pair->pp_owner->cr_ruidinfo, -size, 0);
+		chgpipecnt(cpipe->pipe_pair->pp_owner->cr_uidinfo, -size, 0);
 		if (cpipe->pipe_buffer.buffer == NULL &&
 		    size > SMALL_PIPE_SIZE) {
 			size = SMALL_PIPE_SIZE;