mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH] Remove redundant avg_idle check from sched_balance_newidle
@ 2025-11-27  7:46 Adam Li
  0 siblings, 0 replies; only message in thread
From: Adam Li @ 2025-11-27  7:46 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid, cl,
	linux-kernel, patches, shkaushik, Adam Li

In sched_balance_newidle(), rq->avg_idle is checked against
sd->max_newidle_lb_cost in two places. However these two conditional
checks are logically duplicated:

sched_balance_newidle()
{
	u64 curr_cost = 0;
[...]
	(!get_rd_overloaded(this_rq->rd) ||
		(sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) [1] {
		[...]
		goto out;
	}
	[...]
	sched_balance_update_blocked_averages(this_cpu);
	for_each_domain(this_cpu, sd) {
	[...]
		if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost) [2]
			break;
	[...]
	}
[...]
out:
[...]
}

In the first for_each_domain() loop curr_cost is 0, so conditional check
[1] and [2] are same.

This patch removed conditional check [1]. After the patch, more cpu cycles
might be spent in sched_balance_update_blocked_averages() if [1] is true.
However benchmark shows the patch does not change performance.

Tested with schbench and Specjbb on AmpereOne CPU. The schbench command
is:
./schbench -L -m 4 -M auto -t 256 -n 0 -r 0 -s 0

Signed-off-by: Adam Li <adamli@os.amperecomputing.com>
---
 kernel/sched/fair.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5b752324270b..bbbe48ae6614 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12825,8 +12825,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
 	rcu_read_lock();
 	sd = rcu_dereference_check_sched_domain(this_rq->sd);
 
-	if (!get_rd_overloaded(this_rq->rd) ||
-	    (sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) {
+	if (!get_rd_overloaded(this_rq->rd)) {
 
 		if (sd)
 			update_next_balance(sd, &next_balance);
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-27  7:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27  7:46 [RFC PATCH] Remove redundant avg_idle check from sched_balance_newidle Adam Li

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®