Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp548575pxa; Wed, 19 Aug 2020 08:27:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsTqS6hjhPgzWul2mB3Scg+naQ8D/jpISme3VRyoljROSUMYPdoSJJ8Xh0zQWZSyqF6hgu X-Received: by 2002:a17:906:c406:: with SMTP id u6mr27212357ejz.47.1597850859654; Wed, 19 Aug 2020 08:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597850859; cv=none; d=google.com; s=arc-20160816; b=okjV+946rOnZkXEAedsa1GmxM/1A9b3tCcXSNqRZ2ebJlLdVFFZA7LjZ2LZgChEyhe +RIOgDzSuO3M3+4Be40VprieZ13M1BMjS5MtJA0ulR+Ao+O2MRmHq4sIjfxEeGJgYnbW getk8qvppqnsDJFs169ug1u8nb/61l0ziBwqVUVrSrJhBg59Gd46Zyt93AJ2FMHNWd6u hqR1MEKKAewx+PkS7cE5cDfexONlQWSxfRx8mHs7keXhVwtTyQKDiwq/S3F/K9m89fJR 9yMBQ+MdnkJtd7yV6MIaNsfJBMfa0ZNYehXGjYtrJqiwpZ2OChQuWCBVlqoj47onQD0I K9rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=VjCoV6JAmL4qyYElDiY5yGZEFP9PGEjxIQUq5fXBJ5Q=; b=Nk+1m2tb12mQ7bcJLzhsv+mpRL2k4iV+pcAHm9Pv2podAE8iKCD+H+4Q79/Q0ZxzfU B+iuzcmz7OyZWTRQDbKbVoA9Znmqet/hCLN5GFWkkemw3/NmA3WT4gmg9F/u8Tc0sN7H d1UeYu/cZAr4qstrvUAWjwU4LGYO066KwJotkTFlEwqHIdxeheOtSD0VT/vqPdZuoSwa MhKN+ShP0c/ETcFqaJHd8cqqKsA7eVPllCO0p4zgFDeUgDEetSJSHuLe6zSMlUY5dg0U 5A7kxXYHD4gtGJEWqWBUCVugRwlw8IRBOBdNg4gVvnZ51/zMR/6Mbe3OPsh2X64YByev kToQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp16si16072696ejc.687.2020.08.19.08.27.15; Wed, 19 Aug 2020 08:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728852AbgHSP0G (ORCPT + 99 others); Wed, 19 Aug 2020 11:26:06 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39924 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728782AbgHSPZb (ORCPT ); Wed, 19 Aug 2020 11:25:31 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B0A14375EA32A0D143C2; Wed, 19 Aug 2020 23:24:58 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 19 Aug 2020 23:24:49 +0800 From: John Garry To: , , , , , , , , , , CC: , , , , , , , , John Garry Subject: [PATCH v8 07/18] blk-mq: Relocate hctx_may_queue() Date: Wed, 19 Aug 2020 23:20:25 +0800 Message-ID: <1597850436-116171-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1597850436-116171-1-git-send-email-john.garry@huawei.com> References: <1597850436-116171-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org blk-mq.h and blk-mq-tag.h include on each other, which is less than ideal. Locate hctx_may_queue() to blk-mq.h, as it is not really tag specific code. In this way, we can drop the blk-mq-tag.h include of blk-mq.h Signed-off-by: John Garry --- block/blk-mq-tag.h | 33 --------------------------------- block/blk-mq.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h index 8f4cce52ba2d..7d3e6b333a4a 100644 --- a/block/blk-mq-tag.h +++ b/block/blk-mq-tag.h @@ -2,8 +2,6 @@ #ifndef INT_BLK_MQ_TAG_H #define INT_BLK_MQ_TAG_H -#include "blk-mq.h" - /* * Tag address space map. */ @@ -81,37 +79,6 @@ static inline void blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx) __blk_mq_tag_idle(hctx); } -/* - * For shared tag users, we track the number of currently active users - * and attempt to provide a fair share of the tag depth for each of them. - */ -static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx, - struct sbitmap_queue *bt) -{ - unsigned int depth, users; - - if (!hctx || !(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED)) - return true; - if (!test_bit(BLK_MQ_S_TAG_ACTIVE, &hctx->state)) - return true; - - /* - * Don't try dividing an ant - */ - if (bt->sb.depth == 1) - return true; - - users = atomic_read(&hctx->tags->active_queues); - if (!users) - return true; - - /* - * Allow at least some tags - */ - depth = max((bt->sb.depth + users - 1) / users, 4U); - return atomic_read(&hctx->nr_active) < depth; -} - static inline bool blk_mq_tag_is_reserved(struct blk_mq_tags *tags, unsigned int tag) { diff --git a/block/blk-mq.h b/block/blk-mq.h index 3acdb56065e1..56dc37c21908 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -259,4 +259,36 @@ static inline struct blk_plug *blk_mq_plug(struct request_queue *q, return NULL; } +/* + * For shared tag users, we track the number of currently active users + * and attempt to provide a fair share of the tag depth for each of them. + */ +static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx, + struct sbitmap_queue *bt) +{ + unsigned int depth, users; + + if (!hctx || !(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED)) + return true; + if (!test_bit(BLK_MQ_S_TAG_ACTIVE, &hctx->state)) + return true; + + /* + * Don't try dividing an ant + */ + if (bt->sb.depth == 1) + return true; + + users = atomic_read(&hctx->tags->active_queues); + if (!users) + return true; + + /* + * Allow at least some tags + */ + depth = max((bt->sb.depth + users - 1) / users, 4U); + return atomic_read(&hctx->nr_active) < depth; +} + + #endif -- 2.26.2