summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mbuf.c
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2005-02-10 22:23:02 +0000
committerbmilekic <bmilekic@FreeBSD.org>2005-02-10 22:23:02 +0000
commit885ba938474734fbe7b08d698b6f7e24bad20fab (patch)
treeb0573ee40c1a11c878bda633ea681170cf9967bd /sys/kern/kern_mbuf.c
parentad0e8354e0af089db5146f3e11af06e15484c82f (diff)
downloadFreeBSD-src-885ba938474734fbe7b08d698b6f7e24bad20fab.zip
FreeBSD-src-885ba938474734fbe7b08d698b6f7e24bad20fab.tar.gz
Optimize the way reference counting is performed with Mbufs. We
do not need to perform an extra memory fetch in the Packet (Mbuf+Cluster) constructor to initialize the reference counter anymore. The reference counts are located in a separate memory region (in the slab header, because this zone is UMA_ZONE_REFCNT), so the memory fetch resulted very often in a cache miss. Additionally, and perhaps more significantly, optimize the free mbuf+cluster (packet) case, which is very common, to no longer require an atomic operation on free (to verify the reference counter) if the reference on the cluster has never been increased (also very common). Reduces an atomic on mbuf free on average. Original patch submitted by: Gerrit Nagelhout <gnagelhout@sandvine.com>
Diffstat (limited to 'sys/kern/kern_mbuf.c')
-rw-r--r--sys/kern/kern_mbuf.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 0b81b32..382e149 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -262,9 +262,7 @@ mb_ctor_clust(void *mem, int size, void *arg, int how)
m->m_ext.ext_args = NULL;
m->m_ext.ext_size = MCLBYTES;
m->m_ext.ext_type = EXT_CLUSTER;
- m->m_ext.ref_cnt = (u_int *)uma_find_refcnt(zone_clust,
- m->m_ext.ext_buf);
- *(m->m_ext.ref_cnt) = 1;
+ m->m_ext.ref_cnt = NULL; /* Lazy counter assign. */
mbstat.m_mclusts += 1; /* XXX */
return (0);
}
@@ -337,7 +335,7 @@ mb_ctor_pack(void *mem, int size, void *arg, int how)
m->m_ext.ext_args = NULL;
m->m_ext.ext_size = MCLBYTES;
m->m_ext.ext_type = EXT_PACKET;
- *(m->m_ext.ref_cnt) = 1;
+ m->m_ext.ref_cnt = NULL; /* Lazy counter assign. */
if (flags & M_PKTHDR) {
m->m_pkthdr.rcvif = NULL;
OpenPOWER on IntegriCloud