Expand description
Enforcing what a step holds from the resource pools.
The scheduler only reserves: a step that uses more memory or threads
than it holds is not stopped. With resources.enforce on, each step
that runs is given a cgroup of its own, with its memory limit set to
the memory it holds and its CPU quota to its threads, and every process
of the step, its command and its services, is started in it. A step
that goes over its memory is killed by the kernel, and doris says why.
A step that writes more to its working directory than the disk it
holds is stopped by doris.
There are two ways to get the cgroup:
systemd: a transient slice of the userโs systemd manager, made over D-Bus withbusctl, which leaves no unit file behind. Each process is started in a scope in it, withsystemd-run --user --scope. The slice is stopped when the step ends.cgroup: a directory doris makes itself in a cgroup v2 hierarchy it may write to:resources.cgroup, or the cgroup doris was started in, as in a container with a cgroup namespace of its own. Each process moves itself into it betweenforkandexec. The directory is removed when the step ends.
Apart from either, resources.pin pins each step to as many CPUs as it
holds threads, which the scheduler hands out: see allowed_cpus.
Structsยง
- Measured
- What a step used, as its cgroup accounted for it: every process the step started, at once.
- Part
Measured - What one part of a step used: its command or a service, and what that started.
- Quota
- What a step writes to its working directory, held to the disk it holds
from the
diskpool. The directory is measured while the step runs, no more often than measuring it is cheap, and once more when it ends. - Readings ๐
- What reading one cgroup every second has found.
- Sampler ๐
- A thread that reads a stepโs cgroup, and measures its working directory, while the step runs.
- Samples ๐
- Slice
- The cgroup one running stepโs processes are started in. It is removed when it is dropped.
Enumsยง
- Enforce
- How what steps hold is enforced.
- Kind ๐
- Where a stepโs processes are started.
- Measure
- Whether steps are measured in cgroups of their own when nothing is enforced.
Constantsยง
- CGROUP_
FS ๐ - Where cgroup v2 is mounted.
- CONTROLLERS ๐
- The controllers a stepโs cgroup needs.
- OOM_
KILLED - What the message of a step the kernel killed for its memory says, after the memory it held.
- QUOTA_
EVERY ๐ - The least time between two measurements.
- SAMPLE_
EVERY ๐ - How often a cgroup is read while its step runs.
- SYSTEMD_
EXPANDS ๐ - The first systemd version whose
systemd-runexpands variables in the command, and has--expand-environmentto stop it.
Staticsยง
- PARENT ๐
- The cgroup stepsโ cgroups are made in, once it is ready, or why it could not be made ready. The first step that asks makes it ready.
- SLICES ๐
Functionsยง
- allowed_
cpus - The CPUs this process may run on, by number, lowest first.
- cgroups
- How a runโs steps get cgroups: with systemd, by doris, or not at all,
and whether the cgroups have limits. Enforcement has them, and
measures too; otherwise
measuresays how steps are measured. - check_
cgroup - That
diris a cgroup doris can make a cgroup per step in: it has the memory and CPU controllers, and this user may write to it. Its path, or what is wrong.diris dorisโs own cgroup if not given. - cpu_
list - CPUs as
0-3,6, astasksetand systemdโsAllowedCPUswrite them. - cpu_
usage ๐ - A cgroupโs CPU time so far, in microseconds.
- disk_
used - The disk space the files under
dirtake, without following symbolic links. A file with more than one link is counted once for each. - oom_
kills ๐ - How many processes in a cgroup, or its children, the kernel killed for going over a memory limit.
- own_
cgroup ๐ - The cgroup this process is in, on the cgroup v2 hierarchy.
- own_dir ๐
- Make a cgroup in
parent, with the limits if there are any, and return its directory. - parent ๐
- part_
dirs ๐ - Make a child cgroup in
dirfor each ofparts, with the controllers to measure each. A cgroup that hands its controllers to children may not have processes of its own, so with parts, all of a stepโs processes are in them. - part_
slice ๐ - The systemd slice of part
iof the step whose slice isstep: a-makes it a child of the stepโs. - percentile ๐
- The value
pof the way upvalues,pfrom 0 to 1. - pin
- Start
cmdโs process oncpusonly, and those it starts, unless they set their own. Nothing ifcpusis empty. - prepare ๐
- Make
dirready to have a cgroup per step. A cgroup that hands its controllers to its children canโt have processes of its own, unless it is the root, so those in it, doris among them, are moved to a child nameddoris_leaffirst. - read_
number ๐ - remove_
cgroup ๐ - Kill whatever is left in a cgroup doris made, and remove it.
- remove_
children ๐ - Remove the child cgroups of
dirthat have no processes, deepest first. A cgroupโs own files are files, and its children are directories. - sample ๐
- Sample a cgroup,
knownor a systemd unitโs, and itsparts, every second untilstop, and the working directory as often as is cheap. - systemd_
answers ๐ - Whether
systemd-runis there and the userโs systemd manager answers. Asked once. - systemd_
cgroup ๐ - The cgroup directory of a systemd unit, once systemd has made it.
- systemd_
prefix ๐ - What goes between
systemd-runand the program.expandsis whether thissystemd-runexpands environment variables in the command. - systemd_
run_ ๐expands - Whether
systemd-runexpands environment variables in the command it runs. An older one would reject--expand-environment. Asked once. - systemd_
slice ๐ - The name of a slice for a step, made with the limits if there are any.
- systemd_
version ๐ - The version in what
systemd-run --versionprints, such assystemd 260 (260.5). - writable ๐