Let's try something interesting: we shall create a new sub-group under the cgroups v2 hierarchy on the system. We'll then set up a CPU controller for it, run a couple of test processes (that hammer away on the system's CPU cores), and set a user-specified upper limit on how much CPU bandwidth these processes can actually make use of!
Here, we outline the steps you will typically take to do this (all of these steps require you to be running with root access):
- Ensure your kernel supports cgroups v2:
- You should be running on a 4.5 or later kernel.
- In the presence of mixed cgroups (both legacy v1 and newer v2, which, as of the time of writing, is the default), check that your kernel command line includes the cgroup_no_v1=all string. Here, we shall assume that the cgroup v2 hierarchy is supported and mounted at /sys/fs/cgroup.
- Add a cpu controller to the cgroups v2 hierarchy; this is achieved by doing this, as...