CGRULES.CONF(5)

πŸŽ€ CGRULES.CONF πŸ’–

okay bestie, welcome to the cgrules.conf page from the libcgroup Manual β€” yeah she's got a manual name and everything, iconic behavior honestly. pull up a chair, grab a boba, we're learning how libcgroup decides which control group your lil process belongs in. 🫢


✨ NAME ✨

cgrules.conf β€” the libcgroup configuration file. that's it, that's the name, short and slay. πŸ’…


🌸 DESCRIPTION 🌸

so here's the tea: the cgrules.conf configuration file is what libcgroup uses to define the control groups that a process belongs to. periodt.

the file is literally just a list of rules, and each rule assigns a control group in a subsystem (or multiple control groups across multiple subsystems, no cap) to a defined group or user. πŸ’–

πŸ“ the two rule formats

rules come in exactly two flavors, and here they are:

<user>                   <controllers>  <destination>  <options>
<user>:<process name>    <controllers>  <destination>  <options>

now let's break down what all those lil placeholders actually mean. πŸ¦‹

πŸ‘‘ what <user> can be

  • a user name
  • a group name, written with the @group syntax
  • the wildcard *, which means any user or group β€” she's for everybody fr fr
  • %, which is equivalent to "ditto" (super useful for multi-line rules where you need different cgroups specified for various hierarchies for a single user)

🧚 what <process name> can be

this one's optional, so if you don't need it, skip her. she can be:

  • a process name
  • a full command path of a process
  • and yes, use quotes '"' for names with spaces in them

πŸŽ›οΈ what <controllers> can be

  • comma separated controller names (no spaces, bestie, none)
  • or * (for all mounted controllers)

🎯 what <destination> can be

  • a path relative to the controller hierarchy (ex. pgrp1/gid1/uid1)
  • or one of the following strings called "templates", which will get expanded:
    • %u β€” uid
    • %U β€” username, uid if name resolving fails
    • %g β€” gid
    • %G β€” group name, gid if name resolving fails
    • %p β€” pid
    • %P β€” process name, pid if name not available

also:

  • '\' can be used to escape %
  • quotation marks '"' can be used for names and/or paths with spaces

βš™οΈ what <options> can be

options is optional (lol) and it can be:

  • "ignore" β€” if a process matches a rule with the "ignore" option, then it will be ignored by cgrulesengd and will not be moved. cgrulesengd processing will stop for this process, and all rules below this rule will not affect this process.
  • "ignore_rt" β€” if a process is scheduled as SCHED_RR or SCHED_FF and matches this rule, it will be ignored by cgrulesengd and will not be moved.

πŸ’€ the rules of the rules

First rule which matches the criteria will be executed. that's it. the first one wins, she doesn't keep looking. main character energy only. πŸ‘‘

any text starting with '#' is considered as a start of comment line and is ignored. so go ahead and leave yourself lil notes, bestie. πŸ’œ

if the destination contains a template string, the control group can be created on-fly. in time when some process wants to use the template rule which leads to control group (see cgexec (1)) and the control group does not exist, the group is created. the template control group parameters can be specified in cgconfig.conf configuration file. see (cgconfig.conf (5)). if the template definition is not found there, created group have default kernel setting. πŸ™ˆ

to create a hierarchy of configuration files, use /etc/cgrules.d directory. nesting era fr. 🌈


πŸ”₯ EXAMPLES πŸ”₯

okay this is the part everyone actually scrolls to. let's go. ✨

student         devices         /usergroup/students

Student's processes in the 'devices' subsystem belong to the control group /usergroup/students. simple, clean, ate.

student:cp       devices         /usergroup/students/cp

When student executes 'cp' command, the processes in the 'devices' subsystem belong to the control group /usergroup/students/cp.

@admin           *              admingroup/

Processes started by anybody from admin group no matter in what subsystem belong to the control group admingroup/. the whole admin crew, no exceptions. πŸ’…

peter           cpu             test1/
%               memory          test2/

The first line says Peter's task for cpu controller belongs to test1 control group. The second one says Peter's tasks for memory controller belong to test2/ control group. that % ditto is doing her lil job, love that for her.

*               *               default/

All processes in any subsystem belong to the control group default/. Since the earliest matched rule is applied, it makes sense to have this line at the end of the list. It will put a task which was not mentioned in the previous rules to default/ control group. it's giving catch-all, and that's the point. πŸŽ€

@students cpu,cpuacct    students/%u

Processes in cpu and cpuacct subsystems started by anybody from students group belong to group students/name. Where "name" is user name of owner of the process.

@students:"Web Browser"       cpu         "/usergroup/students/Internet Apps"

When anyone from the students group launches the "Web Browser" application, the processes in the 'cpu' subsystem belong to the control group "/usergroup/students/Internet Apps". Spaces are permitted in process names and control cgroup paths when enclosed within quotes. yes, spaces! the quotes are carrying this entire rule on their back. 😭


πŸ—‚οΈ FILES πŸ—‚οΈ

  • /etc/cgrules.conf β€” default libcgroup configuration file
  • /etc/cgrules.d β€” default libcgroup configuration files directory

πŸ‘€ SEE ALSO πŸ‘€

cgconfig.conf (5), cgclassify (1), cgred.conf (5), cgrules.d (5)

iykyk β€” go read those next, bestie. πŸ¦‹


πŸ’€ BUGS πŸ’€

nothing listed here. literally nothing. she's bug-free (allegedly). πŸ™ˆ


and that's the whole page, bestie β€” no cap. this was libcgroup Manual, version/date 2009-03-10, and the page goes by CGRULES.CONF(5) on a Linux system. go forth and configure those cgroups, you absolute icon. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­

πŸ“¦ where this page comes from