Skip to contentSkip to conversation

dm-mpath: improve I/O schedule

PATCH NAK Ming Lei 4 participants 36 messages Sep 15, 2017 – Sep 20, 2017

Subsystems (5)
SCSI Block layer Device mapper NVMe +1 more subsystems
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

cover dm-mpath: improve I/O schedule

Hi,

We depend on I/O scheduler in dm-mpath layer, and underlying I/O scheduler is bypassed basically.

I/O scheduler depends on queue busy condition to trigger I/O merge, unfortunatley inside dm-mpath, the underlying queue busy feedback is not accurate enough, and we just allocate one request and dispatcch it out to underlying queue, no matter if that queue is busy or not. Then I/O merge is hard to trigger.

This patchset sets underlying queue's nr_request as the queue's queue depth, so that queue busy is figured out by checking if request is allocated successfully.

From test result on mq-deadline, sequential I/O performance is improved a lot, see test result in patch 5's commit log.

Any comments are welcome!

Thanks,
Ming

Ming Lei (5):
block: don't call blk_mq_delay_run_hw_queue() in case of
BLK_STS_RESOURCE
dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure
dm-mpath: remove annoying message of 'blk_get_request() returned -11'
block: export blk_update_nr_requests
dm-mpath: improve I/O schedule

 block/blk-core.c        |  4 +++-
 block/blk-sysfs.c       |  5 +----
 block/blk.h             |  2 --
 drivers/md/dm-mpath.c   | 30 +++++++++++++++++++++++++++---
 drivers/md/dm-rq.c      |  1 -
 drivers/nvme/host/fc.c  |  3 ---
 drivers/scsi/scsi_lib.c |  4 ----
 include/linux/blkdev.h  |  1 +
 8 files changed, 32 insertions(+), 18 deletions(-)
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH 1/5 block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

If .queue_rq() returns BLK_STS_RESOURCE, blk-mq will rerun the queue in the three situations:

1) if BLK_MQ_S_SCHED_RESTART is set
- queue is rerun after one rq is completed, see blk_mq_sched_restart() which is run from blk_mq_free_request()

2) BLK_MQ_S_TAG_WAITING is set
- queue is rerun after one tag is freed

3) otherwise
- queue is run immediately in blk_mq_dispatch_rq_list()

So calling blk_mq_delay_run_hw_queue() inside .queue_rq() doesn't make sense because no matter it is called or not, the queue still will be rerun soon in above three situations, and the busy req can be dispatched again.

Cc Mike Snitzer <[email protected]>
Cc Sagi Grimberg <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
---
 drivers/md/dm-rq.c      | 1 -
 drivers/nvme/host/fc.c  | 3 ---
 drivers/scsi/scsi_lib.c | 4 ----
 3 files changed, 8 deletions(-)
drivers/md/dm-rq.c +0 -1
index c6ebc5b1e00e..71422cea1c4a 100644
@@ -761,7 +761,6 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
 		/* Undo dm_start_request() before requeuing */
 		rq_end_stats(md, rq);
 		rq_completed(md, rq_data_dir(rq), false);
-		blk_mq_delay_run_hw_queue(hctx, 100/*ms*/);
 		return BLK_STS_RESOURCE;
 	}
 
drivers/nvme/host/fc.c +0 -3
index d2e882c0f496..17727eee5d5f 100644
@@ -2041,9 +2041,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
 	return BLK_STS_OK;
 
 busy:
-	if (!(op->flags & FCOP_FLAGS_AEN) && queue->hctx)
-		blk_mq_delay_run_hw_queue(queue->hctx, NVMEFC_QUEUE_DELAY);
-
 	return BLK_STS_RESOURCE;
 }
 
drivers/scsi/scsi_lib.c +0 -4
index 9cf6a80fe297..71d5bf1345c9 100644
@@ -2010,11 +2010,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 out:
 	switch (ret) {
 	case BLK_STS_OK:
-		break;
 	case BLK_STS_RESOURCE:
-		if (atomic_read(&sdev->device_busy) == 0 &&
-		    !scsi_device_blocked(sdev))
-			blk_mq_delay_run_hw_queue(hctx, SCSI_QUEUE_DELAY);
 		break;
 	default:
 		/*
Signature · 1 line
2.9.5
author
#21 lore raw

PATCH 2/5 dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +1 -1
index 96aedaac2c64..f5a1088a6e79 100644
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;
Signature · 1 line
2.9.5
author
#29 lore raw

PATCH 3/5 dm-mpath: remove annoying message of 'blk_get_request() returned -11'

In reply to Ming Lei

It is very normal to see allocation failure, so not necessary to dump it and annoy people.

---
 drivers/md/dm-mpath.c | 2 --
 1 file changed, 2 deletions(-)
drivers/md/dm-mpath.c +0 -2
index f5a1088a6e79..f57ad8621c4c 100644
@@ -499,8 +499,6 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 	if (IS_ERR(clone)) {
 		/* EBUSY, ENODEV or EWOULDBLOCK: requeue */
 		bool queue_dying = blk_queue_dying(q);
-		DMERR_LIMIT("blk_get_request() returned %ld%s - requeuing",
-			    PTR_ERR(clone), queue_dying ? " (path offline)" : "");
 		if (queue_dying) {
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
Signature · 1 line
2.9.5
author
#30 lore raw

PATCH 4/5 block: export blk_update_nr_requests

In reply to Ming Lei

dm-mpath need this API for improving IO scheduling.

The IO schedule is actually done on dm-rq(mpath) queue, instead of underlying devices.

If we set q->nr_requests as q->queue_depth on underlying devices, we can get the queue's busy feedback by simply checking if blk_get_request() returns successfully.

This way will make block layer's I/O schedule more effective on dm-rq device.

---
 block/blk-core.c       | 4 +++-
 block/blk-sysfs.c      | 5 +----
 block/blk.h            | 2 --
 include/linux/blkdev.h | 1 +
 4 files changed, 5 insertions(+), 7 deletions(-)
block/blk-core.c +3 -1
index aebe676225e6..9752aac9821c 100644
@@ -1108,7 +1108,8 @@ int blk_update_nr_requests(struct request_queue *q, unsigned int nr)
 	struct request_list *rl;
 	int on_thresh, off_thresh;
 
-	WARN_ON_ONCE(q->mq_ops);
+	if (q->mq_ops)
+		return blk_mq_update_nr_requests(q, nr);
 
 	spin_lock_irq(q->queue_lock);
 	q->nr_requests = nr;
@@ -1145,6 +1146,7 @@ int blk_update_nr_requests(struct request_queue *q, unsigned int nr)
 	spin_unlock_irq(q->queue_lock);
 	return 0;
 }
+EXPORT_SYMBOL(blk_update_nr_requests);
 
 /**
  * __get_request - get a free request
block/blk-sysfs.c +1 -4
index b8362c0df51d..2dbef5dbd195 100644
@@ -77,10 +77,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count)
 	if (nr < BLKDEV_MIN_RQ)
 		nr = BLKDEV_MIN_RQ;
 
-	if (q->request_fn)
-		err = blk_update_nr_requests(q, nr);
-	else
-		err = blk_mq_update_nr_requests(q, nr);
+	err = blk_update_nr_requests(q, nr);
 
 	if (err)
 		return err;
block/blk.h +0 -2
index fa4f232afc18..5bf662da2417 100644
@@ -308,8 +308,6 @@ static inline int queue_congestion_off_threshold(struct request_queue *q)
 	return q->nr_congestion_off;
 }
 
-extern int blk_update_nr_requests(struct request_queue *, unsigned int);
-
 /*
  * Contribute to IO statistics IFF:
  *
include/linux/blkdev.h +1 -0
index 460294bb0fa5..226b97142999 100644
@@ -1229,6 +1229,7 @@ struct request_queue *blk_alloc_queue(gfp_t);
 struct request_queue *blk_alloc_queue_node(gfp_t, int);
 extern void blk_put_queue(struct request_queue *);
 extern void blk_set_queue_dying(struct request_queue *);
+extern int blk_update_nr_requests(struct request_queue *, unsigned int);
 
 /*
  * block layer runtime pm functions
Signature · 1 line
2.9.5
author
#31 lore raw

PATCH 5/5 dm-mpath: improve I/O schedule

In reply to Ming Lei

The actual I/O schedule is done in dm-mpath layer, and the underlying I/O schedule is simply bypassed.

This patch sets underlying queue's nr_requests as its queue's queue_depth, then we can get its queue busy feedback by simply checking if blk_get_request() returns successfully.

In this way, dm-mpath can reports its queue busy to block layer effectively, so I/O scheduling is improved much.

Follows the test results on lpfc*:

- fio(libaio, bs:4k, dio, queue_depth:64, 64 jobs, over dm-mpath disk)
- system(12 cores, dual sockets, mem: 64G)

---------------------------------------

          |v4.13+         |v4.13+
          |+scsi_mq_perf  |+scsi_mq_perf+patches

-----------------------------------------
IOPS(K) |MQ-DEADLINE |MQ-DEADLINE
------------------------------------------
read | 30.71 | 343.91
-----------------------------------------
randread | 22.98 | 17.17
------------------------------------------
write | 16.45 | 390.88
------------------------------------------
randwrite | 16.21 | 16.09
---------------------------------------

*:
1) lpfc.lpfc_lun_queue_depth=3, so that it is same with .cmd_per_lun
2) scsi_mq_perf means the patchset of 'blk-mq-sched: improve SCSI-MQ performance(V4)'[1]
3) v4.13+: top commit is 46c1e79fee41 Merge branch 'perf-urgent-for-linus'
4) the patchset 'blk-mq-sched: improve SCSI-MQ performance(V4)' focuses
on improving on SCSI-MQ, and all the test result in that coverletter was against the raw lpfc/ib(run after 'multipath -F'), instead of dm-mpath.
5) this patchset itself doesn't depend on the scsi_mq_perf patchset[1]

[1] https://marc.info/?t=150436555700002&r=1&w=2

---
 drivers/md/dm-mpath.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/md/dm-mpath.c +26 -0
index f57ad8621c4c..02647386d2d9 100644
@@ -39,6 +39,8 @@ struct pgpath {
 
 	struct dm_path path;
 	struct delayed_work activate_path;
+	unsigned old_nr_requests;
+	unsigned queue_depth;
 
 	bool is_active:1;		/* Path status */
 };
@@ -160,12 +162,34 @@ static struct priority_group *alloc_priority_group(void)
 	return pg;
 }
 
+static void save_path_queue_depth(struct pgpath *p)
+{
+	struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+
+	p->old_nr_requests = q->nr_requests;
+	p->queue_depth = q->queue_depth;
+
+	/* one extra request for making the pipeline full */
+	if (p->queue_depth)
+		blk_update_nr_requests(q, p->queue_depth + 1);
+}
+
+static void restore_path_queue_depth(struct pgpath *p)
+{
+	struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+
+	/* nr->requests isn't changed, we restore to old value */
+	if (q->nr_requests == p->queue_depth + 1)
+		blk_update_nr_requests(q, p->old_nr_requests);
+}
+
 static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
 {
 	struct pgpath *pgpath, *tmp;
 
 	list_for_each_entry_safe(pgpath, tmp, pgpaths, list) {
 		list_del(&pgpath->list);
+		restore_path_queue_depth(pgpath);
 		dm_put_device(ti, pgpath->path.dev);
 		free_pgpath(pgpath);
 	}
@@ -810,6 +834,8 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 		goto bad;
 	}
 
+	save_path_queue_depth(p);
+
 	return p;
 
  bad:
Signature · 1 line
2.9.5
#22 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Ming Lei
Quoted 14 lines · Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 96aedaac2c64..f5a1088a6e79 100644

drivers/md/dm-mpath.c static int multipath_clone_and_map(struct dm_target *ti, struct request *rq, · line 511

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;

So you are reverting the patch below? Thank you very much.

commit 1c23484c355ec360ca2f37914f8a4802c6baeead

Author: Bart Van Assche <[email protected]>
Date:   Wed Aug 9 11:32:12 2017 -0700

dm mpath: do not lock up a CPU with requeuing activity

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

Fixes 7083abbbf ("dm mpath: avoid that path removal can trigger an infinite loop")
#2 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Ming Lei
Quoted 10 lines · Ming Lei

If .queue_rq() returns BLK_STS_RESOURCE, blk-mq will rerun the queue in the three situations:

1) if BLK_MQ_S_SCHED_RESTART is set
- queue is rerun after one rq is completed, see blk_mq_sched_restart() which is run from blk_mq_free_request()

2) BLK_MQ_S_TAG_WAITING is set
- queue is rerun after one tag is freed

Quoted 7 lines

3) otherwise
- queue is run immediately in blk_mq_dispatch_rq_list()

So calling blk_mq_delay_run_hw_queue() inside .queue_rq() doesn't make sense because no matter it is called or not, the queue still will be rerun soon in above three situations, and the busy req can be dispatched again.

NAK

Block drivers call blk_mq_delay_run_hw_queue() if it is known that the queue has to be rerun later even if no request has completed before the delay has expired. This patch breaks at least the SCSI core and the dm-mpath drivers.

Bart.

#23 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Bart Van Assche
Quoted 38 lines · Bart Van Assche
Quoted 14 lines · Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 96aedaac2c64..f5a1088a6e79 100644

drivers/md/dm-mpath.c static int multipath_clone_and_map(struct dm_target *ti, struct request *rq, · line 511

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;

So you are reverting the patch below? Thank you very much.

commit 1c23484c355ec360ca2f37914f8a4802c6baeead

Author: Bart Van Assche <[email protected]>
Date:   Wed Aug 9 11:32:12 2017 -0700

dm mpath: do not lock up a CPU with requeuing activity

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

Quoted 6 lines
Fixes 7083abbbf ("dm mpath: avoid that path removal can trigger an infinite loop")

The problem is that multipath_clone_and_map() is now treated as common code (thanks to both blk-mq and old .request_fn now enjoying the use of blk_get_request) BUT: Ming please understand that this code is used by old .request_fn too. So it would seem that the use of DM_MAPIO_DELAY_REQUEUE vs DM_MAPIO_REQUEUE needs to be based on dm-sq vs dm-mq.

#32 lore raw
In reply to Ming Lei
Quoted 40 lines · Ming Lei

The actual I/O schedule is done in dm-mpath layer, and the underlying I/O schedule is simply bypassed.

This patch sets underlying queue's nr_requests as its queue's queue_depth, then we can get its queue busy feedback by simply checking if blk_get_request() returns successfully.

In this way, dm-mpath can reports its queue busy to block layer effectively, so I/O scheduling is improved much.

Follows the test results on lpfc*:

- fio(libaio, bs:4k, dio, queue_depth:64, 64 jobs, over dm-mpath disk)
- system(12 cores, dual sockets, mem: 64G)

---------------------------------------

          |v4.13+         |v4.13+
          |+scsi_mq_perf  |+scsi_mq_perf+patches

-----------------------------------------
IOPS(K) |MQ-DEADLINE |MQ-DEADLINE
------------------------------------------
read | 30.71 | 343.91
-----------------------------------------
randread | 22.98 | 17.17
------------------------------------------
write | 16.45 | 390.88
------------------------------------------
randwrite | 16.21 | 16.09
---------------------------------------

*:
1) lpfc.lpfc_lun_queue_depth=3, so that it is same with .cmd_per_lun
2) scsi_mq_perf means the patchset of 'blk-mq-sched: improve SCSI-MQ performance(V4)'[1]
3) v4.13+: top commit is 46c1e79fee41 Merge branch 'perf-urgent-for-linus'
4) the patchset 'blk-mq-sched: improve SCSI-MQ performance(V4)' focuses
on improving on SCSI-MQ, and all the test result in that coverletter was against the raw lpfc/ib(run after 'multipath -F'), instead of dm-mpath.
5) this patchset itself doesn't depend on the scsi_mq_perf patchset[1]

Quoted 3 lines

[1] https://marc.info/?t=150436555700002&r=1&w=2

Very impressive gains Ming!

I'll review in more detail next week but Bart's concerns on patch 1 and 2 definitely need consideration.

Thanks,
Mike

#24 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Mike Snitzer
Quoted 6 lines · Mike Snitzer

The problem is that multipath_clone_and_map() is now treated as common code (thanks to both blk-mq and old .request_fn now enjoying the use of blk_get_request) BUT: Ming please understand that this code is used by old .request_fn too. So it would seem that the use of DM_MAPIO_DELAY_REQUEUE vs DM_MAPIO_REQUEUE needs to be based on dm-sq vs dm-mq.

Hello Mike,

My proposal is to leave out patches 1 and 2 entirely. Since the SCSI core calls blk_mq_run_hw_queues() anyway after a request has finished it is not clear to me what the motivation was behind the development of patches 1 and 2 in this series. If the goal was to rerun a queue after a request has finished I think the same approach should be taken for dm as for the SCSI core, namely to run the queue from inside the end_io callback.

Bart.

#33 lore raw
In reply to Ming Lei
Quoted 14 lines · Ming Lei

---------------------------------------

          |v4.13+         |v4.13+
          |+scsi_mq_perf  |+scsi_mq_perf+patches

-----------------------------------------
IOPS(K) |MQ-DEADLINE |MQ-DEADLINE
------------------------------------------
read | 30.71 | 343.91
-----------------------------------------
randread | 22.98 | 17.17
------------------------------------------
write | 16.45 | 390.88
------------------------------------------
randwrite | 16.21 | 16.09
---------------------------------------

What is the reason for the random I/O performance regressions? Users whose workload triggers a random I/O pattern will be really unhappy with a 33% IOPS regression for random reads. Does that regression get worse for lower latency transports, e.g. SRP?

Bart.

#34 lore raw
In reply to Ming Lei
Quoted 1 line · Ming Lei

1) lpfc.lpfc_lun_queue_depth=3, so that it is same with .cmd_per_lun

Nobody I know uses such a low queue depth for the lpfc driver. Please also include performance results for a more realistic queue depth.

Thanks,

Bart.

#35 lore raw
In reply to Ming Lei

drivers/md/dm-mpath.c static struct priority_group *alloc_priority_group(void) · line 175

Quoted 11 lines · Ming Lei
drivers/md/dm-mpath.c +11 -0
+static void save_path_queue_depth(struct pgpath *p)
+{
+	struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+
+	p->old_nr_requests = q->nr_requests;
+	p->queue_depth = q->queue_depth;
+
+	/* one extra request for making the pipeline full */
+	if (p->queue_depth)
+		blk_update_nr_requests(q, p->queue_depth + 1);
+}

blk_mq_init_allocated_queue() initializes nr_requests to the tag set queue depth. Does that mean that the above code increases nr_requests by one? If so, does that change only result in a performance improvement for the queue depth mentioned in the path description (3)? Sorry but I doubt that this change will yield a significant improvement for higher queue depths. Does that mean that this patch can be left out?

Thanks,

Bart.

author
#3 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Bart Van Assche
Quoted 19 lines · Bart Van Assche
Quoted 10 lines · Ming Lei

If .queue_rq() returns BLK_STS_RESOURCE, blk-mq will rerun the queue in the three situations:

1) if BLK_MQ_S_SCHED_RESTART is set
- queue is rerun after one rq is completed, see blk_mq_sched_restart() which is run from blk_mq_free_request()

2) BLK_MQ_S_TAG_WAITING is set
- queue is rerun after one tag is freed

Quoted 7 lines

3) otherwise
- queue is run immediately in blk_mq_dispatch_rq_list()

So calling blk_mq_delay_run_hw_queue() inside .queue_rq() doesn't make sense because no matter it is called or not, the queue still will be rerun soon in above three situations, and the busy req can be dispatched again.

Quoted 5 lines

NAK

Block drivers call blk_mq_delay_run_hw_queue() if it is known that the queue has to be rerun later even if no request has completed before the delay has expired. This patch breaks at least the SCSI core and the dm-mpath drivers.

"if no request has completed before the delay has expired" can't be a reason to rerun the queue, because the queue can still be busy.

The only reason is that there isn't any requests in-flight and queue is still busy, but I'd rather understand what the exact situation is, instead of using this kind of workaround. If no such situation, we should remove that.

For SCSI, it might be reasonable to run the hw queue after a random time when atomic_read(&sdev->device_busy) is zero, that means the queue may be busy even when there isn't any requests in-flight in this queue. Could you or someone share what the case is? Then we can avoid to use this workaround.

For dm-mpath, it might be related with path, but I have to say it is still a workaround.

I suggest to understand the root cause, instead of keeping this ugly random delay because run hw queue after 100ms may be useless in 99.99% times.

Signature · 1 line
Ming
author
#28 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Bart Van Assche
Quoted 30 lines · Bart Van Assche
Quoted 14 lines · Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 96aedaac2c64..f5a1088a6e79 100644

drivers/md/dm-mpath.c static int multipath_clone_and_map(struct dm_target *ti, struct request *rq, · line 511

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;

So you are reverting the patch below? Thank you very much.

commit 1c23484c355ec360ca2f37914f8a4802c6baeead

Author: Bart Van Assche <[email protected]>
Date:   Wed Aug 9 11:32:12 2017 -0700
Quoted 7 lines

dm mpath: do not lock up a CPU with requeuing activity

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

What is the continuous requeuing activity? In case of BLK_STS_RESOURCE, blk-mq's SCHED_RESTART(see blk_mq_sched_dispatch_requests()) will be triggered, then this rq will be dispatched again after one rq is completed.

Signature · 1 line
Ming
author
#25 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Mike Snitzer
Quoted 48 lines · Mike Snitzer
Quoted 38 lines · Bart Van Assche
Quoted 14 lines · Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 96aedaac2c64..f5a1088a6e79 100644

drivers/md/dm-mpath.c static int multipath_clone_and_map(struct dm_target *ti, struct request *rq, · line 511

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;

So you are reverting the patch below? Thank you very much.

commit 1c23484c355ec360ca2f37914f8a4802c6baeead

Author: Bart Van Assche <[email protected]>
Date:   Wed Aug 9 11:32:12 2017 -0700

dm mpath: do not lock up a CPU with requeuing activity

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

Quoted 6 lines
Fixes 7083abbbf ("dm mpath: avoid that path removal can trigger an infinite loop")
Quoted 4 lines

The problem is that multipath_clone_and_map() is now treated as common code (thanks to both blk-mq and old .request_fn now enjoying the use of blk_get_request) BUT: Ming please understand that this code is used by old .request_fn too. So it would seem that the use of

Hi Mike,

OK, thanks for pointing this out.

Quoted 2 lines

DM_MAPIO_DELAY_REQUEUE vs DM_MAPIO_REQUEUE needs to be based on dm-sq vs dm-mq.

Yeah, just forget that dm-mq can't work on underlying queue which is block legacy path, also forget the exact reason, :-(

Signature · 1 line
Ming
#4 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Ming Lei
Quoted 2 lines · Ming Lei

"if no request has completed before the delay has expired" can't be a reason to rerun the queue, because the queue can still be busy.

That statement of you shows that there are important aspects of the SCSI core and dm-mpath driver that you don't understand.

Quoted 3 lines

I suggest to understand the root cause, instead of keeping this ugly random delay because run hw queue after 100ms may be useless in 99.99% times.

If you are still looking at removing the blk_mq_delay_run_hw_queue() calls then I think you are looking in the wrong direction. What kind of problem are you trying to solve? Is it perhaps that there can be a delay between dm-mpath request completion and the queueing of a new request? If so, adding a queue run call into the dm-mpath end_io callback is probably sufficient and probably can replace this entire patch series.

Bart.

author
#5 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

"if no request has completed before the delay has expired" can't be a reason to rerun the queue, because the queue can still be busy.

That statement of you shows that there are important aspects of the SCSI core and dm-mpath driver that you don't understand.

Then can you tell me why blk-mq's SCHED_RESTART can't cover the rerun when there are in-flight requests? What is the case in which dm-rq can return BUSY and there aren't any in-flight requests meantime?

Also you are the author of adding 'blk_mq_delay_run_hw_queue( hctx, 100/*ms*/)' in dm-rq, you never explain in commit 6077c2d706097c0(dm rq: Avoid that request processing stalls sporadically) what the root cause is for your request stall and why this patch fixes your issue. Even you don't explain why is the delay 100ms?

So it is a workaound, isn't it?

My concern is that it isn't good to add blk_mq_delay_run_hw_queue(hctx, 100/*ms*/) in the hot path since it should been covered by SCHED_RESTART
if there are in-flight requests.

Quoted 8 lines
Quoted 4 lines

I suggest to understand the root cause, instead of keeping this ugly random delay because run hw queue after 100ms may be useless in 99.99% times.

If you are still looking at removing the blk_mq_delay_run_hw_queue() calls then I think you are looking in the wrong direction. What kind of problem are you trying to solve? Is it perhaps that there can be a delay between

Actually the improvement on dm-rq IO schedule(the patch 2 ~ 5) doesn't need this patch.

Signature · 1 line
Ming
#26 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Ming Lei
Quoted 56 lines · Ming Lei
Quoted 48 lines · Mike Snitzer
Quoted 38 lines · Bart Van Assche
Quoted 14 lines · Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 96aedaac2c64..f5a1088a6e79 100644

drivers/md/dm-mpath.c static int multipath_clone_and_map(struct dm_target *ti, struct request *rq, · line 511

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;

So you are reverting the patch below? Thank you very much.

commit 1c23484c355ec360ca2f37914f8a4802c6baeead

Author: Bart Van Assche <[email protected]>
Date:   Wed Aug 9 11:32:12 2017 -0700

dm mpath: do not lock up a CPU with requeuing activity

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

Quoted 6 lines
Fixes 7083abbbf ("dm mpath: avoid that path removal can trigger an infinite loop")
Quoted 4 lines

The problem is that multipath_clone_and_map() is now treated as common code (thanks to both blk-mq and old .request_fn now enjoying the use of blk_get_request) BUT: Ming please understand that this code is used by old .request_fn too. So it would seem that the use of

Hi Mike,

Quoted 7 lines

OK, thanks for pointing this out.

Quoted 2 lines

DM_MAPIO_DELAY_REQUEUE vs DM_MAPIO_REQUEUE needs to be based on dm-sq vs dm-mq.

Yeah, just forget that dm-mq can't work on underlying queue which is block legacy path, also forget the exact reason, :-(

Not sure how that detail is relevant to your patch?

But here are the 2 patches I posted as RFC to eliminate the restriction:
https://patchwork.kernel.org/patch/9839565/
https://patchwork.kernel.org/patch/9839567/

In the end I'm not too interested in supporting blk-mq multipath ontop of block legacy path. But I'd revisit if hch or someone else posted the blk-mq patch that "removed the ->complete handler" (as hch mentions in the thread of the first patchwork patch I reference above).

Mike

#6 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Ming Lei
Quoted 7 lines · Ming Lei
Quoted 3 lines · Bart Van Assche

If you are still looking at removing the blk_mq_delay_run_hw_queue() calls then I think you are looking in the wrong direction. What kind of problem are you trying to solve? Is it perhaps that there can be a delay between

Actually the improvement on dm-rq IO schedule(the patch 2 ~ 5) doesn't need this patch.

The approach of this patch series looks wrong to me and patch 5/5 is an ugly hack in my opinion. That's why I asked you to drop the entire patch series and to test whether inserting a queue run call into the dm-mpath end_io callback yields a similar performance improvement to the patches you posted. Please do not expect me to spend more time on this patch series if you do not come up with measurement results for the proposed alternative.

Bart.

#17 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Ming Lei
Quoted 20 lines · Ming Lei
Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

"if no request has completed before the delay has expired" can't be a reason to rerun the queue, because the queue can still be busy.

That statement of you shows that there are important aspects of the SCSI core and dm-mpath driver that you don't understand.

Then can you tell me why blk-mq's SCHED_RESTART can't cover the rerun when there are in-flight requests? What is the case in which dm-rq can return BUSY and there aren't any in-flight requests meantime?

Also you are the author of adding 'blk_mq_delay_run_hw_queue( hctx, 100/*ms*/)' in dm-rq, you never explain in commit 6077c2d706097c0(dm rq: Avoid that request processing stalls sporadically) what the root cause is for your request stall and why this patch fixes your issue. Even you don't explain why is the delay 100ms?

Quoted 5 lines

So it is a workaound, isn't it?

My concern is that it isn't good to add blk_mq_delay_run_hw_queue(hctx, 100/*ms*/) in the hot path since it should been covered by SCHED_RESTART
if there are in-flight requests.

This thread proves that it is definitely brittle to be relying on fixed delays like this:
https://patchwork.kernel.org/patch/9703249/

Mike

#18 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 3 lines · Mike Snitzer

This thread proves that it is definitely brittle to be relying on fixed delays like this:
https://patchwork.kernel.org/patch/9703249/

Hello Mike,

Sorry but I think that's a misinterpretation of my patch. I came up with that patch before I had found and fixed the root cause of the high system load. These fixes are upstream (kernel v4.13) which means that that patch is now obsolete.

Bart.

#7 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche
Quoted 7 lines · Ming Lei
Quoted 3 lines · Bart Van Assche

If you are still looking at removing the blk_mq_delay_run_hw_queue() calls then I think you are looking in the wrong direction. What kind of problem are you trying to solve? Is it perhaps that there can be a delay between

Actually the improvement on dm-rq IO schedule(the patch 2 ~ 5) doesn't need this patch.

Quoted 6 lines

The approach of this patch series looks wrong to me and patch 5/5 is an ugly hack in my opinion. That's why I asked you to drop the entire patch series and to test whether inserting a queue run call into the dm-mpath end_io callback yields a similar performance improvement to the patches you posted. Please do not expect me to spend more time on this patch series if you do not come up with measurement results for the proposed alternative.

Bart, asserting that Ming's work is a hack doesn't help your apparent goal of deligitimizing Ming's work.

Nor does it take away from the fact that your indecision on appropriate timeouts (let alone ability to defend and/or explain them) validates Ming calling them into question (which you are now dodging regularly).

But please don't take this feedback and shut-down. Instead please work together more constructively. This doesn't need to be adversarial! I am at a loss for why there is such animosity from your end Bart.

Please dial it back. It is just a distraction that fosters needless in-fighting.

Believe it or not: Ming is just trying to improve the code because he has a testbed that is showing fairly abysmal performance with dm-mq multipath (on lpfc with scsi-mq).

Ming, if you can: please see if what Bart has proposed (instead: run queue at end_io) helps. Though I don't yet see why that should be needed.

Mike

author
#27 lore raw

Re: [PATCH 2/5] dm-mpath: return DM_MAPIO_REQUEUE in case of rq allocation failure

In reply to Mike Snitzer
Quoted 64 lines · Mike Snitzer
Quoted 61 lines · Ming Lei
Quoted 48 lines · Mike Snitzer
Quoted 38 lines · Bart Van Assche
Quoted 14 lines · Ming Lei

blk-mq will rerun queue via RESTART after one request is completion, so not necessary to wait random time for requeuing, it should trust blk-mq to do it.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 96aedaac2c64..f5a1088a6e79 100644

drivers/md/dm-mpath.c static int multipath_clone_and_map(struct dm_target *ti, struct request *rq, · line 511

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -505,7 +505,7 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
 		}
-		return DM_MAPIO_DELAY_REQUEUE;
+		return DM_MAPIO_REQUEUE;
 	}
 	clone->bio = clone->biotail = NULL;
 	clone->rq_disk = bdev->bd_disk;

So you are reverting the patch below? Thank you very much.

commit 1c23484c355ec360ca2f37914f8a4802c6baeead

Author: Bart Van Assche <[email protected]>
Date:   Wed Aug 9 11:32:12 2017 -0700

dm mpath: do not lock up a CPU with requeuing activity

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

Quoted 6 lines
Fixes 7083abbbf ("dm mpath: avoid that path removal can trigger an infinite loop")
Quoted 4 lines

The problem is that multipath_clone_and_map() is now treated as common code (thanks to both blk-mq and old .request_fn now enjoying the use of blk_get_request) BUT: Ming please understand that this code is used by old .request_fn too. So it would seem that the use of

Hi Mike,

OK, thanks for pointing this out.

Quoted 2 lines

DM_MAPIO_DELAY_REQUEUE vs DM_MAPIO_REQUEUE needs to be based on dm-sq vs dm-mq.

Quoted 8 lines
Quoted 2 lines

Yeah, just forget that dm-mq can't work on underlying queue which is block legacy path, also forget the exact reason, :-(

Not sure how that detail is relevant to your patch?

But here are the 2 patches I posted as RFC to eliminate the restriction:
https://patchwork.kernel.org/patch/9839565/
https://patchwork.kernel.org/patch/9839567/

Thanks for the posting.

Quoted 5 lines

In the end I'm not too interested in supporting blk-mq multipath ontop of block legacy path. But I'd revisit if hch or someone else posted the blk-mq patch that "removed the ->complete handler" (as hch mentions in the thread of the first patchwork patch I reference above).

If blk-mq mpath can be ontop of both block legacy and blk-mq, the legacy .request_fn can be removed from dm mpath, that can be a big simplification, especially the global parameter of use_blk_mq may exist for a bit long.

Signature · 1 line
Ming
#19 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Bart Van Assche
Quoted 11 lines · Bart Van Assche
Quoted 3 lines · Mike Snitzer

This thread proves that it is definitely brittle to be relying on fixed delays like this:
https://patchwork.kernel.org/patch/9703249/

Hello Mike,

Sorry but I think that's a misinterpretation of my patch. I came up with that patch before I had found and fixed the root cause of the high system load. These fixes are upstream (kernel v4.13) which means that that patch is now obsolete.

OK, fair point.

Though fixed magic values for delay aren't going to stand the test of time.

author
#8 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Mike Snitzer
Quoted 33 lines · Mike Snitzer
Quoted 9 lines · Bart Van Assche
Quoted 7 lines · Ming Lei
Quoted 3 lines · Bart Van Assche

If you are still looking at removing the blk_mq_delay_run_hw_queue() calls then I think you are looking in the wrong direction. What kind of problem are you trying to solve? Is it perhaps that there can be a delay between

Actually the improvement on dm-rq IO schedule(the patch 2 ~ 5) doesn't need this patch.

Quoted 6 lines

The approach of this patch series looks wrong to me and patch 5/5 is an ugly hack in my opinion. That's why I asked you to drop the entire patch series and to test whether inserting a queue run call into the dm-mpath end_io callback yields a similar performance improvement to the patches you posted. Please do not expect me to spend more time on this patch series if you do not come up with measurement results for the proposed alternative.

Bart, asserting that Ming's work is a hack doesn't help your apparent goal of deligitimizing Ming's work.

Nor does it take away from the fact that your indecision on appropriate timeouts (let alone ability to defend and/or explain them) validates Ming calling them into question (which you are now dodging regularly).

But please don't take this feedback and shut-down. Instead please work together more constructively. This doesn't need to be adversarial! I am at a loss for why there is such animosity from your end Bart.

Please dial it back. It is just a distraction that fosters needless in-fighting.

Quoted 7 lines

Believe it or not: Ming is just trying to improve the code because he has a testbed that is showing fairly abysmal performance with dm-mq multipath (on lpfc with scsi-mq).

Ming, if you can: please see if what Bart has proposed (instead: run queue at end_io) helps. Though I don't yet see why that should be needed.

Run queue at end_io is definitely wrong, because blk-mq has SCHED_RESTART to do that already.

The dm-mpath performance issue is nothing to do with that, actually the issue is very similar with my improvement on SCSI-MQ, because now dm_dispatch_clone_request() doesn't know if the underlying queue is busy or not, and dm-rq/mpath is just trying to dispatch more request to underlying queue even though it is busy, then IO merge can't be done easily on dm-rq/mpath.

I am thinking another way to improve this issue, since some SCSI device's queue_depth is different with .cmd_per_lun, will post patchset soon.

Signature · 1 line
Ming
author
#20 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Mike Snitzer
Quoted 25 lines · Mike Snitzer
Quoted 22 lines · Ming Lei
Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

"if no request has completed before the delay has expired" can't be a reason to rerun the queue, because the queue can still be busy.

That statement of you shows that there are important aspects of the SCSI core and dm-mpath driver that you don't understand.

Then can you tell me why blk-mq's SCHED_RESTART can't cover the rerun when there are in-flight requests? What is the case in which dm-rq can return BUSY and there aren't any in-flight requests meantime?

Also you are the author of adding 'blk_mq_delay_run_hw_queue( hctx, 100/*ms*/)' in dm-rq, you never explain in commit 6077c2d706097c0(dm rq: Avoid that request processing stalls sporadically) what the root cause is for your request stall and why this patch fixes your issue. Even you don't explain why is the delay 100ms?

So it is a workaound, isn't it?

Quoted 7 lines
Quoted 3 lines

My concern is that it isn't good to add blk_mq_delay_run_hw_queue(hctx, 100/*ms*/) in the hot path since it should been covered by SCHED_RESTART
if there are in-flight requests.

This thread proves that it is definitely brittle to be relying on fixed delays like this:
https://patchwork.kernel.org/patch/9703249/

I can't agree more, because no one mentioned the root cause, maybe the request stall has been fixed recently. Keeping the workaound in hotpath is a bit annoying.

Signature · 1 line
Ming
#9 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Ming Lei
Quoted 2 lines · Ming Lei

Run queue at end_io is definitely wrong, because blk-mq has SCHED_RESTART to do that already.

Sorry but I disagree. If SCHED_RESTART is set that causes the blk-mq core to reexamine the software queues and the hctx dispatch list but not the requeue list. If a block driver returns BLK_STS_RESOURCE then requests end up on the requeue list. Hence the following code in scsi_end_request():

	if (scsi_target(sdev)->single_lun || !list_empty(&sdev->host->starved_list))
		kblockd_schedule_work(&sdev->requeue_work);
	else
		blk_mq_run_hw_queues(q, true);

Bart.

#10 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 8 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

Run queue at end_io is definitely wrong, because blk-mq has SCHED_RESTART to do that already.

Sorry but I disagree. If SCHED_RESTART is set that causes the blk-mq core to reexamine the software queues and the hctx dispatch list but not the requeue list. If a block driver returns BLK_STS_RESOURCE then requests end up on the requeue list. Hence the following code in scsi_end_request():

That doesn't need SCHED_RESTART, because it is requeue's responsibility to do that,
see blk_mq_requeue_work(), which will run hw queue at the end of this func.

Signature · 1 line
Ming Lei
#11 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 6 lines · Ming Lei
Quoted 4 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

Run queue at end_io is definitely wrong, because blk-mq has SCHED_RESTART to do that already.

Quoted 8 lines
Quoted 4 lines

Sorry but I disagree. If SCHED_RESTART is set that causes the blk-mq core to reexamine the software queues and the hctx dispatch list but not the requeue list. If a block driver returns BLK_STS_RESOURCE then requests end up on the requeue list. Hence the following code in scsi_end_request():

That doesn't need SCHED_RESTART, because it is requeue's responsibility to do that,
see blk_mq_requeue_work(), which will run hw queue at the end of this func.

That's not what I was trying to explain. What I was trying to explain is that every block driver that can cause a request to end up on the requeue list is responsible for kicking the requeue list at a later time. Hence the kblockd_schedule_work(&sdev->requeue_work) call in the SCSI core and the blk_mq_kick_requeue_list() and blk_mq_delay_kick_requeue_list() calls in the dm code. What I would like to see is measurement results for dm-mpath without this patch series and a call to kick the requeue list added to the dm-mpath end_io code.

Bart.

author
#12 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 16 lines · Bart Van Assche
Quoted 6 lines · Ming Lei
Quoted 4 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

Run queue at end_io is definitely wrong, because blk-mq has SCHED_RESTART to do that already.

Quoted 8 lines
Quoted 4 lines

Sorry but I disagree. If SCHED_RESTART is set that causes the blk-mq core to reexamine the software queues and the hctx dispatch list but not the requeue list. If a block driver returns BLK_STS_RESOURCE then requests end up on the requeue list. Hence the following code in scsi_end_request():

That doesn't need SCHED_RESTART, because it is requeue's responsibility to do that,
see blk_mq_requeue_work(), which will run hw queue at the end of this func.

Quoted 8 lines

That's not what I was trying to explain. What I was trying to explain is that every block driver that can cause a request to end up on the requeue list is responsible for kicking the requeue list at a later time. Hence the kblockd_schedule_work(&sdev->requeue_work) call in the SCSI core and the blk_mq_kick_requeue_list() and blk_mq_delay_kick_requeue_list() calls in the dm code. What I would like to see is measurement results for dm-mpath without this patch series and a call to kick the requeue list added to the dm-mpath end_io code.

For this issue, it isn't same between SCSI and dm-rq.

We don't need to run queue in .end_io of dm, and the theory is simple, otherwise it isn't performance issue, and should be I/O hang.

1) every dm-rq's request is 1:1 mapped to SCSI's request

2) if there is any mapped SCSI request not finished, either in-flight or in requeue list or whatever, there will be one corresponding dm-rq's request in-flight

3) once the mapped SCSI request is completed, dm-rq's completion path will be triggered and dm-rq's queue will be rerun because of SCHED_RESTART in dm-rq

So the hw queue of dm-rq has been run in dm-rq's completion path already, right? Why do we need to do it again in the hot path?

Signature · 1 line
Ming
#13 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 11 lines · Ming Lei

For this issue, it isn't same between SCSI and dm-rq.

We don't need to run queue in .end_io of dm, and the theory is simple, otherwise it isn't performance issue, and should be I/O hang.

1) every dm-rq's request is 1:1 mapped to SCSI's request

2) if there is any mapped SCSI request not finished, either in-flight or in requeue list or whatever, there will be one corresponding dm-rq's request in-flight

Quoted 6 lines

3) once the mapped SCSI request is completed, dm-rq's completion path will be triggered and dm-rq's queue will be rerun because of SCHED_RESTART in dm-rq

So the hw queue of dm-rq has been run in dm-rq's completion path already, right? Why do we need to do it again in the hot path?

The measurement data in the description of patch 5/5 shows a significant performance regression for an important workload, namely random I/O. Additionally, the performance improvement for sequential I/O was achieved for an unrealistically low queue depth. Sorry but given these measurement results I don't see why I should spend more time on this patch series.

Bart.

#14 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Quoted 16 lines · Bart Van Assche
Quoted 15 lines · Ming Lei

For this issue, it isn't same between SCSI and dm-rq.

We don't need to run queue in .end_io of dm, and the theory is simple, otherwise it isn't performance issue, and should be I/O hang.

1) every dm-rq's request is 1:1 mapped to SCSI's request

2) if there is any mapped SCSI request not finished, either in-flight or in requeue list or whatever, there will be one corresponding dm-rq's request in-flight

3) once the mapped SCSI request is completed, dm-rq's completion path will be triggered and dm-rq's queue will be rerun because of SCHED_RESTART in dm-rq

Quoted 7 lines
Quoted 2 lines

So the hw queue of dm-rq has been run in dm-rq's completion path already, right? Why do we need to do it again in the hot path?

The measurement data in the description of patch 5/5 shows a significant performance regression for an important workload, namely random I/O. Additionally, the performance improvement for sequential I/O was achieved for an unrealistically low queue depth.

So you've ignored Ming's question entirely and instead decided to focus on previous questions you raised to Ming that he ignored. This is getting tedious.

Especially given that Ming said the first patch that all this fighting has been over isn't even required to attain the improvements.

Ming, please retest both your baseline and patched setup with a queue_depth of >= 32. Also, please do 3 - 5 runs to get a avg and std dev across the runs.

Quoted 2 lines

Sorry but given these measurement results I don't see why I should spend more time on this patch series.

Bart, I've historically genuinely always appreciated your review and insight. But if your future "review" on this patchset would take the form shown in this thread then please don't spend more time on it.

Mike

author
#15 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

Hi Mike,

Quoted 22 lines · Mike Snitzer
Quoted 19 lines · Bart Van Assche
Quoted 17 lines · Ming Lei

For this issue, it isn't same between SCSI and dm-rq.

We don't need to run queue in .end_io of dm, and the theory is simple, otherwise it isn't performance issue, and should be I/O hang.

1) every dm-rq's request is 1:1 mapped to SCSI's request

2) if there is any mapped SCSI request not finished, either in-flight or in requeue list or whatever, there will be one corresponding dm-rq's request in-flight

3) once the mapped SCSI request is completed, dm-rq's completion path will be triggered and dm-rq's queue will be rerun because of SCHED_RESTART in dm-rq

So the hw queue of dm-rq has been run in dm-rq's completion path already, right? Why do we need to do it again in the hot path?

Quoted 8 lines
Quoted 4 lines

The measurement data in the description of patch 5/5 shows a significant performance regression for an important workload, namely random I/O. Additionally, the performance improvement for sequential I/O was achieved for an unrealistically low queue depth.

So you've ignored Ming's question entirely and instead decided to focus on previous questions you raised to Ming that he ignored. This is getting tedious.

Sorry for not making it clear, I mentioned I will post a new version to address the random I/O regression.

Quoted 7 lines

Especially given that Ming said the first patch that all this fighting has been over isn't even required to attain the improvements.

Ming, please retest both your baseline and patched setup with a queue_depth of >= 32. Also, please do 3 - 5 runs to get a avg and std dev across the runs.

Taking a bigger queue_depth won't be helpful on this issue, and it can make the situation worse, because .cmd_per_lun won't be changed, and queue often becomes busy when number of in-flight requests is bigger than .cmd_per_lun.

I will post one new version, which will use another simple way to figure out if underlying queue is busy, so that random I/O perf won't be affected, but this new version need to depend on the following patchset:

	https://marc.info/?t=150436555700002&r=1&w=2

So it may take a while since that patchset is still under review.

I will post them all together in 'blk-mq-sched: improve SCSI-MQ performance(V5)'.

The approach taken in patch 5 depends on q->queue_depth, but some SCSI host's .cmd_per_lun is different with q->queue_depth, so causes the random I/O regression.

Signature · 1 line
Ming
author
#16 lore raw

Re: [PATCH 1/5] block: don't call blk_mq_delay_run_hw_queue() in case of BLK_STS_RESOURCE

In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche
Quoted 2 lines · Ming Lei

Run queue at end_io is definitely wrong, because blk-mq has SCHED_RESTART to do that already.

Sorry but I disagree. If SCHED_RESTART is set that causes the blk-mq core to reexamine the software queues and the hctx dispatch list but not the requeue list. If a block driver returns BLK_STS_RESOURCE then requests end up on the requeue list. Hence the following code in scsi_end_request():

Quoted 4 lines
	if (scsi_target(sdev)->single_lun || !list_empty(&sdev->host->starved_list))
		kblockd_schedule_work(&sdev->requeue_work);
	else
		blk_mq_run_hw_queues(q, true);

Let's focus on dm-rq.

I have explained before, dm-rq is different with SCSI's, we don't need to requeue request any more in dm-rq if blk_get_request() returns NULL in multipath_clone_and_map(), since SCHED_RESTART can cover that definitely.

Not mention dm_mq_delay_requeue_request() will run the queue explicitly if it has to be done. That needn't SCHED_RESTART to cover, right?

Signature · 1 line
Ming