Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp857726rdb; Fri, 20 Oct 2023 01:03:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGG5f3EnM0InxYvQFvyVZYdje8zX2GNzCBS3EMuxbktS0Lg7aeGE5RxFKHtT/K/ALBd4Zf3 X-Received: by 2002:aca:d12:0:b0:3a7:6ff5:c628 with SMTP id 18-20020aca0d12000000b003a76ff5c628mr1255457oin.11.1697789017908; Fri, 20 Oct 2023 01:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697789017; cv=none; d=google.com; s=arc-20160816; b=kzxwmo6Fz76Z68yN/69hTed6NA8AtXs15kCAFIUFV/meC/KXXKdTF2Vhs5JJS3v2BA SohnbvnZmLkDq7R0ipt4sSl0pqJOBAJFS0Lq0aegQoBcTdOGBf2e6jIXMehRt/TYNJLV nSG/XTkM9TNXqYfZnx391QChS9KrEqRSqFP+LaD7NtiJRHrJ9mEI9IFmj11aeRX9m6Yq t62qx5QomWzMtZP0PXddUP4Q+lXKM53TFi8iAyFzcGlEBtavRCgXdXRS4PEPVN4aToxu Q5yEhC++NS5hpTwMn0jPluOe5NH6Jl/r2Omc+IvAHisHGWtqg/q5ZG/hvj4KarzDzJf7 ch4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=AVM/DO9hPX/HC+aIcLv1OaWWQdOPuPcK8XTJEhv9K68=; fh=7kaNAJXsDWWiU8BrFhUqgfYKSSCu8IJM01N1jObrlis=; b=HAr9ePXBO02J5l7mpMQPgGZcsOf/Qw94SdMgI4tDiAKi67WPgdlvD/J0siioth2jPp BPZyD78MxS5gbvpT9hriJ5JJUutlkFAvx/rkb8Eepsb1TLTMqQu1F7Wf2AkIE2lzRUQ6 kLvPV3aOBY6Yhp0vxCSuKwB76G1WaaEW005DSInccDe/HuOnoQozizc6FhQJmDtjMmfD BnNNBWiUSvyg9Febmca6hcWiOIfxHXJim8HgcYW82At6d4eZcIY29dd9iK3GPhsTMyTr rfcaKy/p/xjqUI553+SYG5cZ5l1qmtfscxSfA5wuGI9DTu+3DZkOrhw0krkXNVAyicnH DwFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YQgefFkc; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id c7-20020a6566c7000000b005af4cc9e22fsi1297660pgw.840.2023.10.20.01.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:03:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YQgefFkc; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4FB6880BD755; Fri, 20 Oct 2023 01:02:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376500AbjJTICK (ORCPT + 99 others); Fri, 20 Oct 2023 04:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376472AbjJTICG (ORCPT ); Fri, 20 Oct 2023 04:02:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6AC6D64; Fri, 20 Oct 2023 01:02:03 -0700 (PDT) Date: Fri, 20 Oct 2023 08:02:00 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697788921; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AVM/DO9hPX/HC+aIcLv1OaWWQdOPuPcK8XTJEhv9K68=; b=YQgefFkcxhKEHvHDQmIVENrY61IH4mKpcdpRizRCQh0YE7mZvYHsD1+GMY2jiW74XTBtSh rcG4U2OzRF39XRFZ0JpBn2TcHGdPSfyYwnhhpC3q6OSqsxl8Le2EaI65OvN7/fhWx/HQ36 tFZCBrLpRX2LF0OwSNz04fv3g0L01aTFmQcaIB0RfGSmmXGycklW/URGZ0JMGbWhWdWsHb 3mf6hJsxnXm7K3/6YF5OAnBppJOvn/2wE2yz8W/+9ps3Fe9FT1AKs2yJu1HZCGVklYm79S Q1MrOVGZPywkDSJGpuGpvLRy81GkjeTzpWk9/FF7M3RshAcqR4wt4J2Eq8uK6A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697788921; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AVM/DO9hPX/HC+aIcLv1OaWWQdOPuPcK8XTJEhv9K68=; b=ZKC5qXTgpwPVZYH0yhV207Ek01UWQhWPo+gIDne8YD5Kl+HwHJOwuskO0R3408p8RNi2zs JYzkBPIaa3DeD9CA== From: "tip-bot2 for Vineeth Pillai (Google)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Update ->next_balance correctly during newidle balance Cc: "Vineeth Pillai (Google)" , "Joel Fernandes (Google)" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231020014031.919742-3-joel@joelfernandes.org> References: <20231020014031.919742-3-joel@joelfernandes.org> MIME-Version: 1.0 Message-ID: <169778892069.3135.14832410141983613183.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 01:02:27 -0700 (PDT) The following commit has been merged into the sched/core branch of tip: Commit-ID: 1c0482707c42960ec46b88aadd6bffca8685db11 Gitweb: https://git.kernel.org/tip/1c0482707c42960ec46b88aadd6bffca8685db11 Author: Vineeth Pillai (Google) AuthorDate: Fri, 20 Oct 2023 01:40:28 Committer: Ingo Molnar CommitterDate: Fri, 20 Oct 2023 09:56:21 +02:00 sched/fair: Update ->next_balance correctly during newidle balance When newidle balancing triggers, we see that it constantly clobbers rq->next_balance even when there is no newidle balance happening due to the cost estimates. Due to this, we see that periodic load balance (rebalance_domains) may trigger way more often when the CPU is going in and out of idle at a high rate but is no really idle. Repeatedly triggering load balance there is a bad idea as it is a heavy operation. It also causes increases in softirq. Another issue is ->last_balance is not updated after newidle balance causing mistakes in the ->next_balance calculations. Fix by updating last_balance when a newidle load balance actually happens and then updating next_balance. This is also how it is done in other load balance paths. Testing shows a significant drop in softirqs when running: $ cyclictest -i 100 -d 100 --latency=1000 -D 5 -t -m -q ... goes from ~6,000 to ~800. Co-developed-by: Joel Fernandes (Google) Signed-off-by: Vineeth Pillai (Google) Signed-off-by: Joel Fernandes (Google) Signed-off-by: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Cc: Valentin Schneider Link: https://lore.kernel.org/r/20231020014031.919742-3-joel@joelfernandes.org --- kernel/sched/fair.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8c486ff..393d0dc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -12122,11 +12122,7 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) if (!READ_ONCE(this_rq->rd->overload) || (sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) { - - if (sd) - update_next_balance(sd, &next_balance); rcu_read_unlock(); - goto out; } rcu_read_unlock(); @@ -12141,8 +12137,6 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) int continue_balancing = 1; u64 domain_cost; - update_next_balance(sd, &next_balance); - if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost) break; @@ -12155,6 +12149,8 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) t1 = sched_clock_cpu(this_cpu); domain_cost = t1 - t0; update_newidle_cost(sd, domain_cost); + sd->last_balance = jiffies; + update_next_balance(sd, &next_balance); curr_cost += domain_cost; t0 = t1;