Hide MFREE now that it is not being used anymore and provide some debugging
for the location of the last free for debugging kernels.
This commit is contained in:
parent
a406e29ff1
commit
192a00203a
|
@ -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 @@ m_clget(struct mbuf *m, int nowait)
|
|||
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 @@ m_claim(struct mbuf *m, struct mowner *mo)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -572,25 +572,6 @@ do { \
|
|||
(m)->m_data = (m)->m_dat; \
|
||||
} 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_copypacket(struct mbuf *, int);
|
|||
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 @@ struct mbuf *m_copyback_cow(struct mbuf *, int, int, const void *, int);
|
|||
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 *);
|
||||
|
|
Loading…
Reference in New Issue