Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5637946ioo; Wed, 1 Jun 2022 09:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/Q5Q2vjJcABbd4Mh4WzPf1DFSYesJN6D0YsuR14psetVU2v0E/wrANnSDz7YWwnGRXRdq X-Received: by 2002:a05:6402:50d1:b0:42b:c3e:d71e with SMTP id h17-20020a05640250d100b0042b0c3ed71emr574604edb.144.1654100593802; Wed, 01 Jun 2022 09:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654100593; cv=none; d=google.com; s=arc-20160816; b=qh901/NjdfYl/mhZu/Ph34CZSHjE0jZfuWGIfWJfoKgNlLkx+qdLEYKPwP1x4b8Iew MGmTyG8GGT1enRfP1xMFjl5qSoysmd/oSVHpo4yaRCHIp7T/js9rZDvSOZw4fOo+En9K AwTaaHqZUQuxf4X4Uq8fRn6KD5iMUfE4fo6jVmFIp7Btzxbh+qkrOy17wX6lqJUzdIdq hwIUTiZUWsmW+tYQAmnGBe5ZNdwP4w7LquWnE3A8z94JJCQ3DUTYFhlZMTlYZrlWryIT k4eHaNGFLUgylMcyLMpncKo8x1uX9c11IPN0Vtwye/f3AJNclBHiORpRRW7TDgoJO8ep ZC6g== 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=WHSkStD8sDd6fYt4G9oXe0i/wgPzUZeRpXpdsANFdh2g4X3lWzIMIqLo/81p1Qr0v4 TVMjJ7wss9/ey4E+zZn+Bab8oKSrkJgg1mpCaMs3+fVHlhXPTAggDFcHd8TuLvPy5ZkK OBCNXkVUoUL9j6A55hzDN9lWPxT5Ye6NawSm0umaUWpC8sK3joYPSVlPrs025cUIZmrN 9gH//nGrh2qVCoMhSg+fuYVCiuLFDHm30DnbH0BTXcZFRhEhFg7gTypIuII9LQORU3pn aqAn8bX/1mWCqKgNKmvwCdwTwP6gRRINy0Je1SB6tuMYBZ9jUpW0FoFpl+k80yGJsOTZ Incg== 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 g4-20020a1709065d0400b007082a03af06si1705635ejt.284.2022.06.01.09.22.47; Wed, 01 Jun 2022 09:23:13 -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 S1352764AbiFALa1 (ORCPT + 99 others); Wed, 1 Jun 2022 07:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351526AbiFALaZ (ORCPT ); Wed, 1 Jun 2022 07:30:25 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697BF6FA1F; Wed, 1 Jun 2022 04:30:19 -0700 (PDT) Received: from kwepemi100017.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LCn3q1lX4zjXGk; Wed, 1 Jun 2022 19:29:27 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi100017.china.huawei.com (7.221.188.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 1 Jun 2022 19:30:17 +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; Wed, 1 Jun 2022 19:30:16 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next v9 1/4] block, bfq: support to track if bfqq has pending requests Date: Wed, 1 Jun 2022 19:43:37 +0800 Message-ID: <20220601114340.949953-2-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220601114340.949953-1-yukuai3@huawei.com> References: <20220601114340.949953-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