aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Smith <msmith@FreeBSD.org>1999-12-28 06:35:57 +0000
committerMike Smith <msmith@FreeBSD.org>1999-12-28 06:35:57 +0000
commit736e4b67ae336f0e5dd884ac73f0471b5d758676 (patch)
tree82ca5c3e5ece9c2923753158cc3c9aa77d725cd4
parentecfa9802f0672e4dd96f2b4326f44de333836e50 (diff)
Notes
-rw-r--r--sys/kern/uipc_mbuf.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 8c3c4bfb1dc2..cc38c40e62fe 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -81,12 +81,14 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, mbuf_wait, CTLFLAG_RW,
&mbuf_wait, 0, "");
SYSCTL_STRUCT(_kern_ipc, KIPC_MBSTAT, mbstat, CTLFLAG_RW, &mbstat, mbstat, "");
SYSCTL_INT(_kern_ipc, KIPC_NMBCLUSTERS, nmbclusters, CTLFLAG_RD,
- &nmbclusters, 0, "Maximum number of mbuf clusters avaliable");
+ &nmbclusters, 0, "Maximum number of mbuf clusters available");
+SYSCTL_INT(_kern_ipc, OID_AUTO, nmbufs, CTLFLAG_RD, &nmbufs, 0,
+ "Maximum number of mbufs available");
#ifndef NMBCLUSTERS
#define NMBCLUSTERS (512 + MAXUSERS * 16)
#endif
TUNABLE_INT_DECL("kern.ipc.nmbclusters", NMBCLUSTERS, nmbclusters);
-TUNABLE_INT_DECL("kern.ipc.nmbufs", NMBCLUSTERS * 4, nmbufs); /* XXX fixup? */
+TUNABLE_INT_DECL("kern.ipc.nmbufs", NMBCLUSTERS * 4, nmbufs);
static void m_reclaim __P((void));
@@ -141,6 +143,14 @@ m_mballoc(nmb, how)
int nbytes;
/*
+ * If we've hit the mbuf limit, stop allocating from mb_map,
+ * (or trying to) in order to avoid dipping into the section of
+ * mb_map which we've "reserved" for clusters.
+ */
+ if ((nmb + mbstat.m_mbufs) > nmbufs)
+ return (0);
+
+ /*
* Once we run out of map space, it will be impossible to get
* any more (nothing is ever freed back to the map)
* -- however you are not dead as m_reclaim might
@@ -267,6 +277,16 @@ m_clalloc(ncl, how)
int npg;
/*
+ * If we've hit the mcluster number limit, stop allocating from
+ * mb_map, (or trying to) in order to avoid dipping into the section
+ * of mb_map which we've "reserved" for mbufs.
+ */
+ if ((ncl + mbstat.m_clusters) > nmbclusters) {
+ mbstat.m_drops++;
+ return (0);
+ }
+
+ /*
* Once we run out of map space, it will be impossible
* to get any more (nothing is ever freed back to the
* map). From this point on, we solely rely on freed