From patchwork Mon Oct 15 14:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 148849 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3843326lji; Mon, 15 Oct 2018 07:11:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV63BxdcbxS61m3dmGmg/e5rQHhzMLPnvjrtJMT0pEfY9b/Evn/QnhABGIeE/ZU2ZdjO3ZCZZ X-Received: by 2002:a17:902:7b83:: with SMTP id w3-v6mr17445090pll.285.1539612672225; Mon, 15 Oct 2018 07:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539612672; cv=none; d=google.com; s=arc-20160816; b=K8j1bSdQASSmMWarEWFogPMu5j4Iopz8wWxrTa0k3jUbICAcK4VkQKiVErCC4QVF94 tx4wOPGEGiAN5C74Z7Bll0rqyL/hmNVYpF84pxH0gSEChbYpdeiZKfWmzK/EfnffsxqZ ztME1UX0VVm5GoXGDJ9PxGhXrMixtm8XH8MCQVJivJp2KnEv5nnnIbQsywjSfRdj1X9g T4g2T/DMEdnIP0QdpNlsbCtd6DpMmskiQ+nzSjC11JEozbNCKFjAByAqxQCCJLDrIu2k ieWJbyWImClCqurwuZ3XTin2Y14pQkIKaLJZKzyIaXvow602csvuxAZ4PoMkYL/8VTGb 4dHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=M/ZhIWYIfY5r4RddVyoWnRgXdqgFCk+iYSx5Jk3TXYk=; b=vT3CmvhjcSlki6hFcxX7FG9s9dFGkiuQaSBVALayy5xVfh+BYqhki7A2rjA+Slw2ZH MBEAO7okZmc6+IXwBaPakaXqSoicsAXRqGs+9E1PFtFvlJJoTffH+3ihoxC3SGY/gYkH e67xCZT7OOor641MKztIk01KboI85RjEo5o9YSLA7H4ohueDksjGgJsa45QMJT/0jgk6 gbKFUJXJluCj0VUZv0rhMSo+pjNhcDmZJ0TalOqkpEFvKP8OK4BO7aJ8sPBKLAR/gS/S dfNwLOeZMmc+sXf5uUPbJ6jNIXfYKb/FQRu6gyLveoDM3r5FmJczuBJbJoAOJC1qpRjF jDoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TH9oQngy; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5-v6si9402233pgg.277.2018.10.15.07.11.11; Mon, 15 Oct 2018 07:11:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TH9oQngy; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbeJOV4i (ORCPT + 5 others); Mon, 15 Oct 2018 17:56:38 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36983 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbeJOV4h (ORCPT ); Mon, 15 Oct 2018 17:56:37 -0400 Received: by mail-lf1-f66.google.com with SMTP id a82-v6so14195989lfa.4 for ; Mon, 15 Oct 2018 07:11:08 -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=M/ZhIWYIfY5r4RddVyoWnRgXdqgFCk+iYSx5Jk3TXYk=; b=TH9oQngydTICbA1P922pQMW2Tu7UFQ1JHrtA/Y+fzM6ofaz4+BT4JlwI/0pRQ1aqr8 haOvYHGJZEYbRz3ScvR3XP5IKT6S34JTKnG7bKGwKr7wEcJeUcVHXFoTqttTnfhPpuJM ZytKpS/UrmWo1Xo+xWa1Sf/98/0VMirJh+l+c= 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=M/ZhIWYIfY5r4RddVyoWnRgXdqgFCk+iYSx5Jk3TXYk=; b=kIIozdmELlTy0KByVTy9m6/tLQ3vfhXI8YY2UIebDOOyBAK3sAO5uMVpj4BEMU8OEP TyEz7+xlOi4eWpO9kGST6p4UUMRcDPCpH6DrS4rQ1On1BMBJfaqM5lIOYkfY104kIE9U kYjva0/Y8zCiFgfs/2skNYszJq3AlyDACAU4HMBrvN6/qfDaQZw+TS4ZgQP9plXAlbNC uN2Hkgd6nBH/gJuoz9/O1TN6O4gVPxu8cyCHCqsMXIriL2/Akw6fIE1CEPxlC91CuBBM qjrvAbWiEVDypPyHU/ehIzVnnIg5GgwcyOzYBHQYzesvN8aKpAGgl9O/rGn1u5MnRN6e wxrw== X-Gm-Message-State: ABuFfojJ6/UKXAmYd+WDgQg2jYqxk0GBEzZJE3ZUWzOvIiiYvHTEKbSf E8CHVLGthv9Af4nTIMMl3az8Fw== X-Received: by 2002:a19:9585:: with SMTP id x127-v6mr10098054lfd.112.1539612667956; Mon, 15 Oct 2018 07:11:07 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id p24-v6sm2437537ljg.57.2018.10.15.07.11.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 07:11:05 -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 , Adrian Hunter , Bart Van Assche , Jan Kara , Artem Bityutskiy , Christoph Hellwig , Alan Cox , Mark Brown , Damien Le Moal , Johannes Thumshirn , Oleksandr Natalenko , Jonathan Corbet Subject: [PATCH v2] block: BFQ default for single queue devices Date: Mon, 15 Oct 2018 16:10:59 +0200 Message-Id: <20181015141059.26579-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Cc: Paolo Valente Cc: Jens Axboe Cc: Ulf Hansson Cc: Richard Weinberger Cc: Adrian Hunter Cc: Bart Van Assche Cc: Jan Kara Cc: Artem Bityutskiy Cc: Christoph Hellwig Cc: Alan Cox Cc: Mark Brown Cc: Damien Le Moal Cc: Johannes Thumshirn Cc: Oleksandr Natalenko Cc: Jonathan Corbet Signed-off-by: Linus Walleij --- 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(-) -- 2.17.2 Acked-by: Paolo Valente Reviewed-by: Ulf Hansson 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;