Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
src: Put the "free" functions close to one another. No functiona...
details: https://anonhg.NetBSD.org/src/rev/db4a757689f2
branches: trunk
changeset: 318027:db4a757689f2
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Apr 10 15:29:46 2018 +0000
description:
Put the "free" functions close to one another. No functional change.
diffstat:
sys/kern/uipc_mbuf.c | 142 +++++++++++++++++++++++++-------------------------
1 files changed, 71 insertions(+), 71 deletions(-)
diffs (170 lines):
diff -r 2def819395ad -r db4a757689f2 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c Tue Apr 10 15:27:35 2018 +0000
+++ b/sys/kern/uipc_mbuf.c Tue Apr 10 15:29:46 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_mbuf.c,v 1.185 2018/04/10 15:27:35 maxv Exp $ */
+/* $NetBSD: uipc_mbuf.c,v 1.186 2018/04/10 15:29:46 maxv Exp $ */
/*
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.185 2018/04/10 15:27:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.186 2018/04/10 15:29:46 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_mbuftrace.h"
@@ -1716,75 +1716,6 @@
return NULL;
}
-/*
- * Release a reference to the mbuf external storage.
- *
- * => free the mbuf m itself as well.
- */
-static void
-m_ext_free(struct mbuf *m)
-{
- const bool embedded = MEXT_ISEMBEDDED(m);
- bool dofree = true;
- u_int refcnt;
-
- KASSERT((m->m_flags & M_EXT) != 0);
- KASSERT(MEXT_ISEMBEDDED(m->m_ext_ref));
- KASSERT((m->m_ext_ref->m_flags & M_EXT) != 0);
- KASSERT((m->m_flags & M_EXT_CLUSTER) ==
- (m->m_ext_ref->m_flags & M_EXT_CLUSTER));
-
- if (__predict_false(m->m_type == MT_FREE)) {
- panic("mbuf %p already freed", m);
- }
-
- if (__predict_true(m->m_ext.ext_refcnt == 1)) {
- refcnt = m->m_ext.ext_refcnt = 0;
- } else {
- refcnt = atomic_dec_uint_nv(&m->m_ext.ext_refcnt);
- }
-
- if (refcnt > 0) {
- if (embedded) {
- /*
- * other mbuf's m_ext_ref still points to us.
- */
- dofree = false;
- } else {
- m->m_ext_ref = m;
- }
- } else {
- /*
- * dropping the last reference
- */
- if (!embedded) {
- m->m_ext.ext_refcnt++; /* XXX */
- m_ext_free(m->m_ext_ref);
- m->m_ext_ref = m;
- } else if ((m->m_flags & M_EXT_CLUSTER) != 0) {
- pool_cache_put_paddr((struct pool_cache *)
- m->m_ext.ext_arg,
- m->m_ext.ext_buf, m->m_ext.ext_paddr);
- } else if (m->m_ext.ext_free) {
- (*m->m_ext.ext_free)(m,
- m->m_ext.ext_buf, m->m_ext.ext_size,
- m->m_ext.ext_arg);
- /*
- * 'm' is already freed by the ext_free callback.
- */
- dofree = false;
- } else {
- free(m->m_ext.ext_buf, m->m_ext.ext_type);
- }
- }
-
- if (dofree) {
- m->m_type = MT_FREE;
- m->m_data = NULL;
- pool_cache_put(mb_cache, m);
- }
-}
-
#if defined(DDB)
void
m_print(const struct mbuf *m, const char *modif, void (*pr)(const char *, ...))
@@ -1970,6 +1901,75 @@
#endif /* defined(MBUFTRACE) */
/*
+ * Release a reference to the mbuf external storage.
+ *
+ * => free the mbuf m itself as well.
+ */
+static void
+m_ext_free(struct mbuf *m)
+{
+ const bool embedded = MEXT_ISEMBEDDED(m);
+ bool dofree = true;
+ u_int refcnt;
+
+ KASSERT((m->m_flags & M_EXT) != 0);
+ KASSERT(MEXT_ISEMBEDDED(m->m_ext_ref));
+ KASSERT((m->m_ext_ref->m_flags & M_EXT) != 0);
+ KASSERT((m->m_flags & M_EXT_CLUSTER) ==
+ (m->m_ext_ref->m_flags & M_EXT_CLUSTER));
+
+ if (__predict_false(m->m_type == MT_FREE)) {
+ panic("mbuf %p already freed", m);
+ }
+
+ if (__predict_true(m->m_ext.ext_refcnt == 1)) {
+ refcnt = m->m_ext.ext_refcnt = 0;
+ } else {
+ refcnt = atomic_dec_uint_nv(&m->m_ext.ext_refcnt);
+ }
+
+ if (refcnt > 0) {
+ if (embedded) {
+ /*
+ * other mbuf's m_ext_ref still points to us.
+ */
+ dofree = false;
+ } else {
+ m->m_ext_ref = m;
+ }
+ } else {
+ /*
+ * dropping the last reference
+ */
+ if (!embedded) {
+ m->m_ext.ext_refcnt++; /* XXX */
+ m_ext_free(m->m_ext_ref);
+ m->m_ext_ref = m;
+ } else if ((m->m_flags & M_EXT_CLUSTER) != 0) {
+ pool_cache_put_paddr((struct pool_cache *)
+ m->m_ext.ext_arg,
+ m->m_ext.ext_buf, m->m_ext.ext_paddr);
+ } else if (m->m_ext.ext_free) {
+ (*m->m_ext.ext_free)(m,
+ m->m_ext.ext_buf, m->m_ext.ext_size,
+ m->m_ext.ext_arg);
+ /*
+ * 'm' is already freed by the ext_free callback.
+ */
+ dofree = false;
+ } else {
+ free(m->m_ext.ext_buf, m->m_ext.ext_type);
+ }
+ }
+
+ if (dofree) {
+ m->m_type = MT_FREE;
+ m->m_data = NULL;
+ pool_cache_put(mb_cache, m);
+ }
+}
+
+/*
* Free a single mbuf and associated external storage. Return the
* successor, if any.
*/
Home |
Main Index |
Thread Index |
Old Index