HomeFreeBSD

sched_ule: Fix off by one in preempt_thresh definition

Description

sched_ule: Fix off by one in preempt_thresh definition

Since 'preempt_thresh' is set to PRI_MIN_KERN by default, and comparison
of the considered thread's priority with that threshold is done with
'<=', PRI_MIN_KERN threads actually can preempt other threads, contrary
to other non-interrupt kernel ones (between PRI_MIN_KERN + 1 and
PRI_MAX_KERN).

So, replace the comparison operator '<=' by '<'. The alternative would
be to change the default value, but changing the comparison instead has
the benefit to be consistent with the 0 setting (which forbids
preemption entirely), since allowing only threads with priority 0 to
preempt becomes possible.

Consequently, we also change the default value for the FULL_PREEMPTION
option by adding 1 to PRI_MAX_IDLE (in practice, that does not make any
difference in the current setting, since no preemption will happen if
the new priority value is not strictly lower than the current one, and
PRI_MAX_IDLE is PRI_MAX, the highest possible priority).

Reviewed by: markj
Fixes: ae7a6b38d53f ("ULE 3.0: Fine grain scheduler locking and affinity improvements. (...)")
MFC after: 2 weeks
Event: Halifax Hackathon 202606
Location: jrm@'s dining room
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57828

Details

Provenance
olceAuthored on Jun 19 2026, 1:51 AM
Reviewer
markj
Differential Revision
D57828: sched_ule: Fix off by one in preempt_thresh definition
Parents
rGfe7426b2c9f7: nfs_nfsdport.c: Fix a typo in a KASSERT
Branches
Unknown
Tags
Unknown