简体   繁体   中英

Linux kernel - How CPU subsystem(of CGROUPS) different from CPU scheduler?

Linux kernel code here provides, CPU scheduler that has multiple scheduling algorithms for scheduling the processes(including docker container processes).


A control group is a kernel construct, which allows for limiting access to, and accounting for, the usage of the physical resources of a host system, by a group of processes.

Control groups was originally implemented in Linux kernel in 2007.

This version 1 implementation was replaced by version 2 implementation in Linux kernel 4.5. Version 2 fixed some limitations associated with version 1 implementation.

Two of the six CGROUP subsystem in Linux kernel is cpu subsystem & cpuset subsystem .

cpu subsystem controls access to the system's CPU via scheduler

cpuset subsystem pins process belonging in CGROUPS to specific CPU cores or memory nodes.


How CPU scheduler different from cpu subsystem (of CGROUPS)? something to do with default namespace vs multiple namespaces ?

It's difficult to give a "short answer" without much oversimplification. One could write a book on about "CPU scheduling", and another book on "Linux Control Groups".

Instead of "How [is the] CPU scheduler different from... Cgroups?", a better question might be "How are Linux Cgroups different from Linux processes?"

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/ch01

How Control Groups Are Organized

Cgroups are organized hierarchically, like processes, and child cgroups inherit some of the attributes of their parents. However, there are differences between the two models.

The Linux Process Model

All processes on a Linux system are child processes of a common parent: the init process, which is executed by the kernel at boot time and starts other processes (which may in turn start child processes of their own). Because all processes descend from a single parent, the Linux process model is a single hierarchy, or tree.

Additionally, every Linux process except init inherits the environment (such as the PATH variable)[1] and certain other attributes (such as open file descriptors) of its parent process.

The Cgroup Model

Cgroups are similar to processes in that:

  • they are hierarchical, and
  • child cgroups inherit certain attributes from their parent cgroup.

The fundamental difference is that many different hierarchies of cgroups can exist simultaneously on a system. If the Linux process model is a single tree of processes, then the cgroup model is one or more separate, unconnected trees of tasks (ie processes).

Multiple separate hierarchies of cgroups are necessary because each hierarchy is attached to one or more subsystems. A subsystem[2] represents a single resource, such as CPU time or memory.

Returning back to your initial question:

  • The Linux CPU scheduler allocates time to processes.

  • The CONFIG_CGROUP_SCHED group scheduler extension allows tasks to be grouped and divides CPU time fairly among such groups.

Look here for further information:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM