From Gentoo Wiki
Jump to: navigation, search

Cgroups Overview

OpenRC cgroup implementation follows FDO recommendations. Openrc creates it's own named controller (openrc) and creates hierarchy for each service names 'openrc_$servicename', if service setting require additional cgroup controller openrc creates same hierarchy in that controller.

Turning cgroup support on

Cgroups is available only on Linux. To use cgroups in OpenRC you should turn then in kernel, this switch controls whether or not group for each controller is mounter under /sys/fs/cgroup.

All other features will work only if you will set

File/etc/rc.confAdd cgroups features


Setting limits

For each cgroup controller one can create special variables of the form:


This options can be added in rc.conf file then they will be applied to all services, however, if you will set it in service.conf file that option will be applied only to that service.

For example, you would use this to set the cpu.shares setting in the cpu controller to 512 for your service.

cpu.shares 512

For more information about the adjustments that can be made with cgroups, see Documentation/cgroups/* in the linux kernel source tree.

Service Cleanup

It's possible to trigger killing all service process tree (in process cgroup) when services is stopped or restarted. By setting

File/etc/conf.d/<service>an example of triggering cgroup cleanup


This option should not be set globally as it will kill all service's child processes e.g. SSH connections or apache workers, as OpenRC doesn't support automatic process cgroup-relocation as it done in logind services.

Service death notification


Possible Improvements

  • system notification about cleared cgroups (can be done via sh user script)
  • grouping cgroups subsystems together
  • support for userlevel cgroups

Openrc cgroup architecture

TODO: shortly describe architecture