From patchwork Tue Oct 2 12:43:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10623607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B59718A7 for ; Tue, 2 Oct 2018 12:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BB7D2882F for ; Tue, 2 Oct 2018 12:43:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F3FC288A0; Tue, 2 Oct 2018 12:43:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AABE82889E for ; Tue, 2 Oct 2018 12:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727582AbeJBT0s (ORCPT ); Tue, 2 Oct 2018 15:26:48 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:39634 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbeJBT0s (ORCPT ); Tue, 2 Oct 2018 15:26:48 -0400 Received: by mail-lf1-f66.google.com with SMTP id w21-v6so1292456lff.6 for ; Tue, 02 Oct 2018 05:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=QrEwn+yipGeBRZY5/gGy9a5nu5aovyyAaOxjUkJnx4g=; b=IKOG+/ITKBRtfIypyc3szRhTPjIwYJMJUoJn+rh0yVoTg+xtH6kJUQ85fY+lBnaJrW PxgjM2+FMKI7E3kbyFeAFcNlpZwQJCtAd2YIxcPCwkRrk3ysXafrQGIX6smxYIKqMiMJ 1uaIuRM5nSjBx6yeGyqOO47oxxXDMoIuSWZSM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QrEwn+yipGeBRZY5/gGy9a5nu5aovyyAaOxjUkJnx4g=; b=pgHY0KffrQrIyZB3E+8zVUF8sEdpe+sFO1gyWkfZW9SKD06sTwNNpCzz72WvEv9e2S A1bu7vDeXurVqWSZs/TXf4ljuS//0vB8qrJSlixozDFyQ1Y7c82hS4YxP4VAbGMWsdp5 WHZgypTJ5QYewaMcVjHy0bsENk4YwSAc+TR5Id5lBHa7wylk4fAcWUKYP5XTtGBtxy+3 95quI4WU2SUp/8qE3Vxrr4HO7HRyeDN9k8dVVLguWLFZYF/9F4Xvb3cjKSlS/Rv+VPiX 318cxhgBYT+Csstaj2IOtPEv8MtFeXsRqtiAdUgDAihfL/Gd558KZNMp3/WEGNoAXAzh SMKQ== X-Gm-Message-State: ABuFfoh5+l2r766cCZ9PYnr1TgqVquHRclgtX2QLHXzqzA341NjJ+QbV LQo4LQoJKmRoH2DEhMHVoUx9unzkZ38= X-Google-Smtp-Source: ACcGV61wEWX5Eho0xh77fqv20IuKSGWSvqq3z9uI5IyW8GqY7BI9f2tfpdcWyK6RggxLObdVlGRLnQ== X-Received: by 2002:a19:12a5:: with SMTP id 37-v6mr8713060lfs.51.1538484215889; Tue, 02 Oct 2018 05:43:35 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u2-v6sm3418171ljg.55.2018.10.02.05.43.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Oct 2018 05:43:34 -0700 (PDT) From: Linus Walleij To: linux-block@vger.kernel.org, Jens Axboe Cc: linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, Linus Walleij , Pavel Machek , Paolo Valente , Ulf Hansson , Richard Weinberger , Artem Bityutskiy , Adrian Hunter Subject: [PATCH] block: BFQ default for single queue devices Date: Tue, 2 Oct 2018 14:43:29 +0200 Message-Id: <20181002124329.21248-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 notably 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 talked to Pavel a bit back and it turns out he has a usecase for BFQ as well and I bet he also would like it as default scheduler for that system (Pavel tell us more, I don't remember what it was!) Intuitively I could understand that maybe we want to leave the loop device (possibly others? nbd? rbd?) as "none", as it is probably relying on a scheduler on the device below it, so I'm open to passing in a scheduler hint from the respective subsystem in say struct blk_mq_tag_set. However that makes for a bit of syntactic dissonance with the struct member ".nr_hw_queues" (I wonder how the loop device can have 1 "hardware queue"?) so maybe we should in that case also rename that struct member to ".nr_queues" fair and square before we start making adjustments for treating queues differently whether they are in hardware or actually not. Cc: Pavel Machek Cc: Paolo Valente Cc: Jens Axboe Cc: Ulf Hansson Cc: Richard Weinberger Cc: Artem Bityutskiy Cc: Adrian Hunter Signed-off-by: Linus Walleij --- block/elevator.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index e18ac68626e3..e5a2c39eee7b 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -948,13 +948,15 @@ 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; + struct elevator_type *e = NULL; int err = 0; if (q->nr_hw_queues != 1) @@ -968,9 +970,14 @@ int elevator_init_mq(struct request_queue *q) if (unlikely(q->elevator)) goto out_unlock; - e = elevator_get(q, "mq-deadline", false); - if (!e) - goto out_unlock; + if (IS_ENABLED(CONFIG_IOSCHED_BFQ)) + e = elevator_get(q, "bfq", false); + + if (!e) { + e = elevator_get(q, "mq-deadline", false); + if (!e) + goto out_unlock; + } err = blk_mq_init_sched(q, e); if (err)