User Tools

Site Tools


linux:system:cgroupsv2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:system:cgroupsv2 [2022/11/20 14:58] – [Using drop-in files] oscarlinux:system:cgroupsv2 [2022/11/20 15:35] (current) – [Cgroups with systemd] oscar
Line 265: Line 265:
  
 ====== Cgroups with systemd ====== ====== Cgroups with systemd ======
 +All processes running on the system are child processes of the systemd init process. Systemd provides three unit types that are used for the purpose of resource control:
 +
 +  - **Service** — A process or a group of processes, which systemd started based on a unit configuration file. Services encapsulate the specified processes so that they can be started and stopped as one set. Services are named in the following way: name.service.
 +  - **Scope** — A group of externally created processes. Scopes encapsulate processes that are started and stopped by arbitrary processes through the fork() function and then registered by systemd at runtime. For instance, user sessions, containers, and virtual machines are treated as scopes. Scopes are named as follows: name.scope.
 +  - **Slice** — A group of hierarchically organized units. Slices do not contain processes, they organize a hierarchy in which scopes and services are placed. The actual processes are contained in scopes or in services. In this hierarchical tree, every name of a slice unit corresponds to the path to a location in the hierarchy. The dash ("-") character acts as a separator of the path components. For example, if the name of a slice looks as follows: parent-name.slice. It means that a slice called parent-name.slice is a subslice of the parent.slice. This slice can have its own subslice named parent-name-name2.slice, and so on.There is one root slice denoted as: **-.slice**.
 +
 +Services, scopes, and slices are created manually by the system administrator or dynamically by programs. By default, the operating system defines a number of built-in services that are necessary to run the system. Also, there are four slices created by default:
 +
 +  - **-.slice** — the root slice;
 +  - **system.slice** — the default place for all system services;
 +  - **user.slice** — the default place for all user sessions;
 +  - **machine.slice** — the default place for all virtual machines and Linux containers. 
 +
 +Note that all user sessions are automatically placed in a separated scope unit, as well as virtual machines and container processes. Furthermore, all users are assigned with an implicit subslice. Besides the above default configuration, the system administrator can define new slices and assign services and scopes to them. 
 +
 By default, systemd creates a new cgroup under the system.slice for each service it monitors.  By default, systemd creates a new cgroup under the system.slice for each service it monitors. 
 <code> <code>
Line 324: Line 339:
 MemoryAccounting=yes MemoryAccounting=yes
 CPUAccounting=yes CPUAccounting=yes
-<code>+</code> 
 + 
 +===== Using systemctl set-property ===== 
 +The last method that can be used to configure cgroups is the systemctl set-property command, which places the files in /etc/systemd/system.control. These files are not to be edited by hand. Not every property is recognized by the set-property command, so the Slice definition was put in the service file itself. 
linux/system/cgroupsv2.1668956326.txt.gz · Last modified: by oscar