> >> static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx) > >> { > >> - bool tried = false; > >> int next_cpu = hctx->next_cpu; > >> > >> if (hctx->queue->nr_hw_queues == 1) > >> return WORK_CPU_UNBOUND; > >> > >> - if (--hctx->next_cpu_batch <= 0) { > >> -select_cpu: > >> - next_cpu = cpumask_next_and(next_cpu, hctx->cpumask, > >> - cpu_online_mask); > >> - if (next_cpu >= nr_cpu_ids) > >> - next_cpu = blk_mq_first_mapped_cpu(hctx); > >> + if (--hctx->next_cpu_batch > 0 && cpu_online(next_cpu)) > >> + return next_cpu; > >> + > >> + next_cpu = cpumask_next_and_wrap(next_cpu, hctx->cpumask, cpu_online_mask, next_cpu, false); > > > > Last two parameters are simply useless. In fact, in many cases they > > are useless for cpumask_next_wrap(). I'm working on simplifying the > > cpumask_next_wrap() so that it would take just 2 parameters - pivot > > point and cpumask. > > > > Regarding 'next' version - we already have find_next_and_bit_wrap(), > > and I think cpumask_next_and_wrap() should use it. > > > > Oh, I had missed those, that makes more sense indeed. > > > For the context: those last parameters are needed to exclude part of > > cpumask from traversing, and to implement for-loop. Now that we have > > for_each_cpu_wrap() based on for_each_set_bit_wrap(), it's possible > > to remove them. I'm working on it. > > Sounds good. Hi Valentin, all, I'd like to share my work-in-progress for cpumask_next_wrap(). It's now in testing (at least, it boots on x86_64 VM). I'd like to collect early comments on the rework. If you like it, please align your 'and' version with this. https://github.com/norov/linux/commits/__bitmap-for-next Thanks, Yury