linux:system:cgroupsv2
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:system:cgroupsv2 [2022/11/20 13:58] – oscar | linux: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 (" | ||
| + | |||
| + | 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, | ||
| + | |||
| 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. | ||
| < | < | ||
| Line 310: | Line 325: | ||
| </ | </ | ||
| + | |||
| + | ===== Using drop-in files ===== | ||
| + | Drop-in files for systemd are fairly trivial to set up. Start by making an appropriate directory based on your service' | ||
| + | |||
| + | # mkdir -p / | ||
| + | |||
| + | These files can be organized any way you like them. They are actioned based on numerical order, so you should name your configuration files something like 10-CPUSettings.conf. All files in this directory should have the file extension .conf and require you to run systemctl daemon-reload every time you adjust one of these files. | ||
| + | |||
| + | I have created two drop-in files to show how you can split out different configurations. The first is 00-slice.conf. As seen below, it sets up the default options for a separate slice for the cat service: | ||
| + | < | ||
| + | [Service] | ||
| + | Slice=AWESOME.slice | ||
| + | MemoryAccounting=yes | ||
| + | CPUAccounting=yes | ||
| + | </ | ||
| + | |||
| + | ===== 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 / | ||
linux/system/cgroupsv2.1668952717.txt.gz · Last modified: by oscar
