Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5768459ioo; Wed, 1 Jun 2022 12:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWjL7nuXbHtfH0KJus2WQNopvCbFm0C1h8PeRotwj+RBsIBAsgKkxBDI+6yhR6zy3Cwz+Y X-Received: by 2002:a17:902:8487:b0:15f:b2c:435 with SMTP id c7-20020a170902848700b0015f0b2c0435mr899305plo.33.1654110577468; Wed, 01 Jun 2022 12:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654110577; cv=none; d=google.com; s=arc-20160816; b=FZvRABDBWMJtM5GQ9NT24HGqdx8PTR91imMGNlk2N+BnQDrlHQ8pvpEUFjvnXw3n7z r8PYrT41bFCgBiNhZKNp83xgCwjp27oZv3JPA9RslPrrlfqy8IqJtMb6rLK5F6/Nekn7 6Vx4Bl7AnGhhprl3b86gQhybUdoOCO41Mlm8QVSlrhsvkm2Wv5xrP7JJq5Mn1StujYzJ sIOlWGQdMKP5k9r/owa609XIPQk7T8ULdPIBdE2SKEN5tcyedLyKjFaltHpVb9/ATDqN 5mRw5v3P4/E2c4XSK7srq09JIsq8nc9a5Ru37QT8oiHr3OoWvqViq3H5jBMPVxamHMkA ijbQ== 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=CQ01EP5gsgS+7u3OiYvF7LcKZzkghxcZ17kJQmxsma4=; b=R2FPJ7ZcoaRGZ16+WwMKU09OPvKVhp0QjRu2OigRjEAFs9mLj3omtpm1yc6TiapEtG BY6vVwcQAJu2q3c8cV0UluShGMXGF96d5y8ib9/NUX68md3X3WyA6qDNvNs0XvjihcZJ 1hDz6jT7VWtNViNf9peWGbwgMe6C8dyRvAfHXPAhEhh4PBg4WP8n6e9r/cG4AZgbpCtY IDYdywgQ1v47pVcaeFZyLcvRj1vh5m00MklkZLj0cWEZJeH+YWdgP2QL4VP/1U32hitH JeLFPDIYafrFjhhC3tHinHY9U+KW0uELFfWSn4BNAXcC6HHAdHoNpC8vRLkpWkpNN6ZC RZYw== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w63-20020a638242000000b003fcb8ab9341si1909129pgd.211.2022.06.01.12.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:09:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 96AB81216C2; Wed, 1 Jun 2022 11:50:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244969AbiEaNzx (ORCPT + 99 others); Tue, 31 May 2022 09:55:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245530AbiEaNzm (ORCPT ); Tue, 31 May 2022 09:55:42 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03CF5D5C; Tue, 31 May 2022 06:55:35 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LCDHJ2D70zRhVj; Tue, 31 May 2022 21:52:28 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 31 May 2022 21:55:33 +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; Tue, 31 May 2022 21:55:33 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v8 1/4] block, bfq: support to track if bfqq has pending requests Date: Tue, 31 May 2022 22:08:55 +0800 Message-ID: <20220531140858.3324294-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220531140858.3324294-1-yukuai3@huawei.com> References: <20220531140858.3324294-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: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 If entity belongs to bfqq, then entity->in_groups_with_pending_reqs is not used currently. This patch use it to track if bfqq has pending requests through callers of weights_tree insertion and removal. Signed-off-by: Yu Kuai --- block/bfq-iosched.c | 1 + block/bfq-iosched.h | 1 + block/bfq-wf2q.c | 24 ++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 0d46cb728bbf..0ec21018daba 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -6263,6 +6263,7 @@ static void bfq_completed_request(struct bfq_queue *bfqq, struct bfq_data *bfqd) */ bfqq->budget_timeout = jiffies; + bfq_del_bfqq_in_groups_with_pending_reqs(bfqq); bfq_weights_tree_remove(bfqd, bfqq); } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index ca8177d7bf7c..3b9b1a0e7c1c 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -1080,6 +1080,7 @@ void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, bool expiration); void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq); +void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq); /* --------------- end of interface of B-WF2Q+ ---------------- */ diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index f8eb340381cf..12d20f26ad69 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -1647,6 +1647,22 @@ void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, bfqq == bfqd->in_service_queue, expiration); } +static void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq) +{ + struct bfq_entity *entity = &bfqq->entity; + + if (!entity->in_groups_with_pending_reqs) + entity->in_groups_with_pending_reqs = true; +} + +void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq) +{ + struct bfq_entity *entity = &bfqq->entity; + + if (entity->in_groups_with_pending_reqs) + entity->in_groups_with_pending_reqs = false; +} + /* * Called when the bfqq no longer has requests pending, remove it from * the service tree. As a special case, it can be invoked during an @@ -1668,8 +1684,10 @@ void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, bfq_deactivate_bfqq(bfqd, bfqq, true, expiration); - if (!bfqq->dispatched) + if (!bfqq->dispatched) { + bfq_del_bfqq_in_groups_with_pending_reqs(bfqq); bfq_weights_tree_remove(bfqd, bfqq); + } } /* @@ -1684,10 +1702,12 @@ void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) bfq_mark_bfqq_busy(bfqq); bfqd->busy_queues[bfqq->ioprio_class - 1]++; - if (!bfqq->dispatched) + if (!bfqq->dispatched) { + bfq_add_bfqq_in_groups_with_pending_reqs(bfqq); if (bfqq->wr_coeff == 1) bfq_weights_tree_add(bfqd, bfqq, &bfqd->queue_weights_tree); + } if (bfqq->wr_coeff > 1) bfqd->wr_busy_queues++; -- 2.31.1