[systemd-devel] What do I need to do to force systemd to create folders in the cgroups tree?
Barry Scott
barry.scott at onelan.co.uk
Mon Jan 27 03:46:45 PST 2014
For my application I have three slices. Two of these are working,
onelan.slice and onelan-screen.slice, but onelan-player.slice is
not causing the cgroup folders to come into existence.
I put a dependency on workaround-systemd-cgroup-limitations-onelan-player-
slice.service to cause onelan-player.slice to be created. That slice will
be used later to hold processes create via the dbus start transient interface.
But when that services run I see the following cgroups:
# find /sys/fs/cgroup -name '*.slice' -print
/sys/fs/cgroup/memory/onelan.slice
/sys/fs/cgroup/cpuacct/onelan.slice
/sys/fs/cgroup/cpuacct/onelan.slice/onelan-screen.slice
/sys/fs/cgroup/cpuacct/onelan.slice/onelan-player.slice
/sys/fs/cgroup/cpu/onelan.slice
/sys/fs/cgroup/cpu/onelan.slice/onelan-screen.slice
/sys/fs/cgroup/cpu/onelan.slice/onelan-player.slice
/sys/fs/cgroup/systemd/user.slice
/sys/fs/cgroup/systemd/onelan.slice
/sys/fs/cgroup/systemd/onelan.slice/onelan-screen.slice
/sys/fs/cgroup/systemd/onelan.slice/onelan-player.slice
/sys/fs/cgroup/systemd/system.slice
/sys/fs/cgroup/systemd/system.slice/system-lvm2\x2dpvscan.slice
/sys/fs/cgroup/systemd/system.slice/system-systemd\x2dfsck.slice
/sys/fs/cgroup/systemd/system.slice/system-systemd\x2dbacklight.slice
/sys/fs/cgroup/systemd/system.slice/system-getty.slice
I expect to have /sys/fs/cgroup/memory/onelan.slice/onelan-player.slice
but it does not exist.
What do I need to do to force it to be created?
Here is the content of involved unit files and status from systemd.
# cat /etc/systemd/system/workaround-systemd-cgroup-limitations-onelan-player-
slice.service
[Unit]
Description="workaround systemd cgroup limitations service"
After=workaround-systemd-cgroup-limitations-onelan-slice.service
Requires=workaround-systemd-cgroup-limitations-onelan-slice.service
[Service]
Slice=onelan-player.slice
Type=oneshot
StandardOutput=syslog
ExecStart=/usr/local/onelan/systemd/workaround-systemd-cgroup-limitations
onelan-player.slice
RemainAfterExit=yes
# cat /usr/local/onelan/systemd/workaround-systemd-cgroup-limitations
#!/bin/bash
#
# Copyright 2014 (c) ONELAN Ltd. www.onelan.co.uk
# All rights reserved.
#
#
# workaround-systemd-cgroup-limitations
#
# As of systemd 208 it is not possible to setup all
# the cgroup attributes that we need.
#
# As soon as systemd aquires a method of doing the
# additional cgroup setup this module and its .service
# can be deleted.
#
set -e
function set_attr {
VALUE=$1
CGATTR=$2
echo Info: Set ${VALUE} into ${CGATTR}
echo ${VALUE} >${CGATTR}
}
case "$1" in
onelan.slice)
find /sys/fs/cgroup -name '*.slice' -print >/root/onelan.slice.log
CGROUP=/sys/fs/cgroup/cpu/onelan.slice
set_attr 1000000000 ${CGROUP}/cpu.rt_period_us
set_attr 900000000 ${CGROUP}/cpu.rt_runtime_us
;;
onelan-player.slice)
find /sys/fs/cgroup -name '*.slice' -print >/root/onelan-player.slice.log
CGROUP=/sys/fs/cgroup/memory/onelan.slice/onelan-players.slice
LINE=$( grep '#SwapMemoryLimit' /etc/onelan/ntb/systemd-player-memory-
limits.include )
LIMIT=${LINE#*=}
set_attr ${LIMIT} ${CGROUP}/memory.memsw.limit_in_bytes
;;
*)
exit 1
;;
esac
# cat /etc/systemd/system/onelan-players.slice
[Unit]
Description=ONELAN Players Slice
DefaultDependencies=no
Before=slices.target
Wants=onelan.slice
After=onelan.slice
[Slice]
CPUAccounting=true
MemoryAccounting=true
.include /etc/onelan/ntb/systemd-player-memory-limits.include
# cat /etc/onelan/ntb/systemd-player-memory-limits.include
[Slice]
MemoryLimit=3217719296
#SwapMemoryLimit=5365202944
# systemctl status onelan-player.slice
onelan-player.slice
Loaded: loaded
Active: active since Mon 2014-01-27 10:43:20 GMT; 24min ago
Barry
More information about the systemd-devel
mailing list