mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Ingo Molnar" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	"Joel Fernandes (Google)" <joel@joelfernandes.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/nohz: Remove unnecessarily complex error handling pattern from find_new_ilb()
Date: Mon, 09 Oct 2023 10:26:10 -0000	[thread overview]
Message-ID: <169684717032.3135.17626767741431018350.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20231006102518.2452758-4-mingo@kernel.org>

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     f4bb5705114530cd775a5a649b666755b3efe7aa
Gitweb:        https://git.kernel.org/tip/f4bb5705114530cd775a5a649b666755b3efe7aa
Author:        Ingo Molnar <mingo@kernel.org>
AuthorDate:    Fri, 06 Oct 2023 12:25:18 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 09 Oct 2023 12:21:23 +02:00

sched/nohz: Remove unnecessarily complex error handling pattern from find_new_ilb()

find_new_ilb() returns nr_cpu_ids on failure - which is the usual
cpumask bitops return pattern, but is weird & unnecessary in this
context: not only is it a global variable, it it is a +1 out of
bounds CPU index and also has different signedness ...

Its only user, kick_ilb(), then checks the return against nr_cpu_ids
to decide to return. There's no other use.

So instead of this, use a standard -1 return on failure to find an
idle CPU, as the argument is signed already.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Link: https://lore.kernel.org/r/20231006102518.2452758-4-mingo@kernel.org
---
 kernel/sched/fair.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f82b301..19bb4ac 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -11528,7 +11528,7 @@ static inline int find_new_ilb(void)
 			return ilb_cpu;
 	}
 
-	return nr_cpu_ids;
+	return -1;
 }
 
 /*
@@ -11549,8 +11549,7 @@ static void kick_ilb(unsigned int flags)
 		nohz.next_balance = jiffies+1;
 
 	ilb_cpu = find_new_ilb();
-
-	if (ilb_cpu >= nr_cpu_ids)
+	if (ilb_cpu < 0)
 		return;
 
 	/*

  parent reply	other threads:[~2023-10-09 10:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 10:25 [PATCH 0/3] sched/nohz: Misc minor cleanups to the NOHZ idle balancing code Ingo Molnar
2023-10-06 10:25 ` [PATCH 1/3] sched/nohz: Update idle load-balancing (ILB) comments Ingo Molnar
2023-10-09 10:26   ` [tip: sched/core] " tip-bot2 for Ingo Molnar
2023-10-09 15:12   ` [PATCH 1/3] " Valentin Schneider
2023-10-06 10:25 ` [PATCH 2/3] sched/nohz: Use consistent variable names in find_new_ilb() and kick_ilb() Ingo Molnar
2023-10-09 10:26   ` [tip: sched/core] " tip-bot2 for Ingo Molnar
2023-10-09 15:12   ` [PATCH 2/3] " Valentin Schneider
2023-10-06 10:25 ` [PATCH 3/3] sched/nohz: Remove weird error handling from find_new_ilb() Ingo Molnar
2023-10-06 10:38   ` Peter Zijlstra
2023-10-06 11:01     ` Ingo Molnar
2023-10-09 15:11       ` Valentin Schneider
2023-10-09 10:26   ` tip-bot2 for Ingo Molnar [this message]
2023-10-08 16:56 ` [PATCH 0/3] sched/nohz: Misc minor cleanups to the NOHZ idle balancing code 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=169684717032.3135.17626767741431018350.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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®