Skip to content

Commit dabcefa

Browse files
committed
nvme: provide optimized poll function for separate poll queues
If we have separate poll queues, we know that they aren't using interrupts. Hence we don't need to disable interrupts around finding completions. Provide a separate set of blk_mq_ops for such devices. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9334ae5 commit dabcefa

1 file changed

Lines changed: 37 additions & 8 deletions

File tree

‎drivers/nvme/host/pci.c‎

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,23 @@ static int nvme_poll(struct blk_mq_hw_ctx *hctx, unsigned int tag)
10821082
return __nvme_poll(nvmeq, tag);
10831083
}
10841084

1085+
static int nvme_poll_noirq(struct blk_mq_hw_ctx *hctx, unsigned int tag)
1086+
{
1087+
struct nvme_queue *nvmeq = hctx->driver_data;
1088+
u16 start, end;
1089+
bool found;
1090+
1091+
if (!nvme_cqe_pending(nvmeq))
1092+
return 0;
1093+
1094+
spin_lock(&nvmeq->cq_lock);
1095+
found = nvme_process_cq(nvmeq, &start, &end, tag);
1096+
spin_unlock(&nvmeq->cq_lock);
1097+
1098+
nvme_complete_cqes(nvmeq, start, end);
1099+
return found;
1100+
}
1101+
10851102
static void nvme_pci_submit_async_event(struct nvme_ctrl *ctrl)
10861103
{
10871104
struct nvme_dev *dev = to_nvme_dev(ctrl);
@@ -1584,17 +1601,25 @@ static const struct blk_mq_ops nvme_mq_admin_ops = {
15841601
.timeout = nvme_timeout,
15851602
};
15861603

1604+
#define NVME_SHARED_MQ_OPS \
1605+
.queue_rq = nvme_queue_rq, \
1606+
.rq_flags_to_type = nvme_rq_flags_to_type, \
1607+
.complete = nvme_pci_complete_rq, \
1608+
.init_hctx = nvme_init_hctx, \
1609+
.init_request = nvme_init_request, \
1610+
.map_queues = nvme_pci_map_queues, \
1611+
.timeout = nvme_timeout \
1612+
15871613
static const struct blk_mq_ops nvme_mq_ops = {
1588-
.queue_rq = nvme_queue_rq,
1589-
.rq_flags_to_type = nvme_rq_flags_to_type,
1590-
.complete = nvme_pci_complete_rq,
1591-
.init_hctx = nvme_init_hctx,
1592-
.init_request = nvme_init_request,
1593-
.map_queues = nvme_pci_map_queues,
1594-
.timeout = nvme_timeout,
1614+
NVME_SHARED_MQ_OPS,
15951615
.poll = nvme_poll,
15961616
};
15971617

1618+
static const struct blk_mq_ops nvme_mq_poll_noirq_ops = {
1619+
NVME_SHARED_MQ_OPS,
1620+
.poll = nvme_poll_noirq,
1621+
};
1622+
15981623
static void nvme_dev_remove_admin(struct nvme_dev *dev)
15991624
{
16001625
if (dev->ctrl.admin_q && !blk_queue_dying(dev->ctrl.admin_q)) {
@@ -2276,7 +2301,11 @@ static int nvme_dev_add(struct nvme_dev *dev)
22762301
int ret;
22772302

22782303
if (!dev->ctrl.tagset) {
2279-
dev->tagset.ops = &nvme_mq_ops;
2304+
if (!dev->io_queues[NVMEQ_TYPE_POLL])
2305+
dev->tagset.ops = &nvme_mq_ops;
2306+
else
2307+
dev->tagset.ops = &nvme_mq_poll_noirq_ops;
2308+
22802309
dev->tagset.nr_hw_queues = dev->online_queues - 1;
22812310
dev->tagset.nr_maps = NVMEQ_TYPE_NR;
22822311
dev->tagset.timeout = NVME_IO_TIMEOUT;

0 commit comments

Comments
 (0)