[systemd-devel] Question related to cgroup and systemd
Francis Moreau
francis.moro at gmail.com
Fri Sep 18 05:45:35 PDT 2015
Hello Lennart,
On Fri, Sep 18, 2015 at 2:24 PM, Lennart Poettering
<lennart at poettering.net> wrote:
> B1;4002;0cOn Fri, 18.09.15 14:11, Francis Moreau (francis.moro at gmail.com) wrote:
>
>> Hi,
>>
>> I'm trying to understand how cgroup is used by systemd and having the
>> following behaviour that I don't understand.
>>
>> I've created a slice "myslice.slice" with this resource constraint
>> "MemoryLimit=1024" and started it.
>>
>> I was expecting to find a trace of myslice in /sys/fs/cgroup/memory
>> folder but I can't find anything.
>
> systemd realizes croups only when we add processes to it.
>
>> I put a process inside the slice (with the help of systemd-run
>> --slice=myslice), but nothing was created under /sys/fs/cgroup/memory
>> either.
>
> So, this works fine for me:
>
> # systemd-run --slice=my-deep-slice.slice -p MemoryLimit=3G /bin/sleep 99999
>
> It creates the specified slice, and places the new service in it, then
> adds the process in it and sets the memory.limit_in_bytes= attribute
> on the services' cgroup.
>
> Does this not work for you?
I dont think so:
$ cat ~/.config/systemd/user/myslice.slice
[Slice]
MemoryLimit=1024
$ systemctl --user start myslice.slice
$ systemctl --user status myslice.slice
● myslice.slice
Loaded: loaded (/home/fmoreau/.config/systemd/user/myslice.slice;
static; vendor preset: enabled)
Active: active since Fri 2015-09-18 14:35:59 CEST; 4s ago
Sep 18 14:35:59 cyclone systemd[752]: Created slice myslice.slice.
$ systemd-run --user --slice=myslice.slice /bin/sleep 99999
Running as unit run-793.service.
$ systemctl --user status myslice.slice
● myslice.slice
Loaded: loaded (/home/fmoreau/.config/systemd/user/myslice.slice;
static; vendor preset: enabled)
Active: active since Fri 2015-09-18 14:35:59 CEST; 1min 29s ago
CGroup: /user.slice/user-1000.slice/user at 1000.service/myslice.slice
└─run-793.service
└─794 /bin/sleep 99999
Sep 18 14:35:59 cyclone systemd[752]: Created slice myslice.slice.
$ find /sys/fs/cgroup/memory/ -name myslice\*
$
$ find /sys/fs/cgroup/systemd/ -name myslice\*
/sys/fs/cgroup/systemd/user.slice/user-1000.slice/user at 1000.service/myslice.slice
> Which systemd version are you using?
systemd 225-1 (Archlinux).
>> I was expecting that "myslice.slice" would have its own directory
>> inside /sys/fs/cgroup/memory directory (ie inside the memory
>> controller) and the memory constraint applied to that directory and
>> hence all its children.
>
> Correct. But again, we only realize groups when we really need to.
>
Ok understood.
>> But it seems I'm missing something.
>>
>> Could anybody enlight me please ?
>>
>> Also I'm a bit lost regarding kernel cgroup and its reworked API. Does
>> systemd already use this new API or is it still using the old/broken
>> one ?
>
> Yes, the concept of scopes, services and slices and how they are
> mapped to cgroupfs is fully implemented. We currently don't expose all
> controllers and all settings, but that's mostly because the
> controllers are awful and in progress of being fixed, and we only want
> to expose them as soon as they are cleaned up and here to stay with
> their new settings.
>
> In the most recent systemd release we even support the new kernel
> unified hierarchy now, but you have to select at boot time which one
> you want: the legacy one as before, or the unified one.
>
Which kernel version starts to support the new unified hierarchy ? Is
there a doc which explain it ?
Thanks.
--
Francis
More information about the systemd-devel
mailing list