Future Proof Your Applications - Avoid Breakdowns with cgroup changes

steam20 22 views 20 slides Sep 14, 2025
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

cgroup v1 vs v2 changes


Slide Content

Future-Proof Your Applications:
Avoid Breakdowns with cgroup
Changes!
Kamalesh Babulal, Tom Hromatka
[email protected], [email protected]
Oracle Cloud Infrastructure
August 5
th
, 2025

The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied
upon in making purchasing decisions. The development, release, timing, and pricing
of any features or functionality described for Oracle’s products may change and
remains at the sole discretion of Oracle Corporation.
Safe harbor statement
2 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025

“cgroup is a mechanism to organize
processes hierarchically and distribute
system resources along the hierarchy in a
controlled and configurable manner.”
Documentation/admin-guide/cgroup-v2.rst
Kernel Source
Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 20253

Demo
Introduction to cgroup
4 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025

Jan 2008
cgroup v1
(v2.6.24)
memory,
blkio (IO)
(v3.16)
Aug 2014
cgroup v2
(v3.16)*
RDMA
(v4.11)
Apr 2017
*mount -t cgroup -o __DEVEL__sane_behavior cgroup <mount-point>
Jan 2016
cgroup v2
(v4.5)
cpu
(v4.15)
Jan 2018
PSI
(v4.20)
Dec 2018
cpuset v2
(v5.0)
Mar 2019
freezer
(v5.2)
July 2019
hugeTLB
(v5.6)
Mar 2020
misc
(v5.13)
July 2021
libcgroup v0.34
cgroup v1
Jun 2009
libcgroup v2.0
cgroup v2
May 2021
libcgroup v3.1
systemd support
July 2023
systemd
cgroup v1
Mar 2010
Systemd v232
cgroup v2
Nov 2016
Systemd v244
default cgroup v2
Dec 2019
dmem
(v6.14)
Dec 2024
5 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
cgroup Introduction
The Timeline

6 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
cgroup Introduction
cgroup v1 hierarchy
blkio
cpu
cpuacct
IOdevices
cpuset
freezer
dmem
misc
hugetlb
memory
netcls
perf_event
net_prio
rdma
pids
debug
DB Insights
D1 ……. Dn I1 ……. In
Insights
InsightsDB Insights
D1 ……. Dn I1 ……. In
cpu.shares = 3072 cpu.shares = 1024memory.limit_in_bytes = 1G memory.limit_in_bytes = -1
/sys/fs/cgroup

cgroup Introduction
cgroup v1 vs cgroup v2 hierarchy
7 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
cpu
DB Insights
D1 ……. Dn
/
mycgrp echo `+cpu +memory` > cgroup.subtree
I1 ……. In
cpu.shares=1024
cpu.weight=300
memory.max=1G
D1 ……. Dn I1 ……. In
DB Insights
memory
memory.limit_in_bytes=1G memory.limit_in_bytes=-1
DB Insights
D1 ……. Dn I1 ……. In
cpu.weight=100
memory.max=max
cpu.shares=3072

cgroup Introduction
Hierarchy How To
Bash

# cd /sys/fs/cgroup/

# echo "+cpu +memory" >
cgroup.subtree_control

# echo "300" > db/cpu.weight

# echo "100" > insights/cpu.weight

# echo "1G" > db/memory.max
libcgroup

cgcreate -gcpu,memory db

cgcreate -gcpu,memory insights

cgset -r cpu.weight=300 \
-r memory.max=1G db

cgset -r cpu.weight=100 insights
man cgconfig.conf – libcgroup configuration file
systemd

systemd-run --scope \
--unit=db.scope \
--slice=demo.slice \
-p CPUWeight=300 \
-p MemoryMax=1G sleep 1000

systemd-run --scope \
--unit=insights.scope \
--slice=demo.slice \
-p CPUWeight=100 sleep 1000
8 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025

cgroup Transition
cgroup v1 vs cgroup v2
9 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
cpu
DB Insights
D1 ……. Dn
/
mycgrp
echo `+cpu +memory` > cgroup.subtree_control
I1 ……. In
cpu.shares=1024
cpu.weight=300
memory.max=1G
D1 ……. Dn
I1 ……. In
DB Insights
memory
memory.limit_in_bytes=1G memory.limit_in_bytes=-1
DB Insights
D1 ……. Dn I1 ……. In
cpu.weight=100
memory.max=max
cpu.shares=3072
multi-hierarchyunified-hierarchy

cgroup Transition
Constraints
10 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
/
mycgrp
echo `+cpu +memory` > cgroup.subtree_control
cpu.weight=300
memory.max=1G
DB Insights
D1 ……. Dn I1 ……. In
cpu.weight=100
memory.max=max
●Top-Down Constraint
●Resources from the parent cgroup are distributed among
children cgroups
●No Internal Process Constraint
●Processes are allowed only in leaf cgroup
●Delegation
●Allowing non-root users to manage their sub-tree hierarchy
cpu.weight=400
memory.max=1G

cgroup Transition
11 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
CPU controller
cpu.shares ⏵ cpu.weight
cpu.cfs_period_us ⏵ cpu.max (second field)
cpu.cfs_quota_us ⏵ cpu.max (first field)
memory controller
memory.limits_in_bytes ⏵memory.max
memory.soft_limit_in_bytes ⏵memory.high
memory.swappiness ⏵memory.swap.max
blkio (IO) controller
blkio.weight ⏵ io.weight
blkio.throttle.read_bps_device⏵ io.max
blkio.throttle.wrtie_bps_device⏵ io.max
blkio.throttle.read_iops_device⏵ io.max
blkio.throttle.write_iops_device⏵ io.max
pids controller
pids.max ⏵ pids.max
cpusets controller
cpuset.cpus ⏵ cpuset.cpus
cpuset.mems ⏵ cpuset.mems
cpuset.cpu_exclusive ⏵ cpuset.cpu.exclusive
cpuset.cpu.partition
Enabling cgroup v1 controllers:
CONFIG_MEMCG_V1 (v6.11)
CONFIG_CPUSETS_V1 (v6.12)
Mapping Examples

Demo
Introduction to libcgroup
abstractions
12 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025

cgroup v2 QoS
Finer granularity control
13 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
memory.min
memory.low
memory.high
memory.max
memory cpu IO
cpu.weight
cpu.max
io.weight
io.max
memory.min = 1024M # 1GB
memory.low = 1536M # 1.5GB
memory.high = 2048M # 2GB
memory.max = 2560M # 2.5GB
cpu.weight = 300 # 3x
cpu.max = 800000 1000000 # 80% of cpu
io.weight = 800 # 8x IO bandwidth
io.max = 259:0 rbps=209715200 wbps=104857600
riops=5000 wiops=2000 # read/write bandwidth/IOPS

Demo
Introduction to PSI
14 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025

Thank you
Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 202515

Backup Slides
Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 202517

Demo
Introduction to cgroup
18 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
Terminal 1
# cgcreate -gcpu:db
# cgcreate -gcpu:insights
# cgexec -gcpu:db stress-ng --cpu 0 --timeout 1800s &
# cgexec -gcpu:insights stress-ng –-cpu 0 --timeout 1800s &
# cgset -r cpu.weight=300 db
Terminal 2
# systemd-cgtop

Demo
Introduction to libcgroup
abstractions
19 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
Terminal 1
# cgcreate -gcpu:insights
# cgget -r cpu.weight insights
# cgxset -1 -r cpu.shares=512 insights
# cgget -r cpu.weight insights

Demo
Introduction to PSI
20 Copyright © 2025, Oracle and/or its affiliates | Open Source Summit, Hyderabad 2025
Terminal 1
# cgcreate -gcpu,memory:insights
# cgexec -gmemory:insights stress-ng --vm 2 --vm-bytes 4G \
--vm-keep &
Terminal 2
# watch -n 0.1 "cat /sys/fs/cgroup/insights/memory.pressure"
Monitoring
<some|full> <stall amount is us> <time window in us>
Use select(), poll() or epoll()
# cgset -r memory.pressure="some 150000 1000000 foo"
Take the example from https://docs.kernel.org/accounting/psi.html#psi (Changed to cgroup
insights from global memory pressure)