Source-Changes-HG archive

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

[src/trunk]: src/sys Remove pool reentrancy testing overhead unless DIAGNOSTI...



details:   https://anonhg.NetBSD.org/src/rev/b056d9065a5b
branches:  trunk
changeset: 509808:b056d9065a5b
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sun May 13 17:06:58 2001 +0000

description:
Remove pool reentrancy testing overhead unless DIAGNOSTIC is defined.
Previously, we passed __FILE__ and __LINE__ on all pool_get/pool_set calls.

This change results in a measured 1.2% performance improvement in
ping-flood packets-per-second as reported by ping(8).

diffstat:

 sys/kern/subr_pool.c |  43 ++++++++++++++++++++++++++++++++-----------
 sys/sys/pool.h       |  10 ++++++++--
 2 files changed, 40 insertions(+), 13 deletions(-)

diffs (172 lines):

diff -r 55087dee85b8 -r b056d9065a5b sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Sun May 13 16:59:58 2001 +0000
+++ b/sys/kern/subr_pool.c      Sun May 13 17:06:58 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pool.c,v 1.55 2001/05/10 04:51:41 thorpej Exp $   */
+/*     $NetBSD: subr_pool.c,v 1.56 2001/05/13 17:06:59 sommerfeld Exp $        */
 
 /*-
  * Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -572,7 +572,11 @@
  * Grab an item from the pool; must be called at appropriate spl level
  */
 void *
+#ifdef DIAGNOSTIC
 _pool_get(struct pool *pp, int flags, const char *file, long line)
+#else
+pool_get(struct pool *pp, int flags)
+#endif
 {
        struct pool_item *pi;
        struct pool_item_header *ph;
@@ -584,11 +588,11 @@
                pr_printlog(pp, NULL, printf);
                panic("pool_get: static");
        }
-#endif
 
        if (__predict_false(curproc == NULL && doing_shutdown == 0 &&
                            (flags & PR_WAITOK) != 0))
                panic("pool_get: must have NOWAIT");
+#endif
 
        simple_lock(&pp->pr_slock);
        pr_enter(pp, file, line);
@@ -728,10 +732,9 @@
                    pp->pr_wchan, pp->pr_nitems);
                panic("pool_get: nitems inconsistent\n");
        }
-#endif
+
        pr_log(pp, v, PRLOG_GET, file, line);
 
-#ifdef DIAGNOSTIC
        if (__predict_false(pi->pi_magic != PI_MAGIC)) {
                pr_printlog(pp, pi, printf);
                panic("pool_get(%s): free list modified: magic=%x; page %p;"
@@ -807,7 +810,7 @@
  * Internal version of pool_put().  Pool is already locked/entered.
  */
 static void
-pool_do_put(struct pool *pp, void *v, const char *file, long line)
+pool_do_put(struct pool *pp, void *v)
 {
        struct pool_item *pi = v;
        struct pool_item_header *ph;
@@ -824,8 +827,6 @@
        }
 #endif
 
-       pr_log(pp, v, PRLOG_PUT, file, line);
-
        if (__predict_false((ph = pr_find_pagehead(pp, page)) == NULL)) {
                pr_printlog(pp, NULL, printf);
                panic("pool_put: %s: page header missing", pp->pr_wchan);
@@ -936,6 +937,7 @@
 /*
  * Return resource to the pool; must be called at appropriate spl level
  */
+#ifdef DIAGNOSTIC
 void
 _pool_put(struct pool *pp, void *v, const char *file, long line)
 {
@@ -943,12 +945,27 @@
        simple_lock(&pp->pr_slock);
        pr_enter(pp, file, line);
 
-       pool_do_put(pp, v, file, line);
+       pr_log(pp, v, PRLOG_PUT, file, line);
+
+       pool_do_put(pp, v);
 
        pr_leave(pp);
        simple_unlock(&pp->pr_slock);
 }
 
+#else
+void
+pool_put(struct pool *pp, void *v)
+{
+
+       simple_lock(&pp->pr_slock);
+
+       pool_do_put(pp, v);
+
+       simple_unlock(&pp->pr_slock);
+}
+#endif
+
 /*
  * Add N items to the pool.
  */
@@ -1219,7 +1236,11 @@
  * Release all complete pages that have not been used recently.
  */
 void
+#ifdef DIAGNOSTIC
 _pool_reclaim(struct pool *pp, const char *file, long line)
+#else
+pool_reclaim(struct pool *pp)
+#endif
 {
        struct pool_item_header *ph, *phnext;
        struct pool_cache *pc;
@@ -1729,7 +1750,7 @@
  */
 static void
 pool_cache_do_invalidate(struct pool_cache *pc, int free_groups,
-    void (*putit)(struct pool *, void *, const char *, long))
+    void (*putit)(struct pool *, void *))
 {
        struct pool_cache_group *pcg, *npcg;
        void *object;
@@ -1744,7 +1765,7 @@
                                pc->pc_allocfrom = NULL;
                        if (pc->pc_dtor != NULL)
                                (*pc->pc_dtor)(pc->pc_arg, object);
-                       (*putit)(pc->pc_pool, object, __FILE__, __LINE__);
+                       (*putit)(pc->pc_pool, object);
                }
                if (free_groups) {
                        pc->pc_ngroups--;
@@ -1767,7 +1788,7 @@
 {
 
        simple_lock(&pc->pc_slock);
-       pool_cache_do_invalidate(pc, 0, _pool_put);
+       pool_cache_do_invalidate(pc, 0, pool_put);
        simple_unlock(&pc->pc_slock);
 }
 
diff -r 55087dee85b8 -r b056d9065a5b sys/sys/pool.h
--- a/sys/sys/pool.h    Sun May 13 16:59:58 2001 +0000
+++ b/sys/sys/pool.h    Sun May 13 17:06:58 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pool.h,v 1.23 2001/05/10 04:51:41 thorpej Exp $        */
+/*     $NetBSD: pool.h,v 1.24 2001/05/13 17:06:58 sommerfeld Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -176,8 +176,9 @@
                                 int);
 void           pool_destroy(struct pool *);
 
+#ifdef DIAGNOSTIC
 /*
- * These routines do reentrancy checking.
+ * These versions do reentrancy checking.
  */
 void           *_pool_get(struct pool *, int, const char *, long);
 void           _pool_put(struct pool *, void *, const char *, long);
@@ -185,6 +186,11 @@
 #define                pool_get(h, f)  _pool_get((h), (f), __FILE__, __LINE__)
 #define                pool_put(h, v)  _pool_put((h), (v), __FILE__, __LINE__)
 #define                pool_reclaim(h) _pool_reclaim((h), __FILE__, __LINE__)
+#else
+void           *pool_get(struct pool *, int);
+void           pool_put(struct pool *, void *);
+void           pool_reclaim(struct pool *);
+#endif
 
 int            pool_prime(struct pool *, int);
 void           pool_setlowat(struct pool *, int);



Home | Main Index | Thread Index | Old Index