From 23621f2ff0b5663756b9fae6a0d85b01d4711fc5 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Fri, 3 Oct 2014 02:16:22 +0000 Subject: if you're adding the first cluster reference, you dont have to coordinate with other mbufs so you can add all the pointers without taking the extref lock. looks good deraadt@ --- sys/kern/uipc_mbuf.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 75a70cfb95c..64d05d8d906 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.196 2014/10/03 01:11:17 dlg Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.197 2014/10/03 02:16:21 dlg Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -344,14 +344,18 @@ m_free(struct mbuf *m) void m_extref(struct mbuf *o, struct mbuf *n) { + int refs = MCLISREFERENCED(o); + n->m_flags |= o->m_flags & (M_EXT|M_EXTWR); - mtx_enter(&m_extref_mtx); + if (refs) + mtx_enter(&m_extref_mtx); n->m_ext.ext_nextref = o->m_ext.ext_nextref; n->m_ext.ext_prevref = o; o->m_ext.ext_nextref = n; n->m_ext.ext_nextref->m_ext.ext_prevref = n; - mtx_leave(&m_extref_mtx); + if (refs) + mtx_leave(&m_extref_mtx); MCLREFDEBUGN((n), __FILE__, __LINE__); } -- cgit v1.2.3