Skip to contentSkip to conversation

Make legacy IO schedulers work with blk-mq

PATCH In review Jens Axboe 2 participants 10 messages Dec 5, 2016 – Dec 6, 2016

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

PATCH v2 1/1 Make legacy IO schedulers work with blk-mq

Version 2 of the hack/patchset, that enables blk-mq to use the legacy IO schedulers with single queue devices. Original posting is here:

https://marc.info/?l=linux-block&m=148073493203664&w=2

You can also found this version in the following git branch:

git://git.kernel.dk/linux-block blk-mq-legacy-sched.2

and new developments/fixes will happen in the 'blk-mq-legacy-sched' branch.

Changes since v1:

- Remove the default 'deadline' hard wiring, and provide Kconfig entries to set the blk-mq scheduler. This now works like for legacy devices.

- Rename blk_use_mq_path() to blk_use_sched_path() to make it more clear. Suggested by Johannes Thumshirn.

- Fixup a spot where we did not use the accessor function to determine what path to use.

- Flush mq software queues, even if IO scheduler managed. This should make paths work that are MQ aware, and using only MQ interfaces.

- Cleanup free path of MQ request.

- Account when IO was queued to a hardware context, similarly to the regular MQ path.

- Add BLK_MQ_F_NO_SCHED flag, so that drivers can explicitly ask for no scheduling on a queue. Add this for NVMe admin queues.

- Kill BLK_MQ_F_SCHED, since we now have Kconfig entries for setting the desired IO scheduler.

- Fix issues with live scheduler switching through sysfs. Should now be solid, even with lots of IO running on the device.

- Drop null_blk and SCSI changes, not needed anymore.

 block/Kconfig.iosched   |   29 ++++
 block/blk-core.c        |   77 ++++++-----
 block/blk-exec.c        |   12 +
 block/blk-flush.c       |   40 +++--
 block/blk-merge.c       |    5 
 block/blk-mq.c          |  332 +++++++++++++++++++++++++++++++++++++++++++++---
 block/blk-mq.h          |    1 
 block/blk-sysfs.c       |    2 
 block/blk.h             |   16 ++
 block/cfq-iosched.c     |   22 ++-
 block/elevator.c        |  125 ++++++++++++------
 drivers/nvme/host/pci.c |    1 
 include/linux/blk-mq.h  |    1 
 include/linux/blkdev.h  |    2 
 14 files changed, 555 insertions(+), 110 deletions(-)
author
#1 lore raw

PATCH 1/7 block: use legacy path for flush requests for MQ with a scheduler

No functional changes with this patch, it's just in preparation for supporting legacy schedulers on blk-mq.

---
 block/blk-core.c  |  2 +-
 block/blk-exec.c  |  2 +-
 block/blk-flush.c | 26 ++++++++++++++------------
 block/blk.h       | 12 +++++++++++-
 4 files changed, 27 insertions(+), 15 deletions(-)
block/blk-core.c +1 -1
index 4b7ec5958055..813c448453bf 100644
@@ -1310,7 +1310,7 @@ static struct request *blk_old_get_request(struct request_queue *q, int rw,
 
 struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask)
 {
-	if (q->mq_ops)
+	if (!blk_use_sched_path(q))
 		return blk_mq_alloc_request(q, rw,
 			(gfp_mask & __GFP_DIRECT_RECLAIM) ?
 				0 : BLK_MQ_REQ_NOWAIT);
block/blk-exec.c +1 -1
index 3ecb00a6cf45..3356dff5508c 100644
@@ -64,7 +64,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
 	 * don't check dying flag for MQ because the request won't
 	 * be reused after dying flag is set
 	 */
-	if (q->mq_ops) {
+	if (!blk_use_sched_path(q)) {
 		blk_mq_insert_request(rq, at_head, true, false);
 		return;
 	}
block/blk-flush.c +14 -12
index 1bdbb3d3e5f5..040c36b83ef7 100644
@@ -133,14 +133,16 @@ static void blk_flush_restore_request(struct request *rq)
 
 static bool blk_flush_queue_rq(struct request *rq, bool add_front)
 {
-	if (rq->q->mq_ops) {
+	struct request_queue *q = rq->q;
+
+	if (!blk_use_sched_path(q)) {
 		blk_mq_add_to_requeue_list(rq, add_front, true);
 		return false;
 	} else {
 		if (add_front)
-			list_add(&rq->queuelist, &rq->q->queue_head);
+			list_add(&rq->queuelist, &q->queue_head);
 		else
-			list_add_tail(&rq->queuelist, &rq->q->queue_head);
+			list_add_tail(&rq->queuelist, &q->queue_head);
 		return true;
 	}
 }
@@ -201,7 +203,7 @@ static bool blk_flush_complete_seq(struct request *rq,
 		BUG_ON(!list_empty(&rq->queuelist));
 		list_del_init(&rq->flush.list);
 		blk_flush_restore_request(rq);
-		if (q->mq_ops)
+		if (!blk_use_sched_path(q))
 			blk_mq_end_request(rq, error);
 		else
 			__blk_end_request_all(rq, error);
@@ -224,7 +226,7 @@ static void flush_end_io(struct request *flush_rq, int error)
 	unsigned long flags = 0;
 	struct blk_flush_queue *fq = blk_get_flush_queue(q, flush_rq->mq_ctx);
 
-	if (q->mq_ops) {
+	if (!blk_use_sched_path(q)) {
 		struct blk_mq_hw_ctx *hctx;
 
 		/* release the tag's ownership to the req cloned from */
@@ -240,7 +242,7 @@ static void flush_end_io(struct request *flush_rq, int error)
 	/* account completion of the flush request */
 	fq->flush_running_idx ^= 1;
 
-	if (!q->mq_ops)
+	if (blk_use_sched_path(q))
 		elv_completed_request(q, flush_rq);
 
 	/* and push the waiting requests to the next stage */
@@ -267,7 +269,7 @@ static void flush_end_io(struct request *flush_rq, int error)
 		blk_run_queue_async(q);
 	}
 	fq->flush_queue_delayed = 0;
-	if (q->mq_ops)
+	if (!blk_use_sched_path(q))
 		spin_unlock_irqrestore(&fq->mq_flush_lock, flags);
 }
 
@@ -315,7 +317,7 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq)
 	 * be in flight at the same time. And acquire the tag's
 	 * ownership for flush req.
 	 */
-	if (q->mq_ops) {
+	if (!blk_use_sched_path(q)) {
 		struct blk_mq_hw_ctx *hctx;
 
 		flush_rq->mq_ctx = first_rq->mq_ctx;
@@ -409,7 +411,7 @@ void blk_insert_flush(struct request *rq)
 	 * complete the request.
 	 */
 	if (!policy) {
-		if (q->mq_ops)
+		if (!blk_use_sched_path(q))
 			blk_mq_end_request(rq, 0);
 		else
 			__blk_end_bidi_request(rq, 0, 0, 0);
@@ -425,9 +427,9 @@ void blk_insert_flush(struct request *rq)
 	 */
 	if ((policy & REQ_FSEQ_DATA) &&
 	    !(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
-		if (q->mq_ops) {
+		if (!blk_use_sched_path(q))
 			blk_mq_insert_request(rq, false, false, true);
-		} else
+		else
 			list_add_tail(&rq->queuelist, &q->queue_head);
 		return;
 	}
@@ -440,7 +442,7 @@ void blk_insert_flush(struct request *rq)
 	INIT_LIST_HEAD(&rq->flush.list);
 	rq->rq_flags |= RQF_FLUSH_SEQ;
 	rq->flush.saved_end_io = rq->end_io; /* Usually NULL */
-	if (q->mq_ops) {
+	if (!blk_use_sched_path(q)) {
 		rq->end_io = mq_flush_data_end_io;
 
 		spin_lock_irq(&fq->mq_flush_lock);
block/blk.h +11 -1
index 041185e5f129..600e22ea62e9 100644
@@ -36,10 +36,20 @@ extern struct kmem_cache *request_cachep;
 extern struct kobj_type blk_queue_ktype;
 extern struct ida blk_queue_ida;
 
+/*
+ * Use the MQ path if we have mq_ops, but not if we are using an IO
+ * scheduler. For the scheduler, we should use the legacy path. Only
+ * for internal use in the block layer.
+ */
+static inline bool blk_use_sched_path(struct request_queue *q)
+{
+	return !q->mq_ops || q->elevator;
+}
+
 static inline struct blk_flush_queue *blk_get_flush_queue(
 		struct request_queue *q, struct blk_mq_ctx *ctx)
 {
-	if (q->mq_ops)
+	if (!blk_use_sched_path(q))
 		return blk_mq_map_queue(q, ctx->cpu)->fq;
 	return q->fq;
 }
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/7 cfq-iosched: use appropriate run queue function

In reply to Jens Axboe

For MQ devices, we have to use other functions to run the queue. No functional changes in this patch, just a prep patch for support legacy schedulers on blk-mq.

---
 block/cfq-iosched.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
block/cfq-iosched.c +19 -3
index c73a6fcaeb9d..d6d454a72bd4 100644
@@ -919,8 +919,14 @@ static inline struct cfq_data *cic_to_cfqd(struct cfq_io_cq *cic)
 static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
 {
 	if (cfqd->busy_queues) {
+		struct request_queue *q = cfqd->queue;
+
 		cfq_log(cfqd, "schedule dispatch");
-		kblockd_schedule_work(&cfqd->unplug_work);
+
+		if (q->mq_ops)
+			blk_mq_run_hw_queues(q, true);
+		else
+			kblockd_schedule_work(&cfqd->unplug_work);
 	}
 }
 
@@ -4086,6 +4092,16 @@ static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 	cfq_mark_cfqq_slice_new(cfqq);
 }
 
+static void cfq_run_queue(struct cfq_data *cfqd)
+{
+	struct request_queue *q = cfqd->queue;
+
+	if (q->mq_ops)
+		blk_mq_run_hw_queues(q, true);
+	else
+		__blk_run_queue(q);
+}
+
 /*
  * Called when a new fs request (rq) is added (to cfqq). Check if there's
  * something we should do about it
@@ -4122,7 +4138,7 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
 			    cfqd->busy_queues > 1) {
 				cfq_del_timer(cfqd, cfqq);
 				cfq_clear_cfqq_wait_request(cfqq);
-				__blk_run_queue(cfqd->queue);
+				cfq_run_queue(cfqd);
 			} else {
 				cfqg_stats_update_idle_time(cfqq->cfqg);
 				cfq_mark_cfqq_must_dispatch(cfqq);
@@ -4136,7 +4152,7 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
 		 * this new queue is RT and the current one is BE
 		 */
 		cfq_preempt_queue(cfqd, cfqq);
-		__blk_run_queue(cfqd->queue);
+		cfq_run_queue(cfqd);
 	}
 }
 
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/7 block: use appropriate queue running functions

In reply to Jens Axboe

Use MQ variants for MQ, legacy ones for legacy.

---
 block/blk-core.c  |  5 ++++-
 block/blk-exec.c  | 10 ++++++++--
 block/blk-flush.c | 14 ++++++++++----
 block/elevator.c  |  5 ++++-
 4 files changed, 26 insertions(+), 8 deletions(-)
block/blk-core.c +4 -1
index 813c448453bf..f0aa810a5fe2 100644
@@ -340,7 +340,10 @@ void __blk_run_queue(struct request_queue *q)
 	if (unlikely(blk_queue_stopped(q)))
 		return;
 
-	__blk_run_queue_uncond(q);
+	if (WARN_ON_ONCE(q->mq_ops))
+		blk_mq_run_hw_queues(q, true);
+	else
+		__blk_run_queue_uncond(q);
 }
 EXPORT_SYMBOL(__blk_run_queue);
 
block/blk-exec.c +8 -2
index 3356dff5508c..6c3f12b32f86 100644
@@ -80,8 +80,14 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
 	}
 
 	__elv_add_request(q, rq, where);
-	__blk_run_queue(q);
-	spin_unlock_irq(q->queue_lock);
+
+	if (q->mq_ops) {
+		spin_unlock_irq(q->queue_lock);
+		blk_mq_run_hw_queues(q, false);
+	} else {
+		__blk_run_queue(q);
+		spin_unlock_irq(q->queue_lock);
+	}
 }
 EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);
 
block/blk-flush.c +10 -4
index 040c36b83ef7..8f2354d97e17 100644
@@ -265,8 +265,10 @@ static void flush_end_io(struct request *flush_rq, int error)
 	 * kblockd.
 	 */
 	if (queued || fq->flush_queue_delayed) {
-		WARN_ON(q->mq_ops);
-		blk_run_queue_async(q);
+		if (q->mq_ops)
+			blk_mq_run_hw_queues(q, true);
+		else
+			blk_run_queue_async(q);
 	}
 	fq->flush_queue_delayed = 0;
 	if (!blk_use_sched_path(q))
@@ -346,8 +348,12 @@ static void flush_data_end_io(struct request *rq, int error)
 	 * After populating an empty queue, kick it to avoid stall.  Read
 	 * the comment in flush_end_io().
 	 */
-	if (blk_flush_complete_seq(rq, fq, REQ_FSEQ_DATA, error))
-		blk_run_queue_async(q);
+	if (blk_flush_complete_seq(rq, fq, REQ_FSEQ_DATA, error)) {
+		if (q->mq_ops)
+			blk_mq_run_hw_queues(q, true);
+		else
+			blk_run_queue_async(q);
+	}
 }
 
 static void mq_flush_data_end_io(struct request *rq, int error)
block/elevator.c +4 -1
index a18a5db274e4..11d2cfee2bc1 100644
@@ -627,7 +627,10 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)
 		 *   with anything.  There's no point in delaying queue
 		 *   processing.
 		 */
-		__blk_run_queue(q);
+		if (q->mq_ops)
+			blk_mq_run_hw_queues(q, true);
+		else
+			__blk_run_queue(q);
 		break;
 
 	case ELEVATOR_INSERT_SORT_MERGE:
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 4/7 blk-mq: blk_account_io_start() takes a bool

In reply to Jens Axboe
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
index bac12caece06..90db5b490df9 100644
@@ -1237,7 +1237,7 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
 {
 	init_request_from_bio(rq, bio);
 
-	blk_account_io_start(rq, 1);
+	blk_account_io_start(rq, true);
 }
 
 static inline bool hctx_allow_merges(struct blk_mq_hw_ctx *hctx)
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH 5/7 blk-mq: add BLK_MQ_F_NO_SCHED flag

In reply to Jens Axboe

Drivers can use this to prevent IO scheduling on a queue. Use this for NVMe, for the admin queue, which doesn't handle file system requests.

---
 drivers/nvme/host/pci.c | 1 +
 include/linux/blk-mq.h  | 1 +
 2 files changed, 2 insertions(+)
drivers/nvme/host/pci.c +1 -0
index d58f8e4e2c06..4560575f0a39 100644
@@ -1187,6 +1187,7 @@ static int nvme_alloc_admin_tags(struct nvme_dev *dev)
 		dev->admin_tagset.timeout = ADMIN_TIMEOUT;
 		dev->admin_tagset.numa_node = dev_to_node(dev->dev);
 		dev->admin_tagset.cmd_size = nvme_cmd_size(dev);
+		dev->admin_tagset.flags = BLK_MQ_F_NO_SCHED;
 		dev->admin_tagset.driver_data = dev;
 
 		if (blk_mq_alloc_tag_set(&dev->admin_tagset))
include/linux/blk-mq.h +1 -0
index 35a0af5ede6d..a85bd83bb218 100644
@@ -151,6 +151,7 @@ enum {
 	BLK_MQ_F_SG_MERGE	= 1 << 2,
 	BLK_MQ_F_DEFER_ISSUE	= 1 << 4,
 	BLK_MQ_F_BLOCKING	= 1 << 5,
+	BLK_MQ_F_NO_SCHED	= 1 << 6,
 	BLK_MQ_F_ALLOC_POLICY_START_BIT = 8,
 	BLK_MQ_F_ALLOC_POLICY_BITS = 1,
 
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH 6/7 blk-mq: test patch to get legacy IO schedulers working

In reply to Jens Axboe

With this applied, a single queue blk-mq manage device can use any of the legacy IO schedulers. This is exposed through Kconfig, exposing MQ scheduler choices. Like with the legacy devices, the IO scheduler can be runtime switched by echoing something else into:

/sys/block/</dev>/queue/scheduler

---
 block/Kconfig.iosched  |  29 +++++
 block/blk-core.c       |  44 ++++---
 block/blk-merge.c      |   5 +
 block/blk-mq.c         | 330 ++++++++++++++++++++++++++++++++++++++++++++++---
 block/blk-mq.h         |   1 +
 block/blk-sysfs.c      |   2 +-
 block/blk.h            |   4 +
 block/elevator.c       | 120 ++++++++++++------
 include/linux/blkdev.h |   2 +
 9 files changed, 469 insertions(+), 68 deletions(-)
block/Kconfig.iosched +29 -0
index 421bef9c4c48..50de4589f38e 100644
@@ -63,6 +63,35 @@ config DEFAULT_IOSCHED
 	default "cfq" if DEFAULT_CFQ
 	default "noop" if DEFAULT_NOOP
 
+choice
+	prompt "Default I/O scheduler for MQ devices"
+	default DEFAULT_MQ_SCHED_NONE
+	help
+	  Select the I/O scheduler which will be used by default for all
+	  multiqueue block devices. Note that this only applies for
+	  multiqueue devies that expose a single queue.
+
+	config DEFAULT_MQ_SCHED_NONE
+		bool "None"
+
+	config DEFAULT_MQ_DEADLINE
+		bool "Deadline" if IOSCHED_DEADLINE=y
+
+	config DEFAULT_MQ_CFQ
+		bool "CFQ" if IOSCHED_CFQ=y
+
+	config DEFAULT_MQ_NOOP
+		bool "No-op"
+
+endchoice
+
+config DEFAULT_MQ_IOSCHED
+	string
+	default "deadline" if DEFAULT_MQ_DEADLINE
+	default "cfq" if DEFAULT_MQ_CFQ
+	default "noop" if DEFAULT_MQ_NOOP
+	default "none" if DEFAULT_MQ_SCHED_NONE
+
 endmenu
 
 endif
block/blk-core.c +30 -14

98 lines not on this page · raw message

block/blk-merge.c +5 -0
index 1002afdfee99..0952e0503aa4 100644
@@ -754,6 +754,11 @@ static int attempt_merge(struct request_queue *q, struct request *req,
 	/* owner-ship of bio passed from next to req */
 	next->bio = NULL;
 	__blk_put_request(q, next);
+
+	/* FIXME: MQ+sched holds a reference */
+	if (q->mq_ops && q->elevator)
+		blk_queue_exit(q);
+
 	return 1;
 }
 
block/blk-mq.c +312 -18

427 lines not on this page · raw message

block/blk-mq.h +1 -0
index b444370ae05b..2b8f43fb9583 100644
@@ -56,6 +56,7 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
 extern int blk_mq_sysfs_register(struct request_queue *q);
 extern void blk_mq_sysfs_unregister(struct request_queue *q);
 extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
+extern int blk_mq_sched_init(struct request_queue *q);
 
 extern void blk_mq_rq_timed_out(struct request *req, bool reserved);
 
block/blk-sysfs.c +1 -1
index 706b27bd73a1..f3a11d4de4e6 100644
@@ -896,7 +896,7 @@ int blk_register_queue(struct gendisk *disk)
 
 	blk_wb_init(q);
 
-	if (!q->request_fn)
+	if (!q->elevator)
 		return 0;
 
 	ret = elv_register_queue(q);
block/blk.h +4 -0
index 600e22ea62e9..758c4e7bb788 100644
@@ -77,6 +77,9 @@ bool __blk_end_bidi_request(struct request *rq, int error,
 			    unsigned int nr_bytes, unsigned int bidi_bytes);
 void blk_freeze_queue(struct request_queue *q);
 
+struct request *get_request(struct request_queue *, unsigned int, struct bio *,
+				gfp_t);
+
 static inline void blk_queue_enter_live(struct request_queue *q)
 {
 	/*
@@ -110,6 +113,7 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
 			    unsigned int *request_count,
 			    struct request **same_queue_rq);
 unsigned int blk_plug_queued_count(struct request_queue *q);
+struct list_head *blk_get_plug_list(struct request_queue *, struct blk_plug *);
 
 void blk_account_io_start(struct request *req, bool new_io);
 void blk_account_io_completion(struct request *req, unsigned int bytes);
block/elevator.c +85 -35

209 lines not on this page · raw message

include/linux/blkdev.h +2 -0
index ebeef2b79c5a..a8c580f806cc 100644
@@ -120,6 +120,8 @@ typedef __u32 __bitwise req_flags_t;
 #define RQF_HASHED		((__force req_flags_t)(1 << 16))
 /* IO stats tracking on */
 #define RQF_STATS		((__force req_flags_t)(1 << 17))
+/* rl based request on MQ queue */
+#define RQF_MQ_RL		((__force req_flags_t)(1 << 18))
 
 /* flags that prevent us from merging requests: */
 #define RQF_NOMERGE_FLAGS \
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH 7/7 block: drop irq+lock when flushing queue plugs

In reply to Jens Axboe

Not convinced this is a faster approach, and it does look IRQs off longer than otherwise. With mq+scheduling, it's a problem since it forces us to offload the queue running. If we get rid of it, we can run the queue without the queue lock held.

---
 block/blk-core.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)
block/blk-core.c +14 -18
index 8be12ba91f8e..2c61d2020c3f 100644
@@ -3204,18 +3204,21 @@ static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
  * plugger did not intend it.
  */
 static void queue_unplugged(struct request_queue *q, unsigned int depth,
-			    bool from_schedule)
+			    bool from_schedule, unsigned long flags)
 	__releases(q->queue_lock)
 {
 	trace_block_unplug(q, depth, !from_schedule);
 
-	if (q->mq_ops)
-		blk_mq_run_hw_queues(q, true);
-	else if (from_schedule)
-		blk_run_queue_async(q);
-	else
-		__blk_run_queue(q);
-	spin_unlock(q->queue_lock);
+	if (q->mq_ops) {
+		spin_unlock_irqrestore(q->queue_lock, flags);
+		blk_mq_run_hw_queues(q, from_schedule);
+	} else {
+		if (from_schedule)
+			blk_run_queue_async(q);
+		else
+			__blk_run_queue(q);
+		spin_unlock_irqrestore(q->queue_lock, flags);
+	}
 }
 
 static void flush_plug_callbacks(struct blk_plug *plug, bool from_schedule)
@@ -3283,11 +3286,6 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 	q = NULL;
 	depth = 0;
 
-	/*
-	 * Save and disable interrupts here, to avoid doing it for every
-	 * queue lock we have to take.
-	 */
-	local_irq_save(flags);
 	while (!list_empty(&list)) {
 		rq = list_entry_rq(list.next);
 		list_del_init(&rq->queuelist);
@@ -3297,10 +3295,10 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 			 * This drops the queue lock
 			 */
 			if (q)
-				queue_unplugged(q, depth, from_schedule);
+				queue_unplugged(q, depth, from_schedule, flags);
 			q = rq->q;
 			depth = 0;
-			spin_lock(q->queue_lock);
+			spin_lock_irqsave(q->queue_lock, flags);
 		}
 
 		/*
@@ -3329,9 +3327,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 	 * This drops the queue lock
 	 */
 	if (q)
-		queue_unplugged(q, depth, from_schedule);
-
-	local_irq_restore(flags);
+		queue_unplugged(q, depth, from_schedule, flags);
 }
 
 void blk_finish_plug(struct blk_plug *plug)
Signature · 1 line
2.7.4
#8 lore raw
In reply to Jens Axboe
Quoted 2 lines

Il giorno 05 dic 2016, alle ore 19:26, Jens Axboe <[email protected]> ha =

scritto:

Quoted 5 lines

=20
Version 2 of the hack/patchset, that enables blk-mq to use the legacy IO schedulers with single queue devices. Original posting is here:
=20
https://marc.info/?l=3Dlinux-block&m=3D148073493203664&w=3D2

Quoted 8 lines

=20
You can also found this version in the following git branch:
=20
git://git.kernel.dk/linux-block blk-mq-legacy-sched.2 =20
and new developments/fixes will happen in the 'blk-mq-legacy-sched' branch.
=20

Hi Jens,
while running some tests, the system hung after a while.

If I'm not mistaken, the above branches contain a (modified) 4.9-rc1. Maybe instability follows from that? I have tried a rebase, but resulting conflicts are non-trivial (for me) to solve.

Meanwhile, if you deem it useful, I can provide you with the oops message, as I catch it.

As a secondary issue, iostat always reports 0 MB/s for both reads and writes, while tps are non null.

Thanks,
Paolo

Quoted 32 lines

Changes since v1:
=20
- Remove the default 'deadline' hard wiring, and provide Kconfig entries to set the blk-mq scheduler. This now works like for legacy devices.
=20
- Rename blk_use_mq_path() to blk_use_sched_path() to make it more clear. Suggested by Johannes Thumshirn.
=20
- Fixup a spot where we did not use the accessor function to determine what path to use.
=20
- Flush mq software queues, even if IO scheduler managed. This should make paths work that are MQ aware, and using only MQ interfaces.
=20
- Cleanup free path of MQ request.
=20
- Account when IO was queued to a hardware context, similarly to the regular MQ path.
=20
- Add BLK_MQ_F_NO_SCHED flag, so that drivers can explicitly ask for no scheduling on a queue. Add this for NVMe admin queues.
=20
- Kill BLK_MQ_F_SCHED, since we now have Kconfig entries for setting the desired IO scheduler.
=20
- Fix issues with live scheduler switching through sysfs. Should now be solid, even with lots of IO running on the device.
=20
- Drop null_blk and SCSI changes, not needed anymore.
=20
=20

Quoted 6 lines
block/Kconfig.iosched   |   29 ++++
block/blk-core.c        |   77 ++++++-----
block/blk-exec.c        |   12 +
block/blk-flush.c       |   40 +++--
block/blk-merge.c       |    5=20
block/blk-mq.c          |  332 =

+++++++++++++++++++++++++++++++++++++++++++++---

Quoted 9 lines
block/blk-mq.h          |    1=20
block/blk-sysfs.c       |    2=20
block/blk.h             |   16 ++
block/cfq-iosched.c     |   22 ++-
block/elevator.c        |  125 ++++++++++++------
drivers/nvme/host/pci.c |    1=20
include/linux/blk-mq.h  |    1=20
include/linux/blkdev.h  |    2=20
14 files changed, 555 insertions(+), 110 deletions(-)
Quoted 4 lines

=20
=20
--
To unsubscribe from this list: send the line "unsubscribe linux-block" =

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#9 lore raw
Quoted 19 lines · Paolo Valente
Quoted 6 lines

Il giorno 05 dic 2016, alle ore 19:26, Jens Axboe <[email protected]> ha scritto:

Version 2 of the hack/patchset, that enables blk-mq to use the legacy IO schedulers with single queue devices. Original posting is here:

Quoted 9 lines

https://marc.info/?l=linux-block&m=148073493203664&w=2

You can also found this version in the following git branch:

git://git.kernel.dk/linux-block blk-mq-legacy-sched.2

and new developments/fixes will happen in the 'blk-mq-legacy-sched' branch.

Hi Jens,
while running some tests, the system hung after a while.

Quoted 6 lines

If I'm not mistaken, the above branches contain a (modified) 4.9-rc1. Maybe instability follows from that? I have tried a rebase, but resulting conflicts are non-trivial (for me) to solve.

Meanwhile, if you deem it useful, I can provide you with the oops message, as I catch it.

Please do. I run my testing with master pulled in, but I can rebase the branch to include that.

Quoted 2 lines

As a secondary issue, iostat always reports 0 MB/s for both reads and writes, while tps are non null.

Looks like only the inflight stuff worked, but the completion bytes. Let me fix that up. Done.

OK, pull from:

git://git.kernel.dk/linux-block blk-mq-legacy-sched

and you'll get the latest and greatest, and merged to 4.9-rc8 as well.

Signature · 1 line
Jens Axboe