Index: sys/mbuf.h =================================================================== RCS file: /cvs/src/sys/sys/mbuf.h,v retrieving revision 1.253 diff -u -p -r1.253 mbuf.h --- sys/mbuf.h 15 May 2021 08:07:20 -0000 1.253 +++ sys/mbuf.h 12 Feb 2022 07:38:43 -0000 @@ -429,6 +429,7 @@ void m_align(struct mbuf *, int); struct mbuf *m_clget(struct mbuf *, int, u_int); void m_extref(struct mbuf *, struct mbuf *); void m_pool_init(struct pool *, u_int, u_int, const char *); +u_int m_pool_used(void); void m_extfree_pool(caddr_t, u_int, void *); void m_adj(struct mbuf *, int); int m_copyback(struct mbuf *, int, int, const void *, int); Index: kern/uipc_mbuf.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.281 diff -u -p -r1.281 uipc_mbuf.c --- kern/uipc_mbuf.c 8 Feb 2022 11:28:19 -0000 1.281 +++ kern/uipc_mbuf.c 12 Feb 2022 07:38:44 -0000 @@ -1502,6 +1502,12 @@ m_pool_init(struct pool *pp, u_int size, pool_set_constraints(pp, &kp_dma_contig); } +u_int +m_pool_used(void) +{ + return ((mbuf_mem_alloc * 100) / mbuf_mem_limit); +} + #ifdef DDB void m_print(void *v, Index: kern/uipc_socket2.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_socket2.c,v retrieving revision 1.116 diff -u -p -r1.116 uipc_socket2.c --- kern/uipc_socket2.c 6 Nov 2021 05:26:33 -0000 1.116 +++ kern/uipc_socket2.c 12 Feb 2022 07:38:44 -0000 @@ -155,7 +155,7 @@ sonewconn(struct socket *head, int conns */ soassertlocked(head); - if (mclpools[0].pr_nout > mclpools[0].pr_hardlimit * 95 / 100) + if (m_pool_used() > 95) return (NULL); if (head->so_qlen + head->so_q0len > head->so_qlimit * 3) return (NULL); @@ -517,13 +517,13 @@ int sbchecklowmem(void) { static int sblowmem; + unsigned int used = m_pool_used(); - if (mclpools[0].pr_nout < mclpools[0].pr_hardlimit * 60 / 100 || - mbpool.pr_nout < mbpool.pr_hardlimit * 60 / 100) + if (used < 60) sblowmem = 0; - if (mclpools[0].pr_nout > mclpools[0].pr_hardlimit * 80 / 100 || - mbpool.pr_nout > mbpool.pr_hardlimit * 80 / 100) + else if (used > 80) sblowmem = 1; + return (sblowmem); }