Skip to content

Commit 7b81581

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: add helper for checking if one CPU is mapped to specified hctx
Commit a46c270 ("blk-mq: don't schedule block kworker on isolated CPUs") rules out isolated CPUs from hctx->cpumask, and hctx->cpumask should only be used for scheduling kworker. Add helper blk_mq_cpu_mapped_to_hctx() and apply it into cpuhp handlers. This patch avoids to forget clearing INACTIVE of hctx state in case that one isolated CPU becomes online, and fixes hang issue when allocating request from this hctx's tags. Cc: Raju Cheerla <[email protected]> Fixes: a46c270 ("blk-mq: don't schedule block kworker on isolated CPUs") Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Raju Cheerla <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 9d230c0 commit 7b81581

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

block/blk-mq.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,12 +3545,28 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node)
35453545
return 0;
35463546
}
35473547

3548+
/*
3549+
* Check if one CPU is mapped to the specified hctx
3550+
*
3551+
* Isolated CPUs have been ruled out from hctx->cpumask, which is supposed
3552+
* to be used for scheduling kworker only. For other usage, please call this
3553+
* helper for checking if one CPU belongs to the specified hctx
3554+
*/
3555+
static bool blk_mq_cpu_mapped_to_hctx(unsigned int cpu,
3556+
const struct blk_mq_hw_ctx *hctx)
3557+
{
3558+
struct blk_mq_hw_ctx *mapped_hctx = blk_mq_map_queue_type(hctx->queue,
3559+
hctx->type, cpu);
3560+
3561+
return mapped_hctx == hctx;
3562+
}
3563+
35483564
static int blk_mq_hctx_notify_online(unsigned int cpu, struct hlist_node *node)
35493565
{
35503566
struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node,
35513567
struct blk_mq_hw_ctx, cpuhp_online);
35523568

3553-
if (cpumask_test_cpu(cpu, hctx->cpumask))
3569+
if (blk_mq_cpu_mapped_to_hctx(cpu, hctx))
35543570
clear_bit(BLK_MQ_S_INACTIVE, &hctx->state);
35553571
return 0;
35563572
}
@@ -3568,7 +3584,7 @@ static int blk_mq_hctx_notify_dead(unsigned int cpu, struct hlist_node *node)
35683584
enum hctx_type type;
35693585

35703586
hctx = hlist_entry_safe(node, struct blk_mq_hw_ctx, cpuhp_dead);
3571-
if (!cpumask_test_cpu(cpu, hctx->cpumask))
3587+
if (!blk_mq_cpu_mapped_to_hctx(cpu, hctx))
35723588
return 0;
35733589

35743590
ctx = __blk_mq_get_ctx(hctx->queue, cpu);

0 commit comments

Comments
 (0)