Re: [gentoo-user] cgroups and OpenRC: Am I doing it wrong?

2021-07-16 Thread tastytea
On 2021-07-15 09:58+0200 tastytea  wrote:

> www-apps/gitea often used all 4 of my CPU cores and slowed everything
> else down. So I attempted to limit CPU usage with cgroups:
> 
> I have set this in /etc/rc.conf:
> 
> rc_cgroup_mode="unified"
> rc_cgroup_controllers="cpu memory io pids"
> 
> And this in /etc/conf.d/gitea:
> 
> rc_cgroup_settings="
> cpu.shares 128
> cpu.cfs_period_us 100
> cpu.cfs_quota_us  100
> memory.limit_in_bytes 8G
> "

The error was that I used documentation for cgroups v1 instead of v2¹.
臘The right values are:

rc_cgroup_settings="
cpu.max 100 100
memory.high 7G
memory.max 8G
"

¹ 

-- 
Get my PGP key with `gpg --locate-keys tasty...@tastytea.de` or at
.


pgpRHV5KnZVpQ.pgp
Description: Digitale Signatur von OpenPGP


Re: [gentoo-user] cgroups and OpenRC: Am I doing it wrong?

2021-07-16 Thread tastytea
On 2021-07-15 09:58+0200 tastytea  wrote:

> […] did I do someting wrong? How can I check if my settings are
> applied?

I've tried to set the nice value of my emacs daemon with 

rc_cgroup_settings="
cpu.weight.nice -10
"

/sys/fs/cgroup/emacs.tastytea/cpu.weight.nice shows -10 but htop says
that the nice value is 0.

-- 
Get my PGP key with `gpg --locate-keys tasty...@tastytea.de` or at
.


pgpt2i5zJfWCh.pgp
Description: Digitale Signatur von OpenPGP


[gentoo-user] cgroups and OpenRC: Am I doing it wrong?

2021-07-15 Thread tastytea
www-apps/gitea often used all 4 of my CPU cores and slowed everything
else down. So I attempted to limit CPU usage with cgroups:

I have set this in /etc/rc.conf:

rc_cgroup_mode="unified"
rc_cgroup_controllers="cpu memory io pids"

And this in /etc/conf.d/gitea:

rc_cgroup_settings="
cpu.shares 128
cpu.cfs_period_us 100
cpu.cfs_quota_us  100
memory.limit_in_bytes 8G
"

According to my research, setting cpu.cfs_period_us and
cpu.cfs_quota_us to the same value should ensure that only the power of
one core is used, and “cpu.shares 128” should only use 12.5% (half a
core in my case) of the CPU if the system is under load. The CPU usage
in htop should be at most 100%, right?. However, I often see 110%,
sometimes up to 180% and rarely 230%. Are that all accounting errors or
did I do someting wrong? How can I check if my settings are applied?

/sys/fs/cgroup/gitea/cgroup.threads contains all the gitea-pids and the
pids of its child processes.

$ zgrep CGROUP /proc/config.gz
CONFIG_CGROUPS=y
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_WRITEBACK=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
# CONFIG_CGROUP_RDMA is not set
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_PERF=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_SOCK_CGROUP_DATA=y
CONFIG_BLK_CGROUP_RWSTAT=y
# CONFIG_BLK_CGROUP_IOLATENCY is not set
# CONFIG_BLK_CGROUP_IOCOST is not set
# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set
CONFIG_NET_CLS_CGROUP=y
CONFIG_CGROUP_NET_PRIO=y
CONFIG_CGROUP_NET_CLASSID=y

$ mount | grep cgroup
none on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime)

Kind regards, tastytea

-- 
Get my PGP key with `gpg --locate-keys tasty...@tastytea.de` or at
.


pgp22u1wy0oXj.pgp
Description: Digitale Signatur von OpenPGP