Skip to content

Commit d81603b

Browse files
committed
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 <[email protected]>
1 parent 9ffa4b3 commit d81603b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

include/linux/objpool.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,16 @@ static inline void *objpool_pop(struct objpool_head *pool)
170170
{
171171
void *obj = NULL;
172172
unsigned long flags;
173-
int i, cpu;
173+
int start, cpu;
174174

175175
/* disable local irq to avoid preemption & interruption */
176176
raw_local_irq_save(flags);
177177

178-
cpu = raw_smp_processor_id();
179-
for (i = 0; i < pool->nr_possible_cpus; i++) {
178+
start = raw_smp_processor_id();
179+
for_each_possible_cpu_wrap(cpu, start) {
180180
obj = __objpool_try_get_slot(pool, cpu);
181181
if (obj)
182182
break;
183-
cpu = cpumask_next_wrap(cpu, cpu_possible_mask, -1, 1);
184183
}
185184
raw_local_irq_restore(flags);
186185

0 commit comments

Comments
 (0)