From patchwork Mon Jul 31 16:51:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9872549 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 779A16037D for ; Mon, 31 Jul 2017 16:53:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 501A728533 for ; Mon, 31 Jul 2017 16:53:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44FAC28562; Mon, 31 Jul 2017 16:53:24 +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,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 CD00C28533 for ; Mon, 31 Jul 2017 16:53:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751533AbdGaQwu (ORCPT ); Mon, 31 Jul 2017 12:52:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbdGaQwt (ORCPT ); Mon, 31 Jul 2017 12:52:49 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F05DC23356C; Mon, 31 Jul 2017 16:52:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7F05DC23356C Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ming.lei@redhat.com Received: from localhost (ovpn-12-46.pek2.redhat.com [10.72.12.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id E891E189CB; Mon, 31 Jul 2017 16:52:41 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig Cc: Bart Van Assche , linux-scsi@vger.kernel.org, "Martin K . Petersen" , "James E . J . Bottomley" , Ming Lei Subject: [PATCH 08/14] blk-mq: introduce BLK_MQ_F_SHARED_DEPTH Date: Tue, 1 Aug 2017 00:51:05 +0800 Message-Id: <20170731165111.11536-10-ming.lei@redhat.com> In-Reply-To: <20170731165111.11536-1-ming.lei@redhat.com> References: <20170731165111.11536-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 31 Jul 2017 16:52:49 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SCSI devices often provides one per-requeest_queue depth via q->queue_depth(.cmd_per_lun), which is a global limit on all hw queues. After the pending I/O submitted to one rquest queue reaches this limit, BLK_STS_RESOURCE will be returned to all dispatch path. That means when one hw queue is stuck, actually all hctxs are stuck too. This flag is introduced for improving blk-mq IO scheduling on this kind of device. Signed-off-by: Ming Lei --- block/blk-mq-debugfs.c | 1 + block/blk-mq-sched.c | 2 +- block/blk-mq.c | 25 ++++++++++++++++++++++--- include/linux/blk-mq.h | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 9ebc2945f991..c4f70b453c76 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -209,6 +209,7 @@ static const char *const hctx_flag_name[] = { HCTX_FLAG_NAME(SG_MERGE), HCTX_FLAG_NAME(BLOCKING), HCTX_FLAG_NAME(NO_SCHED), + HCTX_FLAG_NAME(SHARED_DEPTH), }; #undef HCTX_FLAG_NAME diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 3eb524ccb7aa..cc0687a4d0ab 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -144,7 +144,7 @@ void blk_mq_sched_dispatch_requests(struct blk_mq_hw_ctx *hctx) if (!can_go || test_bit(BLK_MQ_S_BUSY, &hctx->state)) return; - if (!has_sched_dispatch && !q->queue_depth) { + if (!has_sched_dispatch && !(hctx->flags & BLK_MQ_F_SHARED_DEPTH)) { blk_mq_flush_busy_ctxs(hctx, &rq_list); blk_mq_dispatch_rq_list(q, &rq_list); return; diff --git a/block/blk-mq.c b/block/blk-mq.c index 7df68d31bc23..db635ef06a72 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2647,12 +2647,31 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) int blk_mq_update_sched_queue_depth(struct request_queue *q) { unsigned nr; + struct blk_mq_hw_ctx *hctx; + unsigned int i; + int ret = 0; - if (!q->mq_ops || !q->elevator) - return 0; + if (!q->mq_ops) + return ret; + + blk_mq_freeze_queue(q); + /* + * if there is q->queue_depth, all hw queues share + * this queue depth limit + */ + if (q->queue_depth) { + queue_for_each_hw_ctx(q, hctx, i) + hctx->flags |= BLK_MQ_F_SHARED_DEPTH; + } + + if (!q->elevator) + goto exit; nr = blk_mq_sched_queue_depth(q); - return __blk_mq_update_nr_requests(q, true, nr); + ret = __blk_mq_update_nr_requests(q, true, nr); + exit: + blk_mq_unfreeze_queue(q); + return ret; } static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 6d44b242b495..14f2ad3af31f 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -164,6 +164,7 @@ enum { BLK_MQ_F_SG_MERGE = 1 << 2, BLK_MQ_F_BLOCKING = 1 << 5, BLK_MQ_F_NO_SCHED = 1 << 6, + BLK_MQ_F_SHARED_DEPTH = 1 << 7, BLK_MQ_F_ALLOC_POLICY_START_BIT = 8, BLK_MQ_F_ALLOC_POLICY_BITS = 1,