Skip to content

Commit

Permalink
blk-mq: pass use managed irq info to blk_mq_dev_map_queues
Browse files Browse the repository at this point in the history
Managed irq is special because genirq core will shut down it when all
cpus in its affinity mask are offline, so blk-mq has to drain requests
and prevent new allocation on the hw queue before its managed irq
is shutdown.

In current implementation, we drain all hctx when the last cpu in
hctx->cpumask is going to be offline. However, we need to avoid the
draining of hw queues which don't use managed irq, one kind of user
is nvme fc/rdma/tcp because these controllers require to submit connection
request successfully even though all cpus in hctx->cpumask are offline.
And we have lots of kernel panic reports on blk_mq_alloc_request_hctx().

Once we know if one qmap uses managed irq or not, we needn't to drain
requests for hctx which doesn't use managed irq, and we can allow to
allocate request on hctx in which all CPUs in hctx->cpumask are offline,
then not only fix kernel panic in blk_mq_alloc_request_hctx(), but also
meet nvme fc/rdma/tcp's requirement.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
  • Loading branch information
Ming Lei authored and intel-lab-lkp committed Jul 9, 2021
1 parent d2f1db6 commit 49f5094
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion block/blk-mq-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)
* @dev_data: Device data passed to get_queue_affinity()
* @fallback: If true, fallback to default blk-mq mapping in case of
* any failure
* @managed_irq: If driver is likely to use managed irq, pass @managed_irq
* as true.
*
* Generic function to setup each queue mapping in @qmap. It will query
* each queue's affinity via @get_queue_affinity and built queue mapping
Expand All @@ -113,7 +115,7 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)
*/
int blk_mq_dev_map_queues(struct blk_mq_queue_map *qmap, void *dev_data,
int dev_off, get_queue_affinty_fn *get_queue_affinity,
bool fallback)
bool fallback, bool managed_irq)
{
const struct cpumask *mask;
unsigned int queue, cpu;
Expand All @@ -136,6 +138,8 @@ int blk_mq_dev_map_queues(struct blk_mq_queue_map *qmap, void *dev_data,
qmap->mq_map[cpu] = qmap->queue_offset + queue;
}

qmap->use_managed_irq = managed_irq;

return 0;

fallback:
Expand Down
5 changes: 3 additions & 2 deletions include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ struct blk_mq_hw_ctx {
struct blk_mq_queue_map {
unsigned int *mq_map;
unsigned int nr_queues;
unsigned int queue_offset;
unsigned int queue_offset:31;
unsigned int use_managed_irq:1;
};

/**
Expand Down Expand Up @@ -556,7 +557,7 @@ typedef const struct cpumask * (get_queue_affinty_fn)(void *dev_data,
int blk_mq_map_queues(struct blk_mq_queue_map *qmap);
int blk_mq_dev_map_queues(struct blk_mq_queue_map *qmap, void *dev_data,
int dev_off, get_queue_affinty_fn *get_queue_affinity,
bool fallback);
bool fallback, bool managed_irq);
void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);

void blk_mq_quiesce_queue_nowait(struct request_queue *q);
Expand Down

0 comments on commit 49f5094

Please sign in to comment.