Use pool_cache_*() for mbufs and clusters. While we don't use the

ctor/dtor feature, it's still faster to allocate from the cache groups
than it is from the pool (cache groups are analogous to "magazines"
in the Solaris SLAB allocator).
This commit is contained in:
thorpej 2001-07-26 19:05:04 +00:00
parent 2a6aa3926d
commit fcc2e4e5f6
2 changed files with 19 additions and 9 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: uipc_mbuf.c,v 1.52 2001/01/14 02:06:22 thorpej Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.53 2001/07/26 19:05:04 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -94,6 +94,9 @@
struct pool mbpool; /* mbuf pool */
struct pool mclpool; /* mbuf cluster pool */
struct pool_cache mbpool_cache;
struct pool_cache mclpool_cache;
struct mbstat mbstat;
int max_linkhdr;
int max_protohdr;
@ -118,6 +121,9 @@ mbinit()
pool_init(&mclpool, mclbytes, 0, 0, 0, "mclpl", 0, mclpool_alloc,
mclpool_release, 0);
pool_cache_init(&mbpool_cache, &mbpool, NULL, NULL, NULL);
pool_cache_init(&mclpool_cache, &mclpool, NULL, NULL, NULL);
/*
* Set the hard limit on the mclpool to the number of
* mbuf clusters the kernel is to support. Log the limit

View File

@ -1,4 +1,4 @@
/* $NetBSD: mbuf.h,v 1.59 2001/07/26 17:24:59 thorpej Exp $ */
/* $NetBSD: mbuf.h,v 1.60 2001/07/26 19:05:04 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2001 The NetBSD Foundation, Inc.
@ -253,7 +253,8 @@ struct mbuf {
* are guaranteed to return successfully.
*/
#define MGET(m, how, type) do { \
MBUFLOCK((m) = pool_get(&mbpool, (how) == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);); \
MBUFLOCK((m) = pool_cache_get(&mbpool_cache, \
(how) == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);); \
if (m) { \
MBUFLOCK(mbstat.m_mtypes[type]++;); \
(m)->m_type = (type); \
@ -266,7 +267,8 @@ struct mbuf {
} while (/* CONSTCOND */ 0)
#define MGETHDR(m, how, type) do { \
MBUFLOCK((m) = pool_get(&mbpool, (how) == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);); \
MBUFLOCK((m) = pool_cache_get(&mbpool_cache, \
(how) == M_WAIT ? PR_WAITOK|PR_LIMITFAIL : 0);); \
if (m) { \
MBUFLOCK(mbstat.m_mtypes[type]++;); \
(m)->m_type = (type); \
@ -340,12 +342,12 @@ struct mbuf {
#define MCLGET(m, how) do { \
MBUFLOCK( \
(m)->m_ext.ext_buf = \
pool_get(&mclpool, (how) == M_WAIT ? \
pool_cache_get(&mclpool_cache, (how) == M_WAIT ? \
(PR_WAITOK|PR_LIMITFAIL) : 0); \
if ((m)->m_ext.ext_buf == NULL) { \
m_reclaim((how)); \
(m)->m_ext.ext_buf = \
pool_get(&mclpool, \
pool_cache_get(&mclpool_cache, \
(how) == M_WAIT ? PR_WAITOK : 0); \
} \
); \
@ -389,7 +391,7 @@ struct mbuf {
if (MCLISREFERENCED(m)) { \
_MCLDEREFERENCE(m); \
} else if ((m)->m_flags & M_CLUSTER) { \
pool_put(&mclpool, (m)->m_ext.ext_buf); \
pool_cache_put(&mclpool_cache, (m)->m_ext.ext_buf); \
} else if ((m)->m_ext.ext_free) { \
(*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
(m)->m_ext.ext_size, (m)->m_ext.ext_arg); \
@ -436,7 +438,7 @@ do { \
_MEXTREMOVE((m)); \
} \
(n) = (m)->m_next; \
pool_put(&mbpool, (m)); \
pool_cache_put(&mbpool_cache, (m)); \
)
/*
@ -596,6 +598,8 @@ extern const int mclbytes; /* mbuf cluster size */
extern const int mbtypes[]; /* XXX */
extern struct pool mbpool;
extern struct pool mclpool;
extern struct pool_cache mbpool_cache;
extern struct pool_cache mclpool_cache;
struct mbuf *m_copym __P((struct mbuf *, int, int, int));
struct mbuf *m_copypacket __P((struct mbuf *, int));