NOTE This is PR relative to master branch, but we should consider whether to port it back to 2.7, because it affects that version. (however, it is not a regression)
Before this change, uspace assumed that online CPU numbers were consecutive, and attempted to schedule the real time tasks on the highest numbered CPU. For example, if SCNPROCESSORS_ONLN returns 8, then it is assumed that the online processors are 0-7, and processor number 7 is selected for real time tasks.
This is not always the case. For example, on a D525 with HT turned off via BIOS, it is reported that SCNPROCESSORS_ONLN is 2 and the online processors are 0,2. The old algorithm chooses processor number 1 for realtime, so no realtime thread is ever run.
While my HT system (i7-4790K) can turn off HT in the BIOS, it gets online processors 0-3 when this is done, so the buggy behavior is not provoked. However, if I take a CPU offline which is not the highest numbered CPU, e.g., with
$ sudo sh -c ‘echo 0 > /sys/devices/system/cpu/cpu6/online’
I can provoke the reported behavior. After this change, cpu number 7 is again selected (correctly) instead of cpu number 6 (incorrectly).
Closes: #294
Signed-off-by: Jeff Epler
#1 – SebKuzminsky 于 2017-06-29
PR #296 merged into 2.7, so this one is no longer needed.