void pool_put_to_cache(struct pool_head *pool, void *ptr, const void *caller);
void pool_fill_pattern(struct pool_cache_head *pch, struct pool_cache_item *item, uint size);
void pool_check_pattern(struct pool_cache_head *pch, struct pool_cache_item *item, uint size);
-
-#if defined(CONFIG_HAP_NO_GLOBAL_POOLS)
-
-static inline uint pool_releasable(const struct pool_head *pool)
-{
- /* no room left */
- return 0;
-}
-
-static inline void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_head *pch)
-{
- /* ignored without shared pools */
-}
-
-static inline void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item, uint count)
-{
- /* ignored without shared pools */
-}
-
-#else /* CONFIG_HAP_NO_GLOBAL_POOLS */
-
void pool_refill_local_from_shared(struct pool_head *pool, struct pool_cache_head *pch);
void pool_put_to_shared_cache(struct pool_head *pool, struct pool_item *item, uint count);
* be released in the worst case, and that this value is always lower than or
* equal to ->allocated. It's important to understand that under thread
* contention these values may not always be accurate but the principle is that
- * any deviation remains contained.
+ * any deviation remains contained. When global pools are disabled, this
+ * function always returns zero so that the caller knows it must free the
+ * object via other ways.
*/
static inline uint pool_releasable(const struct pool_head *pool)
{
uint alloc, used;
+ if (unlikely(pool_debugging & POOL_DBG_NO_GLOBAL))
+ return 0;
+
alloc = HA_ATOMIC_LOAD(&pool->allocated);
used = HA_ATOMIC_LOAD(&pool->used);
if (used < alloc)
return 0;
}
-
-#endif /* CONFIG_HAP_NO_GLOBAL_POOLS */
-
/* These are generic cache-aware wrappers that allocate/free from/to the local
* cache first, then from the second level if it exists.
*/
/* Tries to retrieve an object from the local pool cache corresponding to pool
- * <pool>. If none is available, tries to allocate from the shared cache, and
- * returns NULL if nothing is available.
+ * <pool>. If none is available, tries to allocate from the shared cache if any
+ * and returns NULL if nothing is available.
*/
static inline void *pool_get_from_cache(struct pool_head *pool, const void *caller)
{
ph = &pool->cache[tid];
if (unlikely(LIST_ISEMPTY(&ph->list))) {
- pool_refill_local_from_shared(pool, ph);
+ if (!(pool_debugging & POOL_DBG_NO_GLOBAL))
+ pool_refill_local_from_shared(pool, ph);
if (LIST_ISEMPTY(&ph->list))
return NULL;
}
#endif
#ifdef DEBUG_POOL_INTEGRITY
POOL_DBG_INTEGRITY |
+#endif
+#ifdef CONFIG_HAP_NO_GLOBAL_POOLS
+ POOL_DBG_NO_GLOBAL |
#endif
0;
uint cluster = 0;
uint to_free_max;
+ /* Note: this will be zero when global pools are disabled */
to_free_max = pool_releasable(pool);
while (released < count && !LIST_ISEMPTY(&ph->list)) {
LIST_DELETE(&item->by_lru);
if (to_free_max > released || cluster) {
+ /* will never match when global pools are disabled */
pi = (struct pool_item *)item;
pi->next = NULL;
pi->down = head;
}
}
-#if defined(CONFIG_HAP_NO_GLOBAL_POOLS)
-
-/* legacy stuff */
-void pool_flush(struct pool_head *pool)
-{
-}
-
-/* This function might ask the malloc library to trim its buffers. */
-void pool_gc(struct pool_head *pool_ctx)
-{
- trim_all_pools();
-}
-
-#else /* CONFIG_HAP_NO_GLOBAL_POOLS */
-
/* Tries to refill the local cache <pch> from the shared one for pool <pool>.
* This is only used when pools are in use and shared pools are enabled. No
* malloc() is attempted, and poisonning is never performed. The purpose is to
if (!isolated)
thread_release();
}
-#endif /* CONFIG_HAP_NO_GLOBAL_POOLS */
#else /* CONFIG_HAP_POOLS */