Search code examples
linuxoperating-systemcfs

Does every single CPU core own a red-black tree for CFS?


CFS scheduler uses red-black lock to hold the processes to be scheduled, i am not sure whether there is a global tree or one tree for one CPU core? I think the later is more efficient, but i can not find any proof.


Solution

  • There is one CFS runqueue (implemented as red black tree) per CPU group (structure sched_group). Each CPU group contains one single physical CPU in SMP mode (Symmetric Multiprocessing), so there is one CFS runqueue per CPU.

    You can see some information about these runqueues, for each CPU: cfs_rq[0], cfs_rq[1], etc. by displaying /proc/sched_debug (if you kernel has been compiled with CONFIG_SCHED_DEBUG).

    Some details in sched-domains.txt and in sched-design-CFS.txt