Talk:OpenRC/CGroups

From Gentoo Wiki
Jump to: navigation, search
Note
This is a talk page. Please add newer comments below older ones, and sign your comments using four tildes (~~~~). When adding a new section (at the bottom of the page), please mark it as "open for discussion" by using {{talk|open}} so it will show up in the list of open discussions.

Example: limit memory and I/O for cron jobs

Running rsnapshot could use up a large amount of the system's pagecache, which can cause significant latencies for regular operations like launching new processes / allocating memory (as shown by sys-process/latencytop). To limit the impact of such background jobs on system latency you can limit the amount of memory used by all cron jobs: including the memory used for the file system cache.

https://github.com/Feh/nocache#alternate-approaches shows how to this can be done from the backup script itself.

However using OpenRC you can automatically apply this to all jobs launched from cron. Here is an example if you are using sys-process/cronie:

FILE /etc/conf.d/cronieLimit memory and I/O used by cron jobs
# Settings for the CRON daemon.
# CRONDARGS= :  any extra command-line startup arguments for crond
CRONDARGS=
rc_cgroup_memory="memory.limit_in_bytes 512M"
rc_cgroup_blkio="blkio.weight 100"

# if you want to kill all running cron jobs when stopping or restarting the cron daemon
# then uncomment the follow line
# rc_cgroup_cleanup="yes"
root #service cronie restart

To check that it worked:

root #cat /sys/fs/cgroup/memory/openrc_cronie/memory.limit_in_bytes
root #cat /sys/fs/cgroup/memory/openrc_cronie/tasks; pidof crond

--Edwintorok (talk) 12:24, 9 October 2016 (UTC)

CGroups version 2 and enabled controllers by default?

How does OpenRC enable cgroups version 2? On my Gentoo, the file /sys/fs/cgroup/cgroup.subtree_control is empty. This means that no services have any enabled controllers.

To enable a controller simply do:

root #echo "+cpu +memory" > /sys/fs/cgroup/cgroup.subtree_control

To enable them by default set the following line in rc.conf.

FILE /etc/rc.confEnable CGroups v2 controllers by default
rc_cgroup_controllers="cpu memory io pids"


--Gatak (talk) 10:24, 9 November 2018 (UTC+1)