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 7845e1b01e
("lib/mempool: Fix spurious -ENOMEM due to agressive latency control").
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
f0ddbd7eee
commit
d12462ca6c
1 changed files with 3 additions and 20 deletions
|
@ -61,26 +61,9 @@ int k_mem_pool_alloc(struct k_mem_pool *p, struct k_mem_block *block,
|
||||||
while (true) {
|
while (true) {
|
||||||
u32_t level_num, block_num;
|
u32_t level_num, block_num;
|
||||||
|
|
||||||
/* There is a "managed race" in alloc that can fail
|
ret = z_sys_mem_pool_block_alloc(&p->base, size,
|
||||||
* (albeit in a well-defined way, see comments there)
|
&level_num, &block_num,
|
||||||
* with -EAGAIN when simultaneous allocations happen.
|
&block->data);
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
block->id.pool = pool_id(p);
|
block->id.pool = pool_id(p);
|
||||||
block->id.level = level_num;
|
block->id.level = level_num;
|
||||||
block->id.block = block_num;
|
block->id.block = block_num;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue