tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Adding pool_cache_invalidate_local() to pool_cache(9) API
On Oct 14, 2009, at 1:35 PM, Jean-Yves Migeon wrote:
> However, only the boot processor is running at this stage, and it's still not
> flagged SPCF_RUNNING (it happens during configure2()). As a result,
> xc_broadcast() will never increment xc_headp (see its code), and the
> KASSERT() fires.
Try this flavor of the patch. It avoids using xc_broadcast() if < 2 CPUs are
running (which should handle the early-in-boot case as well as the avoid having
to issue a cross-call on uniprocessors).
Index: kern/subr_pool.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_pool.c,v
retrieving revision 1.175
diff -u -p -r1.175 subr_pool.c
--- kern/subr_pool.c 8 Oct 2009 21:54:45 -0000 1.175
+++ kern/subr_pool.c 15 Oct 2009 04:58:28 -0000
@@ -2289,11 +2289,33 @@ pool_cache_invalidate_groups(pool_cache_
*
* Invalidate a pool cache (destruct and release all of the
* cached objects). Does not reclaim objects from the pool.
+ *
+ * Note: For pool caches that provide constructed objects, there
+ * is an assumption that another level of synchronization is occurring
+ * between the input to the constructor and the cache invalidation.
*/
void
pool_cache_invalidate(pool_cache_t pc)
{
pcg_t *full, *empty, *part;
+ uint64_t where;
+
+ if (ncpu < 2) {
+ /*
+ * We might be called early enough in the boot process
+ * for the CPU data structures to not be fully initialized.
+ * In this case, simply gather the local CPU's cache now
+ * since it will be the only one running.
+ */
+ pool_cache_xcall(pc);
+ } else {
+ /*
+ * Gather all of the CPU-specific caches into the
+ * global cache.
+ */
+ where = xc_broadcast(0, (xcfunc_t)pool_cache_xcall, pc, NULL);
+ xc_wait(where);
+ }
mutex_enter(&pc->pc_lock);
full = pc->pc_fullgroups;
@@ -2313,20 +2335,6 @@ pool_cache_invalidate(pool_cache_t pc)
}
/*
- * pool_cache_invalidate_local:
- *
- * Invalidate all local ('current CPU') cached objects in
- * pool cache.
- * It is caller's responsibility to ensure that no operation is
- * taking place on this pool cache while doing the local invalidation.
- */
-void
-pool_cache_invalidate_local(pool_cache_t pc)
-{
- pool_cache_invalidate_cpu(pc, curcpu()->ci_index);
-}
-
-/*
* pool_cache_invalidate_cpu:
*
* Invalidate all CPU-bound cached objects in pool cache, the CPU being
Index: sys/pool.h
===================================================================
RCS file: /cvsroot/src/sys/sys/pool.h,v
retrieving revision 1.66
diff -u -p -r1.66 pool.h
--- sys/pool.h 8 Oct 2009 21:54:45 -0000 1.66
+++ sys/pool.h 15 Oct 2009 04:58:28 -0000
@@ -321,7 +321,6 @@ void *pool_cache_get_paddr(pool_cache_t
void pool_cache_put_paddr(pool_cache_t, void *, paddr_t);
void pool_cache_destruct_object(pool_cache_t, void *);
void pool_cache_invalidate(pool_cache_t);
-void pool_cache_invalidate_local(pool_cache_t);
bool pool_cache_reclaim(pool_cache_t);
void pool_cache_set_drain_hook(pool_cache_t,
void (*)(void *, int), void *);
-- thorpej
Home |
Main Index |
Thread Index |
Old Index