[tip: locking/core] sched: Avoid signed comparison of preempt_count() in __cant_migrate()

"tip-bot2 for Boqun Feng" <[email protected]>
Newsgroups gmane.linux.kernel
Message-ID <178622210558.442315.2431817868495969988.tip-bot2@tip-bot2>
The following commit has been merged into the locking/core branch of tip:

Commit-ID:     31f35d04a29a7554bb3b9ad827dd37c2942e31d4
Gitweb:        https://git.kernel.org/tip/31f35d04a29a7554bb3b9ad827dd37c2942e31d4
Author:        Boqun Feng <[email protected]>
AuthorDate:    Tue, 04 Aug 2026 09:14:31 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Sat, 08 Aug 2026 22:44:08 +02:00

sched: Avoid signed comparison of preempt_count() in __cant_migrate()

Currently preempt_count() is always a non-negative int on all archs
(PREEMPT_NEED_RESCHED archs will mask out the MSB when returning
preempt_count()), hence the checking in __cant_migrate() is in fact just
checking whether preempt_count() is 0 or not. In a future change, we are
going to use all the 32 bits of preempt_count(), which would make
negative int values possible from preempt_count(). Therefore convert the
"> 0" comparison into a zero check to prepare for the future change.
No functional changes are intended.

Signed-off-by: Boqun Feng <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://patch.msgid.link/[email protected]
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index aa116da..9b3f176 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9241,7 +9241,7 @@ void __cant_migrate(const char *file, int line)
 	if (!IS_ENABLED(CONFIG_PREEMPT_COUNT))
 		return;
 
-	if (preempt_count() > 0)
+	if (preempt_count())
 		return;
 
 	if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.