[systemd-devel] [PATCH] systemd-cgroup-limits.patch

Lennart Poettering lennart at poettering.net
Mon Aug 22 17:52:12 PDT 2011


On Thu, 14.07.11 13:17, Patrascu, Cristian (Cristian.Patrascu at windriver.com) wrote:

> I've changed the options, it was indeed confusing, sorry for that. 
> Very good observation, Thank you!

> > Patch adds functionality to apply certain cgroups limits, such as shares of cpu, memory limit and blkio.
> > Unit files of type Service, Mount, Swap and Socket have new options (under corresponding [Service], [Mount], [Swap], [Socket] option group ):
> > - "MemoryHardLimit" accepts int64 value (considered bytes), puts the value in "memory" cgroup (if defined) in file "memory.limit_in_bytes" ;
> > - "MemoryLimit" accepts int64 value (considered bytes), puts the value in "memory" cgroup (if defined) in file "memory.soft_limit_in_bytes" ;

Cristian, systemd git now can do what your original patch did though
slightly differently. The code makes it very easy to add high-level
parsers for additional cgroup attributes later on. For now I implemented
support for the attributes you already covered plus a few more. I tried
to keep names similar to the ones you chose. 

    CPUShares=
    MemoryLimit=
    MemorySoftLimit=
    DeviceAllow=
    DeviceDeny=
    BlockIOWeight=
    BlockIOReadBandwidth=
    BlockIOWriteBandwidth=

and the more generic option:

    ControlGroupAttribute=

which allows setting arbitrary cgroup attributes with no explicit
support in systemd.

I added a couple of improvements to the parsers. For example, the memory
and bandwith parameters now take suffixes like K, M, G, T to refer to
Kilobytes and so on. Also, I added support to the BlockIOReadBandwidth=
to take proper device node names instead of major/minor. This is
especially important because major/minor numbers are dynamically
assigned these days and hence will be difficult to use if more than one
block device is used. I also added support for specifying arbitrary
paths to any kind of files in which case we'll automatically determine
the underlying block device. The end result I think is quite simple to
use and very powerful:

    BlockIOReadBandwidth=/home/lennart 5M

which means that the service gets 5M/s read bandwith on the block device
backing /home/lennart.

It's all documented in the man pages.

Sorry this took so long and for not merging your proposed patch. I'd be
very thankful if you could have a closer look on this and check if this
is all you need or where you'd like to see additions/improvements.

Thanks,

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list