[RFC PATCH 5/5] nvme-loop: reduce blk_rq_nr_phys_segments calls
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Mon Jul 6 19:15:24 EDT 2020
In the fast path blk_rq_nr_phys_segments() is called twice for
nvme-loop. The function blk_rq_nr_phys_segments() adds a if check for
special payload. The same check gets repeated number of times we call
the function in the fast path.
In order to minimize repetitive check in the fast path this patch
reduces the number of calls to one and adjust the code in submission
path.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
drivers/nvme/target/loop.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 6e8d14a8227c..b5a93b9db783 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -130,6 +130,7 @@ static void nvme_loop_execute_work(struct work_struct *work)
static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
const struct blk_mq_queue_data *bd)
{
+ unsigned short nseg = blk_rq_nr_phys_segments(bd->rq);
struct nvme_ns *ns = hctx->queue->queuedata;
struct nvme_loop_queue *queue = hctx->driver_data;
struct request *req = bd->rq;
@@ -151,10 +152,9 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
&queue->nvme_sq, &nvme_loop_ops))
return BLK_STS_OK;
- if (blk_rq_nr_phys_segments(req)) {
+ if (nseg) {
iod->sg_table.sgl = iod->first_sgl;
- if (sg_alloc_table_chained(&iod->sg_table,
- blk_rq_nr_phys_segments(req),
+ if (sg_alloc_table_chained(&iod->sg_table, nseg,
iod->sg_table.sgl, NVME_INLINE_SG_CNT)) {
nvme_cleanup_cmd(req);
return BLK_STS_RESOURCE;
--
2.22.0
More information about the Linux-nvme
mailing list