-/* $OpenBSD: uipc_mbuf.c,v 1.281 2022/02/08 11:28:19 dlg Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.282 2022/02/14 04:33:18 dlg Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
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,
-/* $OpenBSD: uipc_socket2.c,v 1.116 2021/11/06 05:26:33 visa Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.117 2022/02/14 04:33:18 dlg Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
*/
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);
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);
}
-/* $OpenBSD: mbuf.h,v 1.253 2021/05/15 08:07:20 yasuoka Exp $ */
+/* $OpenBSD: mbuf.h,v 1.254 2022/02/14 04:33:18 dlg Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
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);