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 – jepler 于 2017-06-28
Note: if this PR is merged, then #295 need not be merged, since master branch will get the fix by merge-up