summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2005-11-05 19:43:55 +0000
committerandre <andre@FreeBSD.org>2005-11-05 19:43:55 +0000
commit07bbeaa7561d8f472f27f07c34bdb81d141cd448 (patch)
treee16b6429310ae66ea56b3c0ac095805aea0d4c1c /sys
parentc5417f9f3340f25c97b883a189476208962e9b7a (diff)
downloadFreeBSD-src-07bbeaa7561d8f472f27f07c34bdb81d141cd448.zip
FreeBSD-src-07bbeaa7561d8f472f27f07c34bdb81d141cd448.tar.gz
Free only those mbuf+clusters back to the packet zone that were allocated
from there. All others get broken up and free'd individually to the mbuf and cluster zones. The packet zone is a secondary zone to the mbuf zone. There is currently a limitation in UMA which prevents decreasing the packet zone stock when the mbuf and cluster zone are drained and all their members are part of packets. When this is fixed this change may be reverted.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_mbuf.c3
-rw-r--r--sys/kern/uipc_mbuf.c4
-rw-r--r--sys/sys/mbuf.h1
3 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index ffb3e80..d61fab3 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -332,7 +332,7 @@ mb_dtor_pack(void *mem, int size, void *arg)
KASSERT(m->m_ext.ext_free == NULL, ("%s: ext_free != NULL", __func__));
KASSERT(m->m_ext.ext_args == NULL, ("%s: ext_args != NULL", __func__));
KASSERT(m->m_ext.ext_size == MCLBYTES, ("%s: ext_size != MCLBYTES", __func__));
- KASSERT(m->m_ext.ext_type == EXT_CLUSTER, ("%s: ext_type != EXT_CLUSTER", __func__));
+ KASSERT(m->m_ext.ext_type == EXT_PACKET, ("%s: ext_type != EXT_CLUSTER", __func__));
KASSERT(*m->m_ext.ref_cnt == 1, ("%s: ref_cnt != 1", __func__));
#ifdef INVARIANTS
trash_dtor(m->m_ext.ext_buf, MCLBYTES, arg);
@@ -417,6 +417,7 @@ mb_zinit_pack(void *mem, int size, int how)
uma_zalloc_arg(zone_clust, m, how);
if (m->m_ext.ext_buf == NULL)
return (ENOMEM);
+ m->m_ext.ext_type = EXT_PACKET; /* Override. */
#ifdef INVARIANTS
trash_init(m->m_ext.ext_buf, MCLBYTES, how);
#endif
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 4e0f2d9..e4b5483 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -217,11 +217,13 @@ mb_free_ext(struct mbuf *m)
if (*(m->m_ext.ref_cnt) == 1 ||
atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 0) {
switch (m->m_ext.ext_type) {
- case EXT_CLUSTER: /* The packet zone is special. */
+ case EXT_PACKET: /* The packet zone is special. */
if (*(m->m_ext.ref_cnt) == 0)
*(m->m_ext.ref_cnt) = 1;
uma_zfree(zone_pack, m);
return; /* Job done. */
+ case EXT_CLUSTER:
+ uma_zfree(zone_clust, m->m_ext.ext_buf);
break;
case EXT_JUMBO9:
uma_zfree(zone_jumbo9, m->m_ext.ext_buf);
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 262a02e..4a28e02 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -187,6 +187,7 @@ struct mbuf {
#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */
#define EXT_JUMBO9 3 /* jumbo cluster 9216 bytes */
#define EXT_JUMBO16 4 /* jumbo cluster 16184 bytes */
+#define EXT_PACKET 5 /* mbuf+cluster from packet zone */
#define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */
#define EXT_MOD_TYPE 200 /* custom module's ext_buf type */
#define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */
OpenPOWER on IntegriCloud