Subject: Re: kern/13232: POOL_DIAGNOSTIC && pool.h
To: None <sommerfeld@orchard.arlington.ma.us>
From: Assar Westerlund <assar@netbsd.org>
List: tech-kern
Date: 07/17/2001 16:55:48
--=-=-=

I wrote:
> Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us> writes:
> > they may be ignored in the called routine, but the caller still has to
> > load up argument registers / push arguments containing them; that's
> > where the performance hit was..
> > 
> > pool_get is called *VERY* frequently.
> 
> How about making just LKMs pay that price, as in this patch?  I cannot
> see how you could make LKMs that do not have to be different for
> POOL_DIAGNOSTIC and non-POOL_DIAGNOSTIC kernels otherwise.

It should be possible to allow all four combinations of
POOL_DIAGNOSTIC or not in both kernel and LKM.  Perhaps something like
this patch.  Any comments on it?

/assar


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=netbsd.pool.diff

Index: sys/pool.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/pool.h,v
retrieving revision 1.27
diff -u -w -r1.27 pool.h
--- sys/pool.h	2001/06/06 22:00:17	1.27
+++ sys/pool.h	2001/07/17 14:54:20
@@ -184,13 +184,13 @@
 void		pool_put(struct pool *, void *);
 void		pool_reclaim(struct pool *);
 
-#ifdef POOL_DIAGNOSTIC
-/*
- * These versions do reentrancy checking.
- */
 void		*_pool_get(struct pool *, int, const char *, long);
 void		_pool_put(struct pool *, void *, const char *, long);
 void		_pool_reclaim(struct pool *, const char *, long);
+/*
+ * These versions do reentrancy checking.
+ */
+#if defined(POOL_DIAGNOSTIC)
 #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__)
Index: kern/subr_pool.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/subr_pool.c,v
retrieving revision 1.60
diff -u -w -r1.60 subr_pool.c
--- kern/subr_pool.c	2001/07/01 06:12:20	1.60
+++ kern/subr_pool.c	2001/07/17 14:54:20
@@ -572,6 +572,20 @@
 	return (ph);
 }
 
+#ifdef POOL_DIAGNOSTIC
+void *
+pool_get(struct pool *pp, int flags)
+{
+	return _pool_get(pp, flags, "<unknown>", 0);
+}
+#else
+void *
+_pool_get(struct pool *pp, int flags, const char *file, long line)
+{
+	return pool_get(pp, flags);
+}
+#endif
+
 /*
  * Grab an item from the pool; must be called at appropriate spl level
  */
@@ -943,6 +957,20 @@
 	}
 }
 
+#ifdef POOL_DIAGNOSTIC
+void
+pool_put(struct pool *pp, void *v)
+{
+	return _pool_put(pp, v, "<unknown>", 0);
+}
+#else
+void
+_pool_put(struct pool *pp, void *v, const char *file, long line)
+{
+	return pool_put(pp, v);
+}
+#endif
+
 /*
  * Return resource to the pool; must be called at appropriate spl level
  */
@@ -1244,6 +1272,19 @@
 	uvm_km_free_poolpage1(kernel_map, (vaddr_t)v);
 }
 
+#ifdef POOL_DIAGNOSTIC
+void
+pool_reclaim(struct pool *pp)
+{
+	return _pool_reclaim(pp, "<unknown>", 0);
+}
+#else
+void
+_pool_reclaim(struct pool *pp, const char *file, long line)
+{
+	return pool_reclaim(pp);
+}
+#endif
 
 /*
  * Release all complete pages that have not been used recently.

--=-=-=--