mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-16 16:34:42 +00:00
MINOR: memory: don't let __pool_get_first() pick from the cache
When building with the local cache support, we have an asymmetry in the allocation path which is that __pool_get_first() picks from the cache while when no cache support is used, this one directly accesses the shared area. It looks like it was done this way only to centralize the call to __pool_get_from_cache() but this was not a good idea as it complicates the splitting the code. Let's move the cache access to the upper layer so thatt __pool_get_first() remains agnostic to the cache support. The call tree now looks like this with the cache enabled : pool_get_first() __pool_get_from_cache() // if cache enabled __pool_get_first() pool_alloc() pool_alloc_dirty() __pool_get_from_cache() // if cache enabled __pool_get_first() __pool_refill_alloc() __pool_free() pool_free_area() pool_put_to_cache() __pool_free() __pool_put_to_cache() pool_free() pool_put_to_cache() With cache disabled, the pool_free() path still differs: pool_free() __pool_free_area() __pool_put_to_cache()
This commit is contained in:
parent
24aa1eebaa
commit
a6982e5868
@ -160,10 +160,6 @@ static inline void *__pool_get_from_cache(struct pool_head *pool)
|
||||
static inline void *__pool_get_first(struct pool_head *pool)
|
||||
{
|
||||
struct pool_free_list cmp, new;
|
||||
void *ret = __pool_get_from_cache(pool);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
cmp.seq = pool->seq;
|
||||
__ha_barrier_load();
|
||||
@ -190,6 +186,9 @@ static inline void *pool_get_first(struct pool_head *pool)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
if (likely(ret = __pool_get_from_cache(pool)))
|
||||
return ret;
|
||||
|
||||
ret = __pool_get_first(pool);
|
||||
return ret;
|
||||
}
|
||||
@ -203,6 +202,9 @@ static inline void *pool_alloc_dirty(struct pool_head *pool)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (likely(p = __pool_get_from_cache(pool)))
|
||||
return p;
|
||||
|
||||
if ((p = __pool_get_first(pool)) == NULL)
|
||||
p = __pool_refill_alloc(pool, 0);
|
||||
return p;
|
||||
|
Loading…
Reference in New Issue
Block a user