History

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.

Boqun Feng committed 3 months ago

Commit 560fcaa1 parent ac4231a1 file · +1 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/sched/core.c+1−1
@@ -9241,7 +9241,7 @@ void __cant_migrate(const char *file, int line) · 9240 unmodified lines
92419241 if (!IS_ENABLED(CONFIG_PREEMPT_COUNT))
92429242 return;
92439243
9244− if (preempt_count() > 0)
9244+ if (preempt_count())
92459245 return;
92469246
92479247 if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)