From patchwork Fri Oct 20 08:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 155866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp896311vqb; Fri, 20 Oct 2023 01:03:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENAtRVd4cs5iwvf92w4EEeFgJpjNX3OH8jvt63s9KfPVH5BSQ8EBBDHsd1iqlEJYK6A2R1 X-Received: by 2002:aca:2319:0:b0:3b2:e34f:3495 with SMTP id e25-20020aca2319000000b003b2e34f3495mr1206726oie.33.1697789016485; Fri, 20 Oct 2023 01:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697789016; cv=none; d=google.com; s=arc-20160816; b=Jx2ZNhM7amkaRw786KiyR4k5V+esDHFKX2HoNpnbbydeMUVOlRhNnJeIQ2756BPWW2 3+DB6u3jAvZ4QTgQkpD1r/KXD+zbJl4HcTe1uuQeGrpMIQmDerLLwDU2aYhdAWEt9Vhg C7pu2UW9J6y8CmOh1xyvfZ8OFNXXyAn7dL4G66tX+OYYI6cRiNAP4vS91wSKOaKKpkmX t7hqiuCs4l/AgK7uTaF56mzkxg4vjI6JCOcIPekhwOhVRTEVS8SSrNBPcPEaj5zOstzX R3XuYpIl2bbRfETjjHOBeUmaPspKZyNGojB9lHBGEbtnzh4QALmEP69pnt4xS7qQtg/Q mLHA== 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 header.b=ZKC5qXTg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b137-20020a63348f000000b005ac154f0feesi1300854pga.279.2023.10.20.01.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; 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 header.b=ZKC5qXTg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id C104A82372E8; Fri, 20 Oct 2023 01:02:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376510AbjJTICL (ORCPT + 25 others); Fri, 20 Oct 2023 04:02:11 -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 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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 01:02:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780260815362852038 X-GMAIL-MSGID: 1780260815362852038 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;