Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1370403pxb; Sat, 16 Apr 2022 06:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqa0SSLCIOfDei/BdSEYmH4L0k1ZSvJXLrrLF+cNoWn6fSfjOdJ8cTuR6qJA8c86W1e2EF X-Received: by 2002:a63:5061:0:b0:39c:d0da:677b with SMTP id q33-20020a635061000000b0039cd0da677bmr2894988pgl.599.1650116361251; Sat, 16 Apr 2022 06:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650116361; cv=none; d=google.com; s=arc-20160816; b=GFtmHGqCTl0boBiYGFzj4p7DVdU+fUjoXHOTaTq833bfnQhUyQMyX7jbVPb3KRmiDx ZYMc2qxWxYg8jMiyyZWs83CCQ13Sz21OTbSvSf2IENEl0S0Q6MYnlCrSaTab6f5qibbR 4eC+E6mdcPBLC5bcRJ9clQx8ml3IIKcau3f1vnxCXLvSEdpa8FGEqHQg7snlA7c5Lhlv m/TxlUiYOfAP0+w7AQrpAQAWh5d4PpfqJujOEyltcDkYH7X8OZ/rj47oZP1G6/T6IGlq 0gIiTvUgR0L91pM9NkVtA/pwimS1ygQAXP7OAz+zrUsC4tGZ/GIKEKsnywBpHgri+qTj 0oXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ctifNvj3pgP7L7t2yZtm9tKG1wiPfwZDg1O3erHrS1c=; b=FnJI5s0HbBw0T7zxdC547HDMYQPqlmWf/pbKtT3VWDFi5kK3F3N0lwPzeIr8cKVZHV nuwZC3Wza1oua9YKQUz21TIxJ09gp+imRxMKf3lV+y+oCie6ZRAxlpOatyDI5uwoewEK xKsx/onJBtQkIBlChjUOt6Gm4+lpnDEdSnltyjVnlLSPIzdbhWsv3zZ8SF7kHORWDO/S 1DioteUTd+QCQvuBuB8EpQdgrLgaJgw8YmoZMBADTdm6K2X+Ias+/xV9v/2TZSazpH2V x3v6Y0lBGYNTVq2mw32K8iWOuNaaI7dfWjXP1RRb0OiD4f/tOAZqPkQDpmUe9fOltONI FQ4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a637444000000b0039905bfa26esi4864668pgn.788.2022.04.16.06.39.07; Sat, 16 Apr 2022 06:39:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbiDPJ0H (ORCPT + 99 others); Sat, 16 Apr 2022 05:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230296AbiDPJ0A (ORCPT ); Sat, 16 Apr 2022 05:26:00 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E5951031; Sat, 16 Apr 2022 02:23:29 -0700 (PDT) Received: from kwepemi100019.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KgSNr057nzFphG; Sat, 16 Apr 2022 17:20:59 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi100019.china.huawei.com (7.221.188.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 16 Apr 2022 17:23:27 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 16 Apr 2022 17:23:26 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v2 2/5] block, bfq: add fake weight_counter for weight-raised queue Date: Sat, 16 Apr 2022 17:37:50 +0800 Message-ID: <20220416093753.3054696-3-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220416093753.3054696-1-yukuai3@huawei.com> References: <20220416093753.3054696-1-yukuai3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Weight-raised queue is not inserted to weights_tree, which makes it impossible to track how many queues have pending requests through weights_tree insertion and removel. This patch add fake weight_counter for weight-raised queue to do that. Signed-off-by: Yu Kuai --- block/bfq-iosched.c | 11 +++++++++++ block/bfq-wf2q.c | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2deea2d07a1f..a2977c938c70 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -134,6 +134,8 @@ #include "bfq-iosched.h" #include "blk-wbt.h" +#define BFQ_FAKE_WEIGHT_COUNTER ((void *) POISON_INUSE) + #define BFQ_BFQQ_FNS(name) \ void bfq_mark_bfqq_##name(struct bfq_queue *bfqq) \ { \ @@ -884,6 +886,12 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq) if (bfqq->weight_counter) return; + if (bfqq->wr_coeff != 1) { + bfqq->weight_counter = BFQ_FAKE_WEIGHT_COUNTER; + bfqq->ref++; + return; + } + while (*new) { struct bfq_weight_counter *__counter = container_of(*new, struct bfq_weight_counter, @@ -943,6 +951,9 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bfqq) if (!bfqq->weight_counter) return; + if (bfqq->weight_counter == BFQ_FAKE_WEIGHT_COUNTER) + goto reset_entity_pointer; + root = &bfqd->queue_weights_tree; bfqq->weight_counter->num_active--; if (bfqq->weight_counter->num_active > 0) diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index a1296058c1ec..ae12c6b2c525 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -776,7 +776,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, * Add the entity, if it is not a weight-raised queue, * to the counter associated with its new weight. */ - if (prev_weight != new_weight && bfqq && bfqq->wr_coeff == 1) + if (prev_weight != new_weight && bfqq) bfq_weights_tree_add(bfqd, bfqq); new_st->wsum += entity->weight; @@ -1680,8 +1680,7 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) bfqd->busy_queues[bfqq->ioprio_class - 1]++; if (!bfqq->dispatched) - if (bfqq->wr_coeff == 1) - bfq_weights_tree_add(bfqd, bfqq); + bfq_weights_tree_add(bfqd, bfqq); if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues++; -- 2.31.1