From d12462ca6c5913e2519c5486807e7e81ebe06697 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 4 Oct 2019 12:10:07 -0400 Subject: [PATCH] k_mem_pool_alloc(): remove dead code A loop in k_mem_pool_alloc() around z_sys_mem_pool_block_alloc() assumes the later may return -EAGAIN with an elaborate comment about it. But -EAGAIN is no longer returned by that function since commit 7845e1b01e90 ("lib/mempool: Fix spurious -ENOMEM due to agressive latency control"). Signed-off-by: Nicolas Pitre --- kernel/mempool.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/kernel/mempool.c b/kernel/mempool.c index a5ede59f73..ae6fade218 100644 --- a/kernel/mempool.c +++ b/kernel/mempool.c @@ -61,26 +61,9 @@ int k_mem_pool_alloc(struct k_mem_pool *p, struct k_mem_block *block, while (true) { u32_t level_num, block_num; - /* There is a "managed race" in alloc that can fail - * (albeit in a well-defined way, see comments there) - * with -EAGAIN when simultaneous allocations happen. - * Retry exactly once before sleeping to resolve it. - * If we're so contended that it fails twice, then we - * clearly want to block. - */ - for (int i = 0; i < 2; i++) { - ret = z_sys_mem_pool_block_alloc(&p->base, size, - &level_num, &block_num, - &block->data); - if (ret != -EAGAIN) { - break; - } - } - - if (ret == -EAGAIN) { - ret = -ENOMEM; - } - + ret = z_sys_mem_pool_block_alloc(&p->base, size, + &level_num, &block_num, + &block->data); block->id.pool = pool_id(p); block->id.level = level_num; block->id.block = block_num;