Skip to main content

Module enforce

Module enforce 

Source
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 with busctl, which leaves no unit file behind. Each process is started in a scope in it, with systemd-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 between fork and exec. 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.
PartMeasured
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 disk pool. 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-run expands variables in the command, and has --expand-environment to 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 measure says how steps are measured.
check_cgroup
That dir is 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. dir is dorisโ€™s own cgroup if not given.
cpu_list
CPUs as 0-3,6, as taskset and systemdโ€™s AllowedCPUs write them.
cpu_usage ๐Ÿ”’
A cgroupโ€™s CPU time so far, in microseconds.
disk_used
The disk space the files under dir take, 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 dir for each of parts, 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 i of the step whose slice is step: a - makes it a child of the stepโ€™s.
percentile ๐Ÿ”’
The value p of the way up values, p from 0 to 1.
pin
Start cmdโ€™s process on cpus only, and those it starts, unless they set their own. Nothing if cpus is empty.
prepare ๐Ÿ”’
Make dir ready 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 named doris_leaf first.
read_number ๐Ÿ”’
remove_cgroup ๐Ÿ”’
Kill whatever is left in a cgroup doris made, and remove it.
remove_children ๐Ÿ”’
Remove the child cgroups of dir that have no processes, deepest first. A cgroupโ€™s own files are files, and its children are directories.
sample ๐Ÿ”’
Sample a cgroup, known or a systemd unitโ€™s, and its parts, every second until stop, and the working directory as often as is cheap.
systemd_answers ๐Ÿ”’
Whether systemd-run is 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-run and the program. expands is whether this systemd-run expands environment variables in the command.
systemd_run_expands ๐Ÿ”’
Whether systemd-run expands 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 --version prints, such as systemd 260 (260.5).
writable ๐Ÿ”’