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 8, 2009, at 11:52 PM, Jean-Yves Migeon wrote:

> I need a way to invalidate all pool caches, even those that are CPU-bound. 
> pool_cache_invalidate() only does that for the global cache, as it cannot 
> invalidate CPU caches for CPUs other than its own.

This patch should solve the problem.  Please try it out.

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  13 Oct 2009 21:37:14 -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 *);
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    13 Oct 2009 21:37:14 -0000
@@ -2289,11 +2289,20 @@ 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;
+
+       /* 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 +2322,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

-- thorpej



Home | Main Index | Thread Index | Old Index