Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Hide MFREE now that it is not being used anymore and pro...
details: https://anonhg.NetBSD.org/src/rev/4772a2ff0cb6
branches: trunk
changeset: 348088:4772a2ff0cb6
user: christos <christos%NetBSD.org@localhost>
date: Tue Oct 04 14:13:21 2016 +0000
description:
Hide MFREE now that it is not being used anymore and provide some debugging
for the location of the last free for debugging kernels.
diffstat:
sys/kern/uipc_mbuf.c | 102 +++++++++++++++++++++++++++++++++++++++------------
sys/sys/mbuf.h | 30 ++++----------
2 files changed, 87 insertions(+), 45 deletions(-)
diffs (186 lines):
diff -r 362100d908b4 -r 4772a2ff0cb6 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c Tue Oct 04 14:00:27 2016 +0000
+++ b/sys/kern/uipc_mbuf.c Tue Oct 04 14:13:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_mbuf.c,v 1.168 2016/06/16 02:38:40 ozaki-r Exp $ */
+/* $NetBSD: uipc_mbuf.c,v 1.169 2016/10/04 14:13:21 christos 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.168 2016/06/16 02:38:40 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.169 2016/10/04 14:13:21 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_mbuftrace.h"
@@ -635,28 +635,6 @@
MCLGET(m, nowait);
}
-struct mbuf *
-m_free(struct mbuf *m)
-{
- struct mbuf *n;
-
- MFREE(m, n);
- return (n);
-}
-
-void
-m_freem(struct mbuf *m)
-{
- struct mbuf *n;
-
- if (m == NULL)
- return;
- do {
- MFREE(m, n);
- m = n;
- } while (m);
-}
-
#ifdef MBUFTRACE
/*
* Walk a chain of mbufs, claiming ownership of each mbuf in the chain.
@@ -1935,3 +1913,79 @@
mowner_claim(m, mo);
}
#endif /* defined(MBUFTRACE) */
+
+/*
+ * MFREE(struct mbuf *m, struct mbuf *n)
+ * Free a single mbuf and associated external storage.
+ * Place the successor, if any, in n.
+ */
+#define MFREE(f, l, m, n) \
+ mowner_revoke((m), 1, (m)->m_flags); \
+ mbstat_type_add((m)->m_type, -1); \
+ if ((m)->m_flags & M_PKTHDR) \
+ m_tag_delete_chain((m), NULL); \
+ (n) = (m)->m_next; \
+ if ((m)->m_flags & M_EXT) { \
+ m_ext_free((m)); \
+ } else { \
+ MBUFFREE(f, l, m); \
+ } \
+
+#ifdef DEBUG
+#define MBUFFREE(f, l, m) \
+ do { \
+ if ((m)->m_type == MT_FREE) \
+ panic("mbuf was already freed at %s,%d", \
+ m->m_data, m->m_len); \
+ (m)->m_type = MT_FREE; \
+ (m)->m_data = __UNCONST(f); \
+ (m)->m_len = l; \
+ pool_cache_put(mb_cache, (m)); \
+ } while (/*CONSTCOND*/0)
+
+#else
+#define MBUFFREE(f, l, m) \
+ do { \
+ KASSERT((m)->m_type != MT_FREE); \
+ (m)->m_type = MT_FREE; \
+ pool_cache_put(mb_cache, (m)); \
+ } while (/*CONSTCOND*/0)
+#endif
+
+struct mbuf *
+m__free(const char *f, int l, struct mbuf *m)
+{
+ struct mbuf *n;
+
+ MFREE(f, l, m, n);
+ return (n);
+}
+
+void
+m__freem(const char *f, int l, struct mbuf *m)
+{
+ struct mbuf *n;
+
+ if (m == NULL)
+ return;
+ do {
+ MFREE(f, l, m, n);
+ m = n;
+ } while (m);
+}
+
+#undef m_free
+struct mbuf *m_free(struct mbuf *);
+struct mbuf *
+m_free(struct mbuf *m)
+{
+ return m__free(__func__, __LINE__, m);
+}
+
+#undef m_freem
+void m_freem(struct mbuf *);
+void
+m_freem(struct mbuf *m)
+{
+ m__freem(__func__, __LINE__, m);
+}
diff -r 362100d908b4 -r 4772a2ff0cb6 sys/sys/mbuf.h
--- a/sys/sys/mbuf.h Tue Oct 04 14:00:27 2016 +0000
+++ b/sys/sys/mbuf.h Tue Oct 04 14:13:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mbuf.h,v 1.166 2016/06/21 03:07:54 ozaki-r Exp $ */
+/* $NetBSD: mbuf.h,v 1.167 2016/10/04 14:13:21 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -573,25 +573,6 @@
} while (/* CONSTCOND */ 0)
/*
- * MFREE(struct mbuf *m, struct mbuf *n)
- * Free a single mbuf and associated external storage.
- * Place the successor, if any, in n.
- */
-#define MFREE(m, n) \
- mowner_revoke((m), 1, (m)->m_flags); \
- mbstat_type_add((m)->m_type, -1); \
- if ((m)->m_flags & M_PKTHDR) \
- m_tag_delete_chain((m), NULL); \
- (n) = (m)->m_next; \
- if ((m)->m_flags & M_EXT) { \
- m_ext_free((m)); \
- } else { \
- KASSERT((m)->m_type != MT_FREE); \
- (m)->m_type = MT_FREE; \
- pool_cache_put(mb_cache, (m)); \
- } \
-
-/*
* Copy mbuf pkthdr from `from' to `to'.
* `from' must have M_PKTHDR set, and `to' must be empty.
*/
@@ -849,7 +830,6 @@
struct mbuf *m_devget(char *, int, int, struct ifnet *,
void (*copy)(const void *, void *, size_t));
struct mbuf *m_dup(struct mbuf *, int, int, int);
-struct mbuf *m_free(struct mbuf *);
struct mbuf *m_get(int, int);
struct mbuf *m_getclr(int, int);
struct mbuf *m_gethdr(int, int);
@@ -871,7 +851,15 @@
int m_makewritable(struct mbuf **, int, int, int);
struct mbuf *m_getcl(int, int, int);
void m_copydata(struct mbuf *, int, int, void *);
+struct mbuf *m__free(const char *, int, struct mbuf *);
+void m__freem(const char *, int, struct mbuf *);
+#ifdef DEBUG
+#define m_free(m) m__free(__func__, __LINE__, m)
+#define m_freem(m) m__freem(__func__, __LINE__, m)
+#else
+struct mbuf *m_free(struct mbuf *);
void m_freem(struct mbuf *);
+#endif
void m_reclaim(void *, int);
void mbinit(void);
void m_ext_free(struct mbuf *);
Home |
Main Index |
Thread Index |
Old Index