From patchwork Mon Sep 13 15:12:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 509778 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp655325jao; Mon, 13 Sep 2021 08:18:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEI3+Jx/jUedCjlF1AX+V71Vq1ztOWcX5R/A1z+IaC0BJZE8f0Y6d3P1BMOPkWDX8eF2d9 X-Received: by 2002:a17:906:a195:: with SMTP id s21mr12831770ejy.181.1631546295331; Mon, 13 Sep 2021 08:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631546295; cv=none; d=google.com; s=arc-20160816; b=HcG91dNsppnuQT45tHrK6IQDQKuTb5Pi+e52/FseiiAAdi1w0rJzgRvE1+HS9bWnr+ anEO0FB9xk5n3/1hxQRhUzqcY9/vySSOrTdb+r35f/SN31l6IuuCywYd7O8SJvDbJR03 hnrMn4M4k1DV9TsU6WqmagNmyoqqHZxryZ08J7xD8+6sFWEatZVWJ160j2wXqhfpK3XV iYBu2hfIyjOzZH+882aldByjvKqPv24jYxe7pdzrigy5NERtSN0K+SuwNxXrODQOViRi 0rj3W85ujmiBPrNJuge7fPJ3F3g0+ZJTkgiPm2o8wssxMCCEH5kEFfBnTjo8C9HTc9X/ DkBQ== 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=SzZKOwcQIHijEXFK3nyqrHzMotCwWzJg+PhcGUzFI4w=; b=HakZhnJHUYaf0omO9qznsNgV04A4ZBYkEgfBXrsJAV2HLmeKVbLSfI9q5OAVj82P6N gGsdmvAyZ5fLm7LghH97h59nPooxbTAnnRGJdvXfmVSPfkbmUCDyFePfvnCsxA1XEoRg 3k4Y5Vx3L8YFonUEoeajcH2MNYb43rMQ9We9dl0lVdxx4eOV89pE4Z9++7JbzPzPizMF nPXwkRO1nPxg922xNVKWGvhiHILmJsk9HT6iFI92oMz42IWa4iINOsLC/Fa95/dA1NE3 Jc4LdbmW/CDvqNH7Gim3e4dwC9IFoit4dr6N5U4DzVH7W3smC/Ce87mQb9+D5s+88U7o oLJg== 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 18si7608876ejh.282.2021.09.13.08.18.15 for ; Mon, 13 Sep 2021 08:18:15 -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 S237922AbhIMPT3 (ORCPT ); Mon, 13 Sep 2021 11:19:29 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3781 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346381AbhIMPSz (ORCPT ); Mon, 13 Sep 2021 11:18:55 -0400 Received: from fraeml737-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4H7VR15YDNz67PGs; Mon, 13 Sep 2021 23:15:25 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml737-chm.china.huawei.com (10.206.15.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 13 Sep 2021 17:17:38 +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.2308.8; Mon, 13 Sep 2021 16:17:36 +0100 From: John Garry To: CC: , , , , John Garry Subject: [PATCH RESEND v3 09/13] blk-mq: Add blk_mq_tag_update_sched_shared_sbitmap() Date: Mon, 13 Sep 2021 23:12:26 +0800 Message-ID: <1631545950-56586-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1631545950-56586-1-git-send-email-john.garry@huawei.com> References: <1631545950-56586-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 update the sched shared sbitmap size 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 Reviewed-by: Ming Lei --- block/blk-mq-sched.c | 3 +-- block/blk-mq-tag.c | 6 ++++++ block/blk-mq-tag.h | 1 + block/blk-mq.c | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-) -- 2.26.2 diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 3ab26154f0ea..a3b5a5399bc8 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -575,8 +575,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_update_sched_shared_sbitmap(queue); return 0; } diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 86f87346232a..5f06ad6efc8f 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -634,6 +634,12 @@ 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); } +void blk_mq_tag_update_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..88f3c6485543 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_update_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 5229c5420b85..5fec444d6399 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3641,8 +3641,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_update_sched_shared_sbitmap(q); else blk_mq_tag_resize_shared_sbitmap(set, nr); }