mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adam Li <adamli@os.amperecomputing.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org
Cc: dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	cl@linux.com, linux-kernel@vger.kernel.org,
	patches@amperecomputing.com, shkaushik@amperecomputing.com,
	Adam Li <adamli@os.amperecomputing.com>
Subject: [RFC PATCH] Remove redundant avg_idle check from sched_balance_newidle
Date: Thu, 27 Nov 2025 07:46:12 +0000	[thread overview]
Message-ID: <20251127074612.147150-1-adamli@os.amperecomputing.com> (raw)

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


                 reply	other threads:[~2025-11-27  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251127074612.147150-1-adamli@os.amperecomputing.com \
    --to=adamli@os.amperecomputing.com \
    --cc=bsegall@google.com \
    --cc=cl@linux.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=patches@amperecomputing.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shkaushik@amperecomputing.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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®