[systemd-devel] [PATCH 2/2] Libcgroup: added cgconfig.service unit for systemd.

Jan Safranek jsafrane at redhat.com
Wed Dec 14 03:46:34 PST 2011


On 12/13/2011 01:31 PM, Lennart Poettering wrote:
> On Tue, 13.12.11 13:06, Jan Safranek (jsafrane at redhat.com) wrote:
> 
>>
>> On 12/13/2011 12:46 PM, Lennart Poettering wrote:
>>> On Fri, 09.12.11 15:32, Jan Safranek (jsafrane at redhat.com) wrote:
>>
>> <snip>
>>
>>> Note that this will set up the cgroup structure only during late boot,
>>> which should be fine for most cases. However, in some cases it might
>>> make sense to initialize this due to early boot (for example, to handle
>>> early-boot service, like udev).if you care for those add lines like
>>> the following:
>>>
>>> DefaultDependencies=no
>>> Conflicts=shutdown.target
>>> Before=basic.target shutdown.target
>>
>> I expect that the services that needs cgroups would have
>> "After=cgconfig.service" and systemd will start cgconfig before any of
>> them, regardless how early in the boot it is. In the end I might not
>> need any After/Before in cgconfig.conf at all. Of course, admin must add
>> this "After=cgconfig.service" manually to all dependent services, but he
>> already needs to add "ControlGroup=..." there.
> 
> Well, this is mostly what happens, except that early boot services are
> a bit special. 
> 
> i.e. normal services are implicitly ordered after basic.target. An early
> boot service is not, and even usually ordered before
> basic.target. Therefore, if your service cgconfig.service is not marked
> as early boot service it will be ordered after basic.target, and hence
> we'd have an ordering loop against an early boot service, if it wants to
> be started after cgconfig.service...
> 
> But maybe it's not worth thinking about this too much, since early boot
> services are special anyway, and we can still think about this if
> there's actaully somebody who wants to move an early boot service into
> an arbitrary cgroup.
> 
>> I would end up with this simple service in the end:
>>
>> [Unit]
>> DefaultDependencies=no
>>
>> [Service]
>> Type=oneshot
>> RemainAfterExit=yes
>> ExecStart=/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664
>> ExecStop=/sbin/cgclear -l /etc/cgconfig.conf -e
>>
>> [Install]
>> WantedBy=sysinit.target
>>
>> Could this work?
> 
> I'd recommend adding this too:
> 
> Conflicts=shutdown.target
> Before=basic.target shutdown.target
> 
> Otherwise we'd not invoke the stop binary on shutdown. And the
> Before=basic.target ensures that the cgroup tree is fully set up before
> normal services are started, which might not be necessary, but might
> still make sense?

Agreed, I'll add Conflicts/Before as you suggest. On my fedora 16 I am
able to put udev to a control group this way. Thanks for your help!

Jan



More information about the systemd-devel mailing list