diff options
author | Yury Norov <yury.norov@gmail.com> | 2025-01-28 11:46:30 -0500 |
---|---|---|
committer | Yury Norov <yury.norov@gmail.com> | 2025-02-18 11:51:22 -0500 |
commit | d81603b32cde95e5262c84004081b2e3cb4f23ed (patch) | |
tree | 06e544cfde1b2d892c73d5338dd3e87090e7a124 | |
parent | 9ffa4b35a62d9786ce418085f36af671df3aacaa (diff) |
objpool: rework objpool_pop()
The function has to track number of iterations to prevent an infinite
loop. for_each_cpu_wrap() macro takes care of it, which simplifies user
code.
Signed-off-by: Yury Norov <yury.norov@gmail.com>
-rw-r--r-- | include/linux/objpool.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/include/linux/objpool.h b/include/linux/objpool.h index cb1758eaa2d3..b713a1fe7521 100644 --- a/include/linux/objpool.h +++ b/include/linux/objpool.h @@ -170,17 +170,16 @@ static inline void *objpool_pop(struct objpool_head *pool) { void *obj = NULL; unsigned long flags; - int i, cpu; + int start, cpu; /* disable local irq to avoid preemption & interruption */ raw_local_irq_save(flags); - cpu = raw_smp_processor_id(); - for (i = 0; i < pool->nr_possible_cpus; i++) { + start = raw_smp_processor_id(); + for_each_possible_cpu_wrap(cpu, start) { obj = __objpool_try_get_slot(pool, cpu); if (obj) break; - cpu = cpumask_next_wrap(cpu, cpu_possible_mask, -1, 1); } raw_local_irq_restore(flags); |