Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp975917iol; Thu, 9 Jun 2022 19:28:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN2V4clouPXKcNOxZzIHlEUNG4s1SyN/MqOmr1JyN8wsHEtgNpyFSgRP0VTviTJTYOQ6kP X-Received: by 2002:a05:6a00:124d:b0:51b:f2ac:ef8a with SMTP id u13-20020a056a00124d00b0051bf2acef8amr32028428pfi.72.1654828127035; Thu, 09 Jun 2022 19:28:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654828127; cv=none; d=google.com; s=arc-20160816; b=bmE7hrrJB9zOjkYpa3rNM0D3Z+F6DAKeALhDi23ru22AZUp2xmupurN6ZFVQKhlKsq e6l/A51IasgyDmrieLyMUc8yi1UBb3lK22s0Nj+wgeETy+uIJFjtfMaaqstccl4zNKb/ 5IVKPj7cvpKsK7tTN06zS1Wj/Fn7RXSZMKp9oyhZkClhOxUB+0bv6kmnV3tqdLBJ8oNa CYRsHxJDKYouOXeCCC46wuDuncRNwGio0gy+OSHXdy1j5rKXiNbFmeRmyzXwY/dXlP54 SimZYgq/VYR5mdjRJrUhE5S5+ZGgeD5qqCbyTYygR5jv8AnWg5llbgLefaf3ivzNPTfK mEdg== 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=Wmx6e6CgfdJqJ0tNustJg55Z1sPa1s5dZciLipk+dSs=; b=xfEo46fL/72o7aruk4WbY6jL9emU3vltzTDG65znVvwBn2M23iDbVKOn20IVa1tRUk g1hbZ6tlTnr5ZJ3G6VV+a0cM0Qofef08iRQAc1tW40eF6x+2kPB7bLpiyFOx3fXFNfx4 YVsLMIGy8BSwlNJlzR2cKaMupXcPrQSPHoMStF4hoRqc4NjJ3eRFZrlTOjYCHsJCVWWP IOJtTs06XR2SHRXhES4D101Nb++x+HI+x16rNBb6gIYdz4Mk3Ioa0zj7UOsTfkWZxH8i mQkDaj5qYkOwEjAbhKwewpDKCHi5/FL1vTg3xduDZNT0FcikWVfpV2rEsi4o6ZV40k1o qelA== 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 oo15-20020a17090b1c8f00b001df891c9ab8si1631832pjb.47.2022.06.09.19.28.25; Thu, 09 Jun 2022 19:28:47 -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 S1345642AbiFJCEZ (ORCPT + 99 others); Thu, 9 Jun 2022 22:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238877AbiFJCEO (ORCPT ); Thu, 9 Jun 2022 22:04:14 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70D4687A0C; Thu, 9 Jun 2022 19:03:52 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LK43v0h29zjXQ5; Fri, 10 Jun 2022 10:02:51 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 10 Jun 2022 10:03:50 +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; Fri, 10 Jun 2022 10:03:49 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v10 1/4] block, bfq: support to track if bfqq has pending requests Date: Fri, 10 Jun 2022 10:16:58 +0800 Message-ID: <20220610021701.2347602-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220610021701.2347602-1-yukuai3@huawei.com> References: <20220610021701.2347602-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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 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 Reviewed-by: Jan Kara --- block/bfq-iosched.c | 1 + block/bfq-iosched.h | 2 ++ block/bfq-wf2q.c | 24 ++++++++++++++++++++++-- 3 files changed, 25 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..69c7d15417e5 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -1080,6 +1080,8 @@ 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_add_bfqq_in_groups_with_pending_reqs(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..5704a0315cf2 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); } +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