On 06/10/2019 03:45, Ming Lei wrote:
+ } +} + +static int blk_mq_hctx_notify_online(unsigned int cpu, struct hlist_node *node) +{ + struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node, + struct blk_mq_hw_ctx, cpuhp_online); + unsigned prev_cpu = -1; + + while (true) { + unsigned next_cpu = cpumask_next_and(prev_cpu, hctx->cpumask, + cpu_online_mask); + + if (next_cpu >= nr_cpu_ids) + break; + + /* return if there is other online CPU on this hctx */ + if (next_cpu != cpu) + return 0; + + prev_cpu = next_cpu; + } + + set_bit(BLK_MQ_S_INTERNAL_STOPPED, &hctx->state); + blk_mq_drain_inflight_rqs(hctx); +
Does this do the same: { struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node, struct blk_mq_hw_ctx, cpuhp_online); cpumask_var_t tmp; cpumask_and(tmp, hctx->cpumask, cpu_online_mask); /* test if there is any other cpu online in the hctx cpu mask */ if (cpumask_any_but(tmp, cpu) < nr_cpu_ids) return 0; set_bit(BLK_MQ_S_INTERNAL_STOPPED, &hctx->state); blk_mq_drain_inflight_rqs(hctx); return 0; } If so, it's more readable and concise. Thanks, John BTW, You could have added my Tested-by tags...
+ return 0; +} +