| 1 | There are three major cgroup configuration directives: |
| 2 | |
| 3 | 1. Global top-level group: `init`, `system`, `user`, or a custom group |
| 4 | 2. Selecting a top-level group for a set of run/task/services |
| 5 | 3. Per run/task/service limits |
| 6 | |
| 7 | > [!NOTE] |
| 8 | > Linux cgroups and details surrounding values are not explained in the |
| 9 | > Finit documentation. The Linux admin-guide cover this well: |
| 10 | > <https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html> |
| 11 | |
| 12 | Top-level Group Configuration |
| 13 | ----------------------------- |
| 14 | |
| 15 | # Top-level cgroups and their default settings. All groups mandatory |
| 16 | # but more can be added, max 8 groups in total currently. The cgroup |
| 17 | # 'root' is also available, reserved for RT processes. Settings are |
| 18 | # as-is, only one shorthand 'mem.' exists, other than that it's the |
| 19 | # cgroup v2 controller default names. |
| 20 | cgroup init cpu.weight:100 |
| 21 | cgroup user cpu.weight:100 |
| 22 | cgroup system cpu.weight:9800 |
| 23 | |
| 24 | Adding an extra cgroup `maint/` will require you to adjust the weight of |
| 25 | the above three. We leave `init/` and `user/` as-is reducing weight of |
| 26 | `system/` to 9700. |
| 27 | |
| 28 | cgroup system cpu.weight:9700 |
| 29 | |
| 30 | # Example extra cgroup 'maint' |
| 31 | cgroup maint cpu.weight:100 |
| 32 | |
| 33 | By default, the `system/` cgroup is selected for almost everything. The |
| 34 | `init/` cgroup is reserved for PID 1 itself and its closest relatives. |
| 35 | The `user/` cgroup is for local TTY logins spawned by getty. |
| 36 | |
| 37 | Selecting Cgroups |
| 38 | ------------------ |
| 39 | |
| 40 | To select a different top-level cgroup, e.g. `maint/`, one can either |
| 41 | define it for a group of run/task/service directives in a `.conf` or per |
| 42 | each stanza: |
| 43 | |
| 44 | cgroup.maint |
| 45 | service [...] <...> /path/to/foo args -- description |
| 46 | service [...] <...> /path/to/bar args -- description |
| 47 | |
| 48 | or |
| 49 | |
| 50 | service [...] <...> cgroup.maint /path/to/foo args -- description |
| 51 | |
| 52 | The latter form also allows per-stanza limits on the form: |
| 53 | |
| 54 | service [...] <...> cgroup.maint:cpu.max:10000,mem.max:655360 /path/to/foo args -- description |
| 55 | |
| 56 | Notice the comma separation and the `mem.` exception to the rule: every |
| 57 | cgroup setting maps directly to cgroup v2 syntax. I.e., `cpu.max` maps |
| 58 | to the file `/sys/fs/cgroup/maint/foo/cpu.max`. There is no filtering, |
| 59 | except for expanding the shorthand `mem.` to `memory.`, if the file is |
| 60 | not available, either the cgroup controller is not available in your |
| 61 | Linux kernel, or the name is misspelled. |
| 62 | |
| 63 | A daemon using `SCHED_RR` currently need to run outside the default cgroups. |
| 64 | |
| 65 | service [...] <...> cgroup.root /path/to/daemon arg -- Real-Time process |