diff options
Diffstat (limited to 'lib/debugobjects.c')
-rw-r--r-- | lib/debugobjects.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/debugobjects.c b/lib/debugobjects.c index fc9397de5534..cc32844ca18d 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -255,6 +255,24 @@ static struct debug_obj *pcpu_alloc(void) if (likely(obj)) { pcp->cnt--; + /* + * If this emptied a batch try to refill from the + * free pool. Don't do that if this was the top-most + * batch as pcpu_free() expects the per CPU pool + * to be less than ODEBUG_POOL_PERCPU_SIZE. + */ + if (unlikely(pcp->cnt < (ODEBUG_POOL_PERCPU_SIZE - ODEBUG_BATCH_SIZE) && + !(pcp->cnt % ODEBUG_BATCH_SIZE))) { + /* + * Don't try to allocate from the regular pool here + * to not exhaust it prematurely. + */ + if (pool_count(&pool_to_free)) { + guard(raw_spinlock)(&pool_lock); + pool_move_batch(pcp, &pool_to_free); + pcpu_refill_stats(); + } + } return obj; } |