From: "tip-bot2 for Vineeth Pillai (Google)" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Vineeth Pillai (Google)" <vineeth@bitbyteword.org>,
"Joel Fernandes (Google)" <joel@joelfernandes.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/fair: Update ->next_balance correctly during newidle balance
Date: Fri, 20 Oct 2023 08:02:00 -0000 [thread overview]
Message-ID: <169778892069.3135.14832410141983613183.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20231020014031.919742-3-joel@joelfernandes.org>
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) <vineeth@bitbyteword.org>
AuthorDate: Fri, 20 Oct 2023 01:40:28
Committer: Ingo Molnar <mingo@kernel.org>
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) <joel@joelfernandes.org>
Signed-off-by: Vineeth Pillai (Google) <vineeth@bitbyteword.org>
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Valentin Schneider <vschneid@redhat.com>
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;
next prev parent reply other threads:[~2023-10-20 8:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 1:40 [PATCH 1/3] sched/nohz: Update nohz.next_balance directly without IPIs (v2) Joel Fernandes (Google)
2023-10-20 1:40 ` [PATCH 2/3] sched/nohz: Update comments about NEWILB_KICK Joel Fernandes (Google)
2023-10-20 7:51 ` Ingo Molnar
2023-10-20 8:02 ` [tip: sched/core] " tip-bot2 for Joel Fernandes (Google)
2023-10-20 1:40 ` [PATCH 3/3] sched: Update ->next_balance correctly during newidle balance Joel Fernandes (Google)
2023-10-20 7:53 ` Ingo Molnar
2023-10-20 13:48 ` Vincent Guittot
2023-10-21 6:50 ` Ingo Molnar
2023-10-20 8:02 ` tip-bot2 for Vineeth Pillai (Google) [this message]
2023-10-20 13:40 ` Vincent Guittot
2023-10-20 13:56 ` Ingo Molnar
2023-10-20 15:50 ` Joel Fernandes
2023-10-22 0:28 ` Joel Fernandes
2023-10-26 14:23 ` Vincent Guittot
2023-11-09 10:02 ` Joel Fernandes
2023-11-09 12:31 ` Joel Fernandes
2023-11-14 15:43 ` Vincent Guittot
2023-11-14 17:43 ` Joel Fernandes
2024-06-13 7:13 ` Joel Fernandes
2025-11-25 13:16 ` [PATCH] sched/fair: Only increment deadline once on yield Wang Tao
2025-11-25 13:27 ` [PATCH 3/3] sched: Update ->next_balance correctly during newidle balance Wang Tao
2023-10-20 4:17 ` [PATCH 1/3] sched/nohz: Update nohz.next_balance directly without IPIs (v2) Joel Fernandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=169778892069.3135.14832410141983613183.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bristot@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=joel@joelfernandes.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
--cc=vineeth@bitbyteword.org \
--cc=vschneid@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®