From patchwork Wed Jul 14 15:06:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 476767 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp659566jao; Wed, 14 Jul 2021 08:11:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUEAxTuT5AxPrcU2hflmD1aqiN2t+WAtrJROhq7MjgvXt+lgag+nBN3BJ0oE00OB1cu6sr X-Received: by 2002:a17:906:b53:: with SMTP id v19mr12507223ejg.262.1626275488157; Wed, 14 Jul 2021 08:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626275488; cv=none; d=google.com; s=arc-20160816; b=yiA7YFAZHNRqDgx1p4WqrhuunC+IBcHGRAhti1uY3FsubDca2N5vQsYNdV1jt3oM8H qNrraGi1ymWgVIMZjvATAVmRYsrd21UuEWbF010t4T/sX0jyom/YIOveN9wNVOikQTB1 CQcFtPO2TR0/4d8zmY+zx1JVGuO7rYvYKhIf61V06pksEyi3fqPXdcDXjU0MmtPnrFop heH8Mi6q6wCD509samLHzUehH/bGO68M8Ior4A9qK5xha+piISfxqO1phKrkH2f+MRR+ lMlSJstasGzw71qWv3yPC4vQp7WY4K6RTyPfQzcu8bVGn4V2ShfLUXh7nUbGt4T9i4xV 68dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=moVxzf43KTvMxAAhp5MJ0AC4y5Sna/ke6T82rtx9lC4=; b=s81NhVRuQWavRUY0eYVM5BuaYGw0y9rOePJFCNhkZMzvckUHU2tixkx2dbKc/tSJW4 HZKj5ZWB9a8QwQEk7IuJdZaHL3jNNsVgyIFY/lBEojb4WywLhGmFDh06/bkg8CpdaTZ+ VAt59bDVr8WvY71kv141myvzrL/nQObyU+n90q+gl17DwDobrHmhShTo4+YXAwhIuf32 GGSlBYaOELJmj/4DM7SjiAEAGEgOiz5pMvucd9+dwgK+zSiFB9imo2joURd3Zgdm4I+Z ZJ1GTfU4CCWMkLtidhQc5rWngSjEwBeyb/RziEmoj9aGZrXATy8vdbHcbtUgbRGFtHpQ OIjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z20si2999812edc.592.2021.07.14.08.11.28 for ; Wed, 14 Jul 2021 08:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239628AbhGNPOQ (ORCPT ); Wed, 14 Jul 2021 11:14:16 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3407 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239611AbhGNPOP (ORCPT ); Wed, 14 Jul 2021 11:14:15 -0400 Received: from fraeml745-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GQ0vq10X7z6D91S; Wed, 14 Jul 2021 22:56:55 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml745-chm.china.huawei.com (10.206.15.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 14 Jul 2021 17:11:21 +0200 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 14 Jul 2021 16:11:19 +0100 From: John Garry To: CC: , , , , , , John Garry Subject: [PATCH 4/9] blk-mq: Add blk_mq_tag_resize_sched_shared_sbitmap() Date: Wed, 14 Jul 2021 23:06:30 +0800 Message-ID: <1626275195-215652-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1626275195-215652-1-git-send-email-john.garry@huawei.com> References: <1626275195-215652-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Put the functionality to resize the sched shared sbitmap in a common function. Since the same formula is always used to resize, and it can be got from the request queue argument, so just pass the request queue pointer. Signed-off-by: John Garry --- block/blk-mq-sched.c | 3 +-- block/blk-mq-tag.c | 10 ++++++++++ block/blk-mq-tag.h | 1 + block/blk-mq.c | 3 +-- 4 files changed, 13 insertions(+), 4 deletions(-) -- 2.26.2 diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index f5cb2931c20d..1e028183557d 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -584,8 +584,7 @@ static int blk_mq_init_sched_shared_sbitmap(struct request_queue *queue) &queue->sched_breserved_tags; } - sbitmap_queue_resize(&queue->sched_bitmap_tags, - queue->nr_requests - set->reserved_tags); + blk_mq_tag_resize_sched_shared_sbitmap(queue); return 0; } diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 86f87346232a..55c7f1bf41c7 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -634,6 +634,16 @@ void blk_mq_tag_resize_shared_sbitmap(struct blk_mq_tag_set *set, unsigned int s sbitmap_queue_resize(&set->__bitmap_tags, size - set->reserved_tags); } +/* + * We always resize with q->nr_requests - q->tag_set->reserved_tags, so + * don't bother passing a size. + */ +void blk_mq_tag_resize_sched_shared_sbitmap(struct request_queue *q) +{ + sbitmap_queue_resize(&q->sched_bitmap_tags, + q->nr_requests - q->tag_set->reserved_tags); +} + /** * blk_mq_unique_tag() - return a tag that is unique queue-wide * @rq: request for which to compute a unique tag diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h index 8ed55af08427..3a7495e47fb4 100644 --- a/block/blk-mq-tag.h +++ b/block/blk-mq-tag.h @@ -48,6 +48,7 @@ extern int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx, unsigned int depth, bool can_grow); extern void blk_mq_tag_resize_shared_sbitmap(struct blk_mq_tag_set *set, unsigned int size); +extern void blk_mq_tag_resize_sched_shared_sbitmap(struct request_queue *q); extern void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool); void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn, diff --git a/block/blk-mq.c b/block/blk-mq.c index 56e3c6fdba60..b0d4197d36c7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3643,8 +3643,7 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr) q->nr_requests = nr; if (blk_mq_is_sbitmap_shared(set->flags)) { if (q->elevator) { - sbitmap_queue_resize(&q->sched_bitmap_tags, - nr - set->reserved_tags); + blk_mq_tag_resize_sched_shared_sbitmap(q); } else { blk_mq_tag_resize_shared_sbitmap(set, nr); }