Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp293129lqe; Sat, 6 Apr 2024 01:09:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUTZDIThZxCMEyCl8GF29ZvSaTq6SgmgPy6JKgsPzZTsD/zFJ4M0I2RTo9x5MNa/LcBgXnblg/l9erGztupxxrkZZ4GS52Au5GlhNto8g== X-Google-Smtp-Source: AGHT+IHsb5zTSi7P2g4i027CgFDmfYg1nDj8TIDkQmVDWrxlH54N92zs5Hh5DTQW6kYfTIAI+MXf X-Received: by 2002:a17:906:c2d8:b0:a51:9531:ced8 with SMTP id ch24-20020a170906c2d800b00a519531ced8mr2287972ejb.67.1712390984396; Sat, 06 Apr 2024 01:09:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712390984; cv=pass; d=google.com; s=arc-20160816; b=C63KT4seaUb6UFL9l9YYU7RprhEuD4N/Ij4I/xVKHljjRVFvPNOExEcHSV2ZQzVDXS 9romqSEIXYkJjBbU0956/EZjQn9qmaaM9/hQ6q2/5Y0PzRBBmzG8gqhvjkuqM6NwY582 te67k5lqYqGbRpKbhpw8Rl/k//g3i07Muf7zJW7QQHFavhaFIWQZsTtOY6ty19iqpA3q 19LLvhJOm4RtRIWYHz9BSFhgfwo/A5LQg70cAWPB4RBDeKTFcwdA2YomvyKAgUZqaXcq gbr6tOz5HYE82d4OaR6axlxZ8WRqRjaiUAGuyYvIsU24hc88jMCWBDuTSG++t+UZ7qhk /tbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=kH6zNAnGN0SnJiR/erFO+4hIvEK3+k4kuSwKBjKzgrw=; fh=4XKyS2Sm8fzjg1nTQMNo9APn8qz/MI9Pn3UU4jQ9MSE=; b=WsJYDBdWg1RgcFHMmu6QTYN5yC8T6tvUmAlyP2eFItEoTyWA1yb5BDGjr8qemVfeFU f9EjVQPNnzZk3m/25RIDF8wVS20/RmJe9YBN8KmhEKe475/o6UOftro5o2lB2VH3TsCy 5lATR8FjmLMqJpiB0BxosdEFEi0uqc3X65OQPy9MBz9XU2YTg2T9xRvYbeT1clnSqoL3 rz9KEib17FXx3jNBF3jNmYafYEA4iJWKlqjQPV+aVfOfxb+Xluq39Z5JGqjKg74+RuF5 cMtxQTdnJD22byIlA9MsK27HWzM55B7eUUTz5zC+iuNj0iF19AYRblDyHSoYvpYj5M4H dy2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-133846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133846-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qw33-20020a1709066a2100b00a4e2541005bsi1572011ejc.454.2024.04.06.01.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 01:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-133846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133846-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 243A91F22287 for ; Sat, 6 Apr 2024 08:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09F7D2BAE3; Sat, 6 Apr 2024 08:09:17 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98A5022F02; Sat, 6 Apr 2024 08:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712390956; cv=none; b=EPkhY8v6rzbdp4pwrtBWwKRj3xLvd0wOSB1r72qs96kfpPfEJGgrobqQbRsYvBireicl1UwwK22DDQfEsDDZekxUmnBeYbbF5WJlMU+TF9NpM5lSvN0V5//sjm8/fGl8XCK3RQmlOSl5z5WdEUdFuc2LHa/muYBWJqfYFlnoUpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712390956; c=relaxed/simple; bh=RGeLpQq1tNqBVU02itqj6kS9o7uyCx/gUkBGHq49FmQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E2bmnZnw6XL5Gp8Or9SnYmybqvFAK7I/ttnQNnXliUq2OZNt6VRZ2A9fNZo6fVQjRQMtMfAaQ4DJic/WZB2McHQ1qEbCFDf1dI4/wpLjHi2Mo61x7HPyadWOipqnzMxDQys6N1nbTFgRkxY6bNow+rwhZGiABHNZgwLZXqNz9v4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VBSg316Nlz4f3lVx; Sat, 6 Apr 2024 16:09:03 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9C4B91A016E; Sat, 6 Apr 2024 16:09:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDHlxAjAxFmnZTkJA--.2125S7; Sat, 06 Apr 2024 16:09:11 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, chenhuacai@kernel.org, tj@kernel.org, josef@toxicpanda.com, jhs@mojatatu.com, svenjoac@gmx.de, raven@themaw.net, pctammela@mojatatu.com, yukuai3@huawei.com, qde@naccy.de, zhaotianrui@loongson.cn Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, cgroups@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 3/6] blk-throttle: expand tg_conf_updated() to return if any tg has rules Date: Sat, 6 Apr 2024 16:00:56 +0800 Message-Id: <20240406080059.2248314-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240406080059.2248314-1-yukuai1@huaweicloud.com> References: <20240406080059.2248314-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgDHlxAjAxFmnZTkJA--.2125S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr47Kr4xtry3ur17GryDJrb_yoW5Jr48pF yUAa1UJw4DZFs09rsxJr1qgFWFqan7Zryaq393Ww4rtr4aqwnYgFn0vryruayrAF93uF4x ZrsrtrWYkF109FDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8Jw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUojjgUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai There are no functional changes yet, prepare to destroy blk-throttle when it's disabled. Signed-off-by: Yu Kuai --- block/blk-throttle.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/block/blk-throttle.c b/block/blk-throttle.c index acb2758f45ef..b371442131fe 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c @@ -320,9 +320,10 @@ static void throtl_pd_init(struct blkg_policy_data *pd) * This doesn't require walking up to the top of the hierarchy as the * parent's has_rules[] is guaranteed to be correct. */ -static void tg_update_has_rules(struct throtl_grp *tg) +static bool tg_update_has_rules(struct throtl_grp *tg) { struct throtl_grp *parent_tg = sq_to_tg(tg->service_queue.parent_sq); + bool has_rules = false; int rw; for (rw = READ; rw <= WRITE; rw++) { @@ -332,7 +333,11 @@ static void tg_update_has_rules(struct throtl_grp *tg) tg->has_rules_bps[rw] = (parent_tg && parent_tg->has_rules_bps[rw]) || tg_bps_limit(tg, rw) != U64_MAX; + if (tg->has_rules_iops[rw] || tg->has_rules_bps[rw]) + has_rules = true; } + + return has_rules; } static void throtl_pd_online(struct blkg_policy_data *pd) @@ -1163,11 +1168,12 @@ static int tg_print_conf_uint(struct seq_file *sf, void *v) return 0; } -static void tg_conf_updated(struct throtl_grp *tg, bool global) +static bool tg_conf_updated(struct throtl_grp *tg, bool global) { struct throtl_service_queue *sq = &tg->service_queue; struct cgroup_subsys_state *pos_css; struct blkcg_gq *blkg; + bool has_rules = false; throtl_log(&tg->service_queue, "limit change rbps=%llu wbps=%llu riops=%u wiops=%u", @@ -1187,7 +1193,8 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global) struct throtl_grp *this_tg = blkg_to_tg(blkg); struct throtl_grp *parent_tg; - tg_update_has_rules(this_tg); + if (tg_update_has_rules(this_tg)) + has_rules = true; /* ignore root/second level */ if (!cgroup_subsys_on_dfl(io_cgrp_subsys) || !blkg->parent || !blkg->parent->parent) @@ -1211,6 +1218,8 @@ static void tg_conf_updated(struct throtl_grp *tg, bool global) tg_update_disptime(tg); throtl_schedule_next_dispatch(sq->parent_sq, true); } + + return has_rules; } static int blk_throtl_init(struct gendisk *disk) -- 2.39.2