Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Use pool_cache_*() for mbufs and clusters. While we don...



details:   https://anonhg.NetBSD.org/src/rev/afb9cf4e432e
branches:  trunk
changeset: 513230:afb9cf4e432e
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 26 19:05:04 2001 +0000

description:
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).

diffstat:

 sys/kern/uipc_mbuf.c |  10 ++++++++--
 sys/sys/mbuf.h       |  18 +++++++++++-------
 2 files changed, 19 insertions(+), 9 deletions(-)

diffs (104 lines):

diff -r c36806880813 -r afb9cf4e432e sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Thu Jul 26 17:24:59 2001 +0000
+++ b/sys/kern/uipc_mbuf.c      Thu Jul 26 19:05:04 2001 +0000
@@ -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 @@
        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
diff -r c36806880813 -r afb9cf4e432e sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Thu Jul 26 17:24:59 2001 +0000
+++ b/sys/sys/mbuf.h    Thu Jul 26 19:05:04 2001 +0000
@@ -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 @@
  * 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 @@
 } 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 @@
 #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 @@
        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 @@
                        _MEXTREMOVE((m)); \
                } \
                (n) = (m)->m_next; \
-               pool_put(&mbpool, (m)); \
+               pool_cache_put(&mbpool_cache, (m)); \
        )
 
 /*
@@ -596,6 +598,8 @@
 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));



Home | Main Index | Thread Index | Old Index