summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-05-27 20:54:26 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-05-27 20:54:26 +0000
commit9633961c8ea8042fb22c2f4cbefc824a6980bcbd (patch)
treeb652a0c77381c84d99defb05b29909772d6799df /sys
parentc51554c18c6367c56e04251989f51d729fa69e0e (diff)
Kill the nasty MGET, MGETHDR and MCLGET makros and replace them with normal
functions. The world is no longer running on a PDP11 so function call overhead is not an issue. Diff by tbert, tested by many, OK art@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c83
-rw-r--r--sys/sys/mbuf.h67
2 files changed, 53 insertions, 97 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 0074b8f63a0..a7786a6ec06 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.80 2007/03/15 11:48:09 claudio Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.81 2007/05/27 20:54:25 claudio Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -153,15 +153,24 @@ m_reclaim(void *arg, int flags)
/*
* Space allocation routines.
- * These are also available as macros
- * for critical paths.
*/
struct mbuf *
m_get(int nowait, int type)
{
struct mbuf *m;
-
- MGET(m, nowait, type);
+ int s;
+
+ s = splvm();
+ m = pool_get(&mbpool, nowait == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);
+ if (m) {
+ m->m_type = type;
+ mbstat.m_mtypes[type]++;
+ m->m_next = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_data = m->m_dat;
+ m->m_flags = 0;
+ }
+ splx(s);
return (m);
}
@@ -169,8 +178,21 @@ struct mbuf *
m_gethdr(int nowait, int type)
{
struct mbuf *m;
-
- MGETHDR(m, nowait, type);
+ int s;
+
+ s = splvm();
+ m = pool_get(&mbpool, nowait == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);
+ if (m) {
+ m->m_type = type;
+ mbstat.m_mtypes[type]++;
+ m->m_next = (struct mbuf *)NULL;
+ m->m_nextpkt = (struct mbuf *)NULL;
+ m->m_data = m->m_pktdat;
+ m->m_flags = M_PKTHDR;
+ SLIST_INIT(&m->m_pkthdr.tags);
+ m->m_pkthdr.csum_flags = 0;
+ }
+ splx(s);
return (m);
}
@@ -186,6 +208,25 @@ m_getclr(int nowait, int type)
return (m);
}
+void
+m_clget(struct mbuf *m, int how)
+{
+ int s;
+
+ s = splvm();
+ m->m_ext.ext_buf =
+ pool_get(&mclpool, how == M_WAIT ? (PR_WAITOK|PR_LIMITFAIL) : 0);
+ splx(s);
+ if (m->m_ext.ext_buf != NULL) {
+ m->m_data = m->m_ext.ext_buf;
+ m->m_flags |= M_EXT|M_CLUSTER;
+ m->m_ext.ext_size = MCLBYTES;
+ m->m_ext.ext_free = NULL;
+ m->m_ext.ext_arg = NULL;
+ MCLINITREFERENCE(m);
+ }
+}
+
struct mbuf *
m_free(struct mbuf *m)
{
@@ -944,31 +985,3 @@ m_apply(struct mbuf *m, int off, int len,
return (0);
}
-
-#ifdef SMALL_KERNEL
-/*
- * The idea of adding code in a small kernel might look absurd, but this is
- * instead of macros.
- */
-struct mbuf *
-_sk_mget(int how, int type)
-{
- struct mbuf *m;
- _MGET(m, how, type);
- return m;
-}
-
-struct mbuf *
-_sk_mgethdr(int how, int type)
-{
- struct mbuf *m;
- _MGETHDR(m, how, type);
- return m;
-}
-
-void
-_sk_mclget(struct mbuf *m, int how)
-{
- _MCLGET(m, how);
-}
-#endif /* SMALL_KERNEL */
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 20cd9ad6e2c..4cdc4e60515 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.86 2007/01/03 18:39:56 claudio Exp $ */
+/* $OpenBSD: mbuf.h,v 1.87 2007/05/27 20:54:25 claudio Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -197,47 +197,9 @@ struct mbuf {
* allocates an mbuf and initializes it to contain a packet header
* and internal data.
*/
-#define _MGET(m, how, type) MBUFLOCK( \
- (m) = pool_get(&mbpool, \
- (how) == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0); \
- if (m) { \
- (m)->m_type = (type); \
- mbstat.m_mtypes[type]++; \
- (m)->m_next = (struct mbuf *)NULL; \
- (m)->m_nextpkt = (struct mbuf *)NULL; \
- (m)->m_data = (m)->m_dat; \
- (m)->m_flags = 0; \
- } \
-)
+#define MGET(m, how, type) m = m_get((how), (type))
-#ifdef SMALL_KERNEL
-struct mbuf *_sk_mget(int, int);
-#define MGET(m, how, type) { m = _sk_mget(how, type); }
-#else
-#define MGET(m, how, type) _MGET(m, how, type)
-#endif
-
-#define _MGETHDR(m, how, type) MBUFLOCK( \
- (m) = pool_get(&mbpool, \
- (how) == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0); \
- if (m) { \
- (m)->m_type = (type); \
- mbstat.m_mtypes[type]++; \
- (m)->m_next = (struct mbuf *)NULL; \
- (m)->m_nextpkt = (struct mbuf *)NULL; \
- (m)->m_data = (m)->m_pktdat; \
- (m)->m_flags = M_PKTHDR; \
- SLIST_INIT(&(m)->m_pkthdr.tags); \
- (m)->m_pkthdr.csum_flags = 0; \
- } \
-)
-
-#ifdef SMALL_KERNEL
-struct mbuf *_sk_mgethdr(int, int);
-#define MGETHDR(m, how, type) { m = _sk_mgethdr(how, type); }
-#else
-#define MGETHDR(m, how, type) _MGETHDR(m, how, type)
-#endif
+#define MGETHDR(m, how, type) m = m_gethdr((how), (type))
/*
* Macros for tracking external storage associated with an mbuf.
@@ -295,21 +257,6 @@ struct mbuf *_sk_mgethdr(int, int);
* MEXTADD adds pre-allocated external storage to
* a normal mbuf; the flag M_EXT is set upon success.
*/
-#define _MCLGET(m, how) do { \
- MBUFLOCK( \
- (m)->m_ext.ext_buf = pool_get(&mclpool, (how) == M_WAIT ? \
- (PR_WAITOK|PR_LIMITFAIL) : 0); \
- ); \
- if ((m)->m_ext.ext_buf != NULL) { \
- (m)->m_data = (m)->m_ext.ext_buf; \
- (m)->m_flags |= M_EXT|M_CLUSTER; \
- (m)->m_ext.ext_size = MCLBYTES; \
- (m)->m_ext.ext_free = NULL; \
- (m)->m_ext.ext_arg = NULL; \
- MCLINITREFERENCE(m); \
- } \
-} while (/* CONSTCOND */ 0)
-
#define MEXTMALLOC(m, size, how) do { \
(m)->m_ext.ext_buf = \
(caddr_t)malloc((size), mbtypes[(m)->m_type], (how)); \
@@ -367,12 +314,7 @@ do { \
(m)->m_data = (m)->m_dat; \
} while (/* CONSTCOND */ 0)
-#ifdef SMALL_KERNEL
-void _sk_mclget(struct mbuf *, int);
-#define MCLGET(m, how) _sk_mclget(m, how)
-#else
-#define MCLGET(m, how) _MCLGET(m, how)
-#endif
+#define MCLGET(m, how) m_clget(m, how)
/*
* MFREE(struct mbuf *m, struct mbuf *n)
@@ -547,6 +489,7 @@ struct mbuf *m_pullup2(struct mbuf *, int);
struct mbuf *m_split(struct mbuf *, int, int);
struct mbuf *m_inject(struct mbuf *, int, int, int);
struct mbuf *m_getptr(struct mbuf *, int, int *);
+void m_clget(struct mbuf *, int);
void m_adj(struct mbuf *, int);
int m_clalloc(int, int);
void m_copyback(struct mbuf *, int, int, const void *);