summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2016-09-03 14:17:38 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2016-09-03 14:17:38 +0000
commit5abb3ed8d819d912513fcdc4d1528e2b11422e17 (patch)
tree78ece688a3c555114ecb0ba6054bd377e3bf7b58 /sys/kern
parent051352093b38ade911ed790536e386f414d3d263 (diff)
Limit all mbuf cluster pools to the same memory size. Having limits
by number would allow the large clusters using too much memory. Set size of mclsizes array explicitly to keep it in sync with mclpools. OK claudio@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_mbuf.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index c34f5166338..bc8490f23e3 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.226 2016/06/13 21:24:43 bluhm Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.227 2016/09/03 14:17:37 bluhm Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -105,7 +105,7 @@ struct pool mbpool; /* mbuf pool */
struct pool mtagpool;
/* mbuf cluster pools */
-u_int mclsizes[] = {
+u_int mclsizes[MCLPOOLS] = {
MCLBYTES, /* must be at slot 0 */
4 * 1024,
8 * 1024,
@@ -179,15 +179,16 @@ mbinit(void)
void
nmbclust_update(void)
{
- int i;
+ unsigned int i, n;
+
/*
* Set the hard limit on the mclpools to the number of
* mbuf clusters the kernel is to support. Log the limit
* reached message max once a minute.
*/
for (i = 0; i < nitems(mclsizes); i++) {
- (void)pool_sethardlimit(&mclpools[i], nmbclust,
- mclpool_warnmsg, 60);
+ n = (unsigned long long)nmbclust * MCLBYTES / mclsizes[i];
+ (void)pool_sethardlimit(&mclpools[i], n, mclpool_warnmsg, 60);
/*
* XXX this needs to be reconsidered.
* Setting the high water mark to nmbclust is too high
@@ -195,7 +196,7 @@ nmbclust_update(void)
* allocations in interrupt context don't fail or mclgeti()
* drivers may end up with empty rings.
*/
- pool_sethiwat(&mclpools[i], nmbclust);
+ pool_sethiwat(&mclpools[i], n);
}
pool_sethiwat(&mbpool, nmbclust);
}