From patchwork Sat Mar 5 09:12:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 12770292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 826C2C433FE for ; Sat, 5 Mar 2022 08:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbiCEI5q (ORCPT ); Sat, 5 Mar 2022 03:57:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbiCEI5j (ORCPT ); Sat, 5 Mar 2022 03:57:39 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23BC4269A77; Sat, 5 Mar 2022 00:56:48 -0800 (PST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4K9dpl6Jk5zdcJs; Sat, 5 Mar 2022 16:55:27 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Sat, 5 Mar 2022 16:56:46 +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.2308.21; Sat, 5 Mar 2022 16:56:46 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [PATCH -next 09/11] block, bfq: move forward __bfq_weights_tree_remove() Date: Sat, 5 Mar 2022 17:12:03 +0800 Message-ID: <20220305091205.4188398-10-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220305091205.4188398-1-yukuai3@huawei.com> References: <20220305091205.4188398-1-yukuai3@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Prepare to decrease 'num_groups_with_pending_reqs' earlier. Signed-off-by: Yu Kuai --- block/bfq-iosched.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 2a48c40b4f02..f221e9cab4d0 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -979,6 +979,19 @@ void bfq_weights_tree_remove(struct bfq_data *bfqd, { struct bfq_entity *entity = bfqq->entity.parent; + /* + * grab a ref to prevent bfqq to be freed in + * __bfq_weights_tree_remove + */ + bfqq->ref++; + + /* + * remove bfqq from weights tree first, so that how many queues have + * pending requests in parent bfqg is updated. + */ + __bfq_weights_tree_remove(bfqd, bfqq, + &bfqd->queue_weights_tree); + for_each_entity(entity) { struct bfq_sched_data *sd = entity->my_sched_data; @@ -1013,14 +1026,7 @@ void bfq_weights_tree_remove(struct bfq_data *bfqd, } } - /* - * Next function is invoked last, because it causes bfqq to be - * freed if the following holds: bfqq is not in service and - * has no dispatched request. DO NOT use bfqq after the next - * function invocation. - */ - __bfq_weights_tree_remove(bfqd, bfqq, - &bfqd->queue_weights_tree); + bfq_put_queue(bfqq); } /*