Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Aug 2013 23:36:33 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r254342 - in user/np/cxl_tuning/sys: kern sys
Message-ID:  <201308142336.r7ENaXMc022306@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Wed Aug 14 23:36:33 2013
New Revision: 254342
URL: http://svnweb.freebsd.org/changeset/base/254342

Log:
  Perform lazy initialization of a cluster's refcount if possible.  This
  doesn't change anything for the common cases where the constructor is
  given an mbuf to attach to the cluster, or when the cluster is obtained
  with m_cljget(NULL, ...) and attached later with m_cljset().  But it
  allows for an alternate usage scenario where the cluster is managed
  EXT_EXTREF style without ever having to look up its "usual" refcount via
  uma_find_refcnt.

Modified:
  user/np/cxl_tuning/sys/kern/kern_mbuf.c
  user/np/cxl_tuning/sys/sys/mbuf.h

Modified: user/np/cxl_tuning/sys/kern/kern_mbuf.c
==============================================================================
--- user/np/cxl_tuning/sys/kern/kern_mbuf.c	Wed Aug 14 22:55:05 2013	(r254341)
+++ user/np/cxl_tuning/sys/kern/kern_mbuf.c	Wed Aug 14 23:36:33 2013	(r254342)
@@ -527,8 +527,6 @@ mb_dtor_pack(void *mem, int size, void *
 static int
 mb_ctor_clust(void *mem, int size, void *arg, int how)
 {
-	struct mbuf *m;
-	u_int *refcnt;
 	int type;
 	uma_zone_t zone;
 
@@ -559,10 +557,11 @@ mb_ctor_clust(void *mem, int size, void 
 		break;
 	}
 
-	m = (struct mbuf *)arg;
-	refcnt = uma_find_refcnt(zone, mem);
-	*refcnt = 1;
-	if (m != NULL) {
+	if (arg != NULL) {
+		struct mbuf *m = arg;
+		u_int *refcnt = uma_find_refcnt(zone, mem);
+
+		*refcnt = 1;
 		m->m_ext.ext_buf = (caddr_t)mem;
 		m->m_data = m->m_ext.ext_buf;
 		m->m_flags |= M_EXT;
@@ -572,6 +571,10 @@ mb_ctor_clust(void *mem, int size, void 
 		m->m_ext.ext_size = size;
 		m->m_ext.ext_type = type;
 		m->m_ext.ref_cnt = refcnt;
+	} else {
+#ifdef INVARIANTS
+		*uma_find_refcnt(zone, mem) = 0;
+#endif
 	}
 
 	return (0);

Modified: user/np/cxl_tuning/sys/sys/mbuf.h
==============================================================================
--- user/np/cxl_tuning/sys/sys/mbuf.h	Wed Aug 14 22:55:05 2013	(r254341)
+++ user/np/cxl_tuning/sys/sys/mbuf.h	Wed Aug 14 23:36:33 2013	(r254342)
@@ -594,6 +594,7 @@ m_cljset(struct mbuf *m, void *cl, int t
 	m->m_ext.ext_size = size;
 	m->m_ext.ext_type = type;
 	m->m_ext.ref_cnt = uma_find_refcnt(zone, cl);
+	*m->m_ext.ref_cnt = 1;
 	m->m_flags |= M_EXT;
 
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308142336.r7ENaXMc022306>