All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] block: BFQ default for single queue devices
@ 2018-10-15 14:10 ` Linus Walleij
  0 siblings, 0 replies; 73+ messages in thread
From: Linus Walleij @ 2018-10-15 14:10 UTC (permalink / raw)
  To: linux-block, Jens Axboe
  Cc: linux-mmc, linux-mtd, Linus Walleij, Pavel Machek, Paolo Valente,
	Ulf Hansson, Richard Weinberger, Adrian Hunter, Bart Van Assche,
	Jan Kara, Artem Bityutskiy, Christoph Hellwig, Alan Cox,
	Mark Brown, Damien Le Moal, Johannes Thumshirn,
	Oleksandr Natalenko, Jonathan Corbet

This sets BFQ as the default scheduler for single queue
block devices (nr_hw_queues == 1) if it is available. This
affects notably MMC/SD-cards but also UBI and the loopback
device.

I have been running it for a while without any negative
effects on my pet systems and I want some wider testing
so let's throw it out there and see what people say.
Admittedly my use cases are limited. I need to keep this
patch around for my personal needs anyway.

We take special care to avoid using BFQ on zoned devices
(in particular SMR, shingled magnetic recording devices)
as these currently require mq-deadline to group writes
together.

I have opted against introducing any default scheduler
through Kconfig as the mq-deadline enforcement for
zoned devices has to be done at runtime anyways and
too many config options will make things confusing.

My argument for setting a default policy in the kernel
as opposed to user space is the "reasonable defaults"
type, analogous to how we have one default CPU scheduling
policy (CFS) that make most sense for most tasks, and
how automatic process group scheduling happens in most
distributions without userspace involvement. The BFQ
scheduling policy makes most sense for single hardware
queue devices and many embedded systems will not have
the clever userspace tools (such as udev) to make an
educated choice of scheduling policy. Defaults should be
those that make most sense for the hardware.

Cc: Pavel Machek <pavel@ucw.cz>
Cc: Paolo Valente <paolo.valente@linaro.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
Cc: Mark Brown <broonie@kernel.org>
Cc: Damien Le Moal <Damien.LeMoal@wdc.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Add a quirk so that devices with zoned writes are forced
  to use the deadline scheduler, this is necessary since only
  that scheduler supports zoned writes.
- There is a summary article in LWN for subscribers:
  https://lwn.net/Articles/767987/
---
 block/elevator.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/block/elevator.c b/block/elevator.c
index 8fdcd64ae12e..6e6048ca3471 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -948,13 +948,16 @@ int elevator_switch_mq(struct request_queue *q,
 }
 
 /*
- * For blk-mq devices, we default to using mq-deadline, if available, for single
- * queue devices.  If deadline isn't available OR we have multiple queues,
- * default to "none".
+ * For blk-mq devices, we default to using:
+ * - "none" for multiqueue devices (nr_hw_queues != 1)
+ * - "bfq", if available, for single queue devices
+ * - "mq-deadline" if "bfq" is not available for single queue devices
+ * - "none" for single queue devices as well as last resort
  */
 int elevator_init_mq(struct request_queue *q)
 {
 	struct elevator_type *e;
+	const char *policy;
 	int err = 0;
 
 	if (q->nr_hw_queues != 1)
@@ -968,7 +971,18 @@ int elevator_init_mq(struct request_queue *q)
 	if (unlikely(q->elevator))
 		goto out_unlock;
 
-	e = elevator_get(q, "mq-deadline", false);
+	/*
+	 * Zoned devices must use a deadline scheduler because currently
+	 * that is the only scheduler respecting zoned writes.
+	 */
+	if (blk_queue_is_zoned(q))
+		policy = "mq-deadline";
+	else if (IS_ENABLED(CONFIG_IOSCHED_BFQ))
+		policy = "bfq";
+	else
+		policy = "mq-deadline";
+
+	e = elevator_get(q, policy, false);
 	if (!e)
 		goto out_unlock;
 
-- 
2.17.2

^ permalink raw reply related	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2018-11-02 10:40 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-15 14:10 [PATCH v2] block: BFQ default for single queue devices Linus Walleij
2018-10-15 14:10 ` Linus Walleij
2018-10-15 14:22 ` Paolo Valente
2018-10-15 14:22   ` Paolo Valente
2018-10-15 14:22   ` Paolo Valente
2018-10-15 14:32 ` Oleksandr Natalenko
2018-10-15 14:32   ` Oleksandr Natalenko
2018-10-19  8:33   ` Linus Walleij
2018-10-19  8:33     ` Linus Walleij
2018-10-19  9:26     ` Oleksandr Natalenko
2018-10-19  9:26       ` Oleksandr Natalenko
2018-10-15 15:02 ` Bart Van Assche
2018-10-15 15:02   ` Bart Van Assche
2018-10-15 18:34   ` Paolo Valente
2018-10-15 18:34     ` Paolo Valente
2018-10-15 18:34     ` Paolo Valente
2018-10-17  5:18     ` Paolo Valente
2018-10-17  5:18       ` Paolo Valente
2018-10-17  5:18       ` Paolo Valente
2018-10-16 16:14   ` Federico Motta
2018-10-16 16:14     ` Federico Motta
2018-10-16 16:26     ` Paolo Valente
2018-10-16 16:26       ` Paolo Valente
2018-10-16 16:26       ` Paolo Valente
2018-10-15 15:39 ` Jens Axboe
2018-10-15 15:39   ` Jens Axboe
2018-10-15 18:26   ` Paolo Valente
2018-10-15 18:26     ` Paolo Valente
2018-10-15 18:26     ` Paolo Valente
2018-10-15 19:26     ` Jens Axboe
2018-10-15 19:26       ` Jens Axboe
2018-10-15 19:44       ` Paolo Valente
2018-10-15 19:44         ` Paolo Valente
2018-10-15 19:44         ` Paolo Valente
2018-10-16 17:35         ` Jens Axboe
2018-10-16 17:35           ` Jens Axboe
2018-10-17 10:05           ` Jan Kara
2018-10-17 10:05             ` Jan Kara
2018-10-17 14:48             ` Bart Van Assche
2018-10-17 14:48               ` Bart Van Assche
2018-10-17 14:59               ` Bryan Gurney
2018-10-17 14:59                 ` Bryan Gurney
2018-10-19  8:42                 ` Linus Walleij
2018-10-19  8:42                   ` Linus Walleij
2018-10-19 13:36                   ` Bryan Gurney
2018-10-19 13:36                     ` Bryan Gurney
2018-10-19 13:44                     ` Johannes Thumshirn
2018-10-19 13:44                       ` Johannes Thumshirn
2018-10-19 14:16                       ` Bryan Gurney
2018-10-19 14:16                         ` Bryan Gurney
2018-10-22  8:12                   ` Jens Axboe
2018-10-22  8:12                     ` Jens Axboe
2018-10-17 16:01               ` Mark Brown
2018-10-17 16:01                 ` Mark Brown
2018-10-17 16:29             ` Jens Axboe
2018-10-17 16:29               ` Jens Axboe
2018-10-18  7:21               ` Jan Kara
2018-10-18  7:21                 ` Jan Kara
2018-10-18 14:35                 ` Jens Axboe
2018-10-18 14:35                   ` Jens Axboe
2018-10-19  8:22                   ` Pavel Machek
2018-10-19  8:22                     ` Pavel Machek
2018-10-22  8:08                     ` Jens Axboe
2018-10-22  8:08                       ` Jens Axboe
2018-11-02 10:40           ` Oleksandr Natalenko
2018-11-02 10:40             ` Oleksandr Natalenko
2018-10-19 10:59     ` Paolo Valente
2018-10-19 10:59       ` Paolo Valente
2018-10-19 10:59       ` Paolo Valente
2018-10-22  8:21       ` Jens Axboe
2018-10-22  8:21         ` Jens Axboe
2018-10-16 13:42 ` Ulf Hansson
2018-10-16 13:42   ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.