HomeFreeBSD

runq: runq_not_empty() to support racy lookups again

Description

runq: runq_not_empty() to support racy lookups again

The 4BSD assumes that its sched_runnable(), which then calls
runq_not_empty(), can be called racily (another CPU may be grabbing
a thread from the global queue at the same time).

This makes runq_not_empty() trip on an assertion in runq_find()
detecting a mismatch between some bit in the status word and the state
of the corresponding queue (empty/not empty).

Re-implement runq_not_empty() in an independent and simpler way as an
alternative to removing the assertion, which remains useful to detect
races when removing or adding a thread in some runqueue.

Fixes: 79f68322c892 ("runq: runq_check(): Re-implement on top of runq_findq()")
MFC after: 1 month
Event: Kitchener-Waterloo Hackathon 202506
Sponsored by: The FreeBSD Foundation

Details

Provenance
olceAuthored on Jun 20 2025, 2:36 AM
Parents
rG3e5aeb20645f: runq: Fix printing status word bits
Branches
Unknown
Tags
Unknown