From patchwork Mon Feb 6 19:24:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9558681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7652602B1 for ; Mon, 6 Feb 2017 19:24:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A901B27FE4 for ; Mon, 6 Feb 2017 19:24:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C95B2808C; Mon, 6 Feb 2017 19:24:53 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham 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 20A4C27FE4 for ; Mon, 6 Feb 2017 19:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbdBFTYw (ORCPT ); Mon, 6 Feb 2017 14:24:52 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34747 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751471AbdBFTYv (ORCPT ); Mon, 6 Feb 2017 14:24:51 -0500 Received: by mail-pf0-f176.google.com with SMTP id e4so26080702pfg.1 for ; Mon, 06 Feb 2017 11:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=bjgR7RHDatCU4SaDcgtLJqlrwORV4hftewyhK853oUs=; b=DDZnO30pP1rlfEwu9Ox1hrOPIc/i3NMfgqFvLSYsToMMi68UBtDkNp46RBTugDTobG 9Elaz4VE9aweTX8Oo9bST3YQTrsELrY+5CKrgzAWY8cbsszxknYckoz+XqH1u4LLsnLM fO4GgpDLJpO7FQxme5P5Hhb2NOR6HCNouiQqPSd48icsvSuu/zWnzm9MHkUrSFY1x/P5 wDyy3basY6IObf5EeslPu0PPIpNV5cKoWK7+SEGNUSY8mPX1aTpQK5i5eL4mwpHtCWN4 he/ke5fG83XswDCS06E/foJnR7BTHvwYZx74TYZXKkvo7uhhhl9NOS+EqbrKb049Loj7 JFKA== 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=bjgR7RHDatCU4SaDcgtLJqlrwORV4hftewyhK853oUs=; b=A7qP6Y/tFQ3r69ltTnWuCuEZeP6ugVMCzyWGD3zx7AKSA7F9JQqg7QBQigJWU4KmL2 Sje6UoN3pCsNOTFBe9iHKYNfWWdqNv076f+OM/HaLC/QE8ToB5N7xfz7eSEqwDYJgkU1 Kvf7APCKItw5OfetWgnBjBT3P2xiQJClRHCv1RDAf8a7jsKkt5B0uRSfRrWKQgtik5pM GsXpBNQC9KRX7eC2Qn1tlmyirTn23oCKNl03nrYE0ughLvumoqRA6pTwH5+NJn1an/PK OWN6QgVpiyDYoG1BnCRzKYeUeLmItzPslmnHZY194COaba3/6Az+zlxRVbyIj9fZ6Ui/ UCAg== X-Gm-Message-State: AIkVDXIsXfeGDRl0O9AlJ+L8eiT5/WicqqE2eXCoE4jTI3pt71vBUPa/unTf5+kvO7ye6L5E X-Received: by 10.98.112.134 with SMTP id l128mr14894521pfc.81.1486409090954; Mon, 06 Feb 2017 11:24:50 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::96e7]) by smtp.gmail.com with ESMTPSA id y23sm4577625pfi.66.2017.02.06.11.24.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 11:24:50 -0800 (PST) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH v2] blk-mq-sched: separate mark hctx and queue restart operations Date: Mon, 6 Feb 2017 11:24:11 -0800 Message-Id: <0ec9b1167d22966cdf77a1d5140499493ea888a2.1486408944.git.osandov@fb.com> X-Mailer: git-send-email 2.11.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 From: Omar Sandoval In blk_mq_sched_dispatch_requests(), we call blk_mq_sched_mark_restart() after we dispatch requests left over on our hardware queue dispatch list. This is so we'll go back and dispatch requests from the scheduler. In this case, it's only necessary to restart the hardware queue that we are running; there's no reason to run other hardware queues just because we are using shared tags. So, split out blk_mq_sched_mark_restart() into two operations, one for just the hardware queue and one for the whole request queue. The core code uses both, and I/O schedulers may also want to use them. Signed-off-by: Omar Sandoval --- Patch based on block/for-next. block/blk-mq-sched.c | 2 +- block/blk-mq-sched.h | 25 ++++++++++++++++++------- block/blk-mq.c | 5 ++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index ee455e7cf9d8..7538565359ea 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -201,7 +201,7 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx) * needing a restart in that case. */ if (!list_empty(&rq_list)) { - blk_mq_sched_mark_restart(hctx); + blk_mq_sched_mark_restart_hctx(hctx); blk_mq_dispatch_rq_list(hctx, &rq_list); } else if (!e || !e->type->ops.mq.dispatch_request) { blk_mq_flush_busy_ctxs(hctx, &rq_list); diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 5954859c8670..46788ef2b3db 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -121,16 +121,27 @@ static inline bool blk_mq_sched_has_work(struct blk_mq_hw_ctx *hctx) return false; } -static inline void blk_mq_sched_mark_restart(struct blk_mq_hw_ctx *hctx) +/* + * Mark a hardware queue as needing a restart. + */ +static inline void blk_mq_sched_mark_restart_hctx(struct blk_mq_hw_ctx *hctx) { - if (!test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state)) { + if (!test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state)) set_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state); - if (hctx->flags & BLK_MQ_F_TAG_SHARED) { - struct request_queue *q = hctx->queue; +} + +/* + * Mark a hardware queue and the request queue it belongs to as needing a + * restart. + */ +static inline void blk_mq_sched_mark_restart_queue(struct blk_mq_hw_ctx *hctx) +{ + struct request_queue *q = hctx->queue; - if (!test_bit(QUEUE_FLAG_RESTART, &q->queue_flags)) - set_bit(QUEUE_FLAG_RESTART, &q->queue_flags); - } + if (!test_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state)) { + set_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state); + if (!test_bit(QUEUE_FLAG_RESTART, &q->queue_flags)) + set_bit(QUEUE_FLAG_RESTART, &q->queue_flags); } } diff --git a/block/blk-mq.c b/block/blk-mq.c index be183e6115a1..a494c0b589d5 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -937,7 +937,10 @@ bool blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list) * in case the needed IO completed right before we * marked the queue as needing a restart. */ - blk_mq_sched_mark_restart(hctx); + if (hctx->flags & BLK_MQ_F_TAG_SHARED) + blk_mq_sched_mark_restart_queue(hctx); + else + blk_mq_sched_mark_restart_hctx(hctx); if (!blk_mq_get_driver_tag(rq, &hctx, false)) break; }