summaryrefslogtreecommitdiff
path: root/src/core/cgroup.c
AgeCommit message (Collapse)Author
2014-11-05core: introduce new Delegate=yes/no property controlling creation of cgroup ↵Lennart Poettering
subhierarchies For priviliged units this resource control property ensures that the processes have all controllers systemd manages enabled. For unpriviliged services (those with User= set) this ensures that access rights to the service cgroup is granted to the user in question, to create further subgroups. Note that this only applies to the name=systemd hierarchy though, as access to other controllers is not safe for unpriviliged processes. Delegate=yes should be set for container scopes where a systemd instance inside the container shall manage the hierarchies below its own cgroup and have access to all controllers. Delegate=yes should also be set for user@.service, so that systemd --user can run, controlling its own cgroup tree. This commit changes machined, systemd-nspawn@.service and user@.service to set this boolean, in order to ensure that container management will just work, and the user systemd instance can run fine.
2014-09-29Do not format USEC_INFINITY as NULLZbigniew Jędrzejewski-Szmek
systemctl would print 'CPUQuotaPerSecUSec=(null)' for no limit. This does not look right. Since USEC_INFINITY is one of the valid values, format_timespan() could return NULL, and we should wrap every use of it in strna() or similar. But most callers didn't do that, and it seems more robust to return a string ("infinity") that makes sense most of the time, even if in some places the result will not be grammatically correct.
2014-08-22core: split up "starting" manager state into "initializing" and "starting"Lennart Poettering
We'll stay in "initializing" until basic.target has reached, at which point we will enter "starting". This is preparation so that we can change the startip timeout to only apply to the first phase of startup, not the full procedure.
2014-08-15cgroup: only generate warnings if actually writing to cgroup attributes failedLennart Poettering
2014-08-15cgroup: downgrade log messages about non-existant cgroup attributes to LOG_DEBUGLennart Poettering
2014-07-29time-util: add and use USEC/NSEC_INFINIYKay Sievers
2014-07-20test-engine: fix access to unit load pathZbigniew Jędrzejewski-Szmek
Also add a bit of debugging output to help diagnose problems, add missing units, and simplify cppflags. Move test-engine to normal tests from manual tests, it should now work without destroying the system.
2014-05-22cgroups: simplify CPUQuota= logicLennart Poettering
Only accept cpu quota values in percentages, get rid of period definition. It's not clear whether the CFS period controllable per-cgroup even has a future in the kernel, hence let's simplify all this, hardcode the period to 100ms and only accept percentage based quota values.
2014-05-22cgroups: always propagate controller membership to siblings, for all controllersLennart Poettering
This is the behaviour the kernel cgroup rework exposes for all controllers, hence let's do this already now for all cases.
2014-05-22cgroup: rework startup logicLennart Poettering
Introduce a (unsigned long) -1 as "unset" state for cpu shares/block io weights, and keep the startup unit set around all the time.
2014-05-22core: add startup resource control optionWaLyong Cho
Similar to CPUShares= and BlockIOWeight= respectively. However only assign the specified weight during startup. Each control group attribute is re-assigned as weight by CPUShares=weight and BlockIOWeight=weight after startup. If not CPUShares= or BlockIOWeight= be specified, then the attribute is re-assigned to each default attribute value. (default cpu.shares=1024, blkio.weight=1000) If only CPUShares=weight or BlockIOWeight=weight be specified, then that implies StartupCPUShares=weight and StartupBlockIOWeight=weight.
2014-05-08core: check the right variable for failed open()Łukasz Stelmach
2014-05-05core: require cgroups filesystem to be availableKay Sievers
We should no longer pretend that we can run in any sensible way without the kernel supporting us with cgroups functionality.
2014-04-25core: expose CFS CPU time quota as high-level unit propertiesLennart Poettering
2014-03-19core: make sure we can combine DevicePolicy=closed with PrivateDevices=yesLennart Poettering
if PrivateDevices=yes is used we need to make sure we can still create /dev/null and so on.
2014-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering
safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
2014-03-11core: support globbing matches in DeviceAllow= when checking for device groupsLennart Poettering
2014-02-24cgroup: certain cgroup attributes are not available in the root cgroup, ↵Lennart Poettering
hence don't bother
2014-02-22cgroup: Extend DeviceAllow= syntax to whitelist groups of devices, not just ↵Lennart Poettering
particular devices nodes
2014-02-19update TODOLennart Poettering
2014-02-17doc: update punctuationJan Engelhardt
Resolve spotted issues related to missing or extraneous commas, dashes.
2014-02-17core: find the closest parent slice that has a specfic cgroup controller ↵Lennart Poettering
enabled when enabling/disabling cgroup controllers for units
2014-02-17core: rework cgroup mask propagationLennart Poettering
Previously a cgroup setting down tree would result in cgroup membership additions being propagated up the tree and to the siblings, however a unit could never lose cgroup memberships again. With this change we'll make sure that both cgroup additions and removals propagate properly.
2013-11-22cgroups: Cache controller masks and optimize queues.David Strauss
2013-11-09systemd: fix memory leak in cgroup codeZbigniew Jędrzejewski-Szmek
If the unit already was in the hashmap, path would be leaked.
2013-11-06Comment spelling fixes.David Strauss
2013-11-06cgroup: run PID 1 in the root cgroupLennart Poettering
This way cleaning up the cgroup tree on shutdown is a lot easier since we are in the root dir. Also PID 1 was previously artificially placed in system.slice, even though our rule actually was not to have processes in slices. The root slice otoh is magic anyway, so having PID 1 in there sounds less surprising. Of course, this means that PID is scheduled against the three top-level slices.
2013-10-14list: make our list macros a bit easier to use by not requring type spec on ↵Lennart Poettering
each invocation We can determine the list entry type via the typeof() gcc construct, and so we should to make the macros much shorter to use.
2013-09-25cgroup: if we do a cgroup operation then do something on all supported ↵Lennart Poettering
controllers Previously we did operations like attach, trim or migrate only on the controllers that were enabled for a specific unit. With this changes we will now do them for all supproted controllers, and fall back to all possible prefix paths if the specified paths do not exist. This fixes issues if a controller is being disabled for a unit where it was previously enabled, and makes sure that all processes stay as "far down" the tree as groups exist.
2013-09-23cgroup: always enable memory.use_hierarchy= for all cgroups in the memory ↵Lennart Poettering
hierarchy The non-hierarchial mode contradicts the whole idea of a cgroup tree so let's not support this. In the future the kernel will only support the hierarchial logic anyway.
2013-09-17cgroup: get rid of MemorySoftLimit=Lennart Poettering
The cgroup attribute memory.soft_limit_in_bytes is unlikely to stay around in the kernel for good, so let's not expose it for now. We can readd something like it later when the kernel guys decided on a final API for this.
2013-09-16cgroup: add missing equals for BlockIOWeightGao feng
2013-09-13core/cgroup: first print then freeLukas Nykryn
2013-09-13cgroup: fix incorrectly setting memory cgroupGao feng
If the memory_limit of unit is -1, we should write "-1" to the file memory.limit_in_bytes. not the (unit64_t) -1. otherwise the memory.limit_in_bytes will be set to zero.
2013-09-13cgroup: correct the log informationGao feng
it should be memory.soft_limit_in_bytes.
2013-09-13cgroup: add the missing setting of variable's valueGao feng
set the value of variable "r" to the return value of cg_set_attribute.
2013-08-28Do not realloc strings, which are already in the hashmap as keysHarald Hoyer
This prevents corruption of the hashmap, because we would free() the keys in the hashmap, if the unit is already in there, with the same cgroup path.
2013-08-28Revert "cgroup.c: check return value of unit_realize_cgroup_now()"Harald Hoyer
This reverts commit 1f11a0cdfe397cc404d61ee679fc12f58c0a885b.
2013-08-23cgroup.c: check return value of unit_realize_cgroup_now()Harald Hoyer
do not recurse further, if unit_realize_cgroup_now() failed
2013-07-11cgroup: split out per-device BlockIOWeight= setting into BlockIODeviceWeight=Lennart Poettering
This way we can nicely map the configuration directive to properties and back, without requiring two different signatures for the same property.
2013-07-11cgroup: don't ever try to destroy the cgroup of the root sliceLennart Poettering
The root slice is after all the root cgroup, so don't attempt to delete it.
2013-07-11cgroup: don't move systemd into systems.slice when running as --user instanceLennart Poettering
2013-07-10cgroup: downgrade error message when we cannot remove a cgroup to debugLennart Poettering
Some units set KillMode=none to survive the initrd→rootfs transition. We cannot remove their cgroups, but that shouldn't really be considered an issue, so let's downgrade the error message.
2013-07-02core: don't consider a unit's cgroup empty if only a subcgroup runs emptyLennart Poettering
2013-07-01cgroup: implicitly add units to GC queue when their cgroups run emptyLennart Poettering
2013-07-01cgroup: readd proper cgroup empty trackingLennart Poettering
2013-06-27core: general cgroup reworkLennart Poettering
Replace the very generic cgroup hookup with a much simpler one. With this change only the high-level cgroup settings remain, the ability to set arbitrary cgroup attributes is removed, so is support for adding units to arbitrary cgroup controllers or setting arbitrary paths for them (especially paths that are different for the various controllers). This also introduces a new -.slice root slice, that is the parent of system.slice and friends. This enables easy admin configuration of root-level cgrouo properties. This replaces DeviceDeny= by DevicePolicy=, and implicitly adds in /dev/null, /dev/zero and friends if DeviceAllow= is used (unless this is turned off by DevicePolicy=).
2013-06-20logind: add infrastructure to keep track of machines, and move to slicesLennart Poettering
- This changes all logind cgroup objects to use slice objects rather than fixed croup locations. - logind can now collect minimal information about running VMs/containers. As fixed cgroup locations can no longer be used we need an entity that keeps track of machine cgroups in whatever slice they might be located. Since logind already keeps track of users, sessions and seats this is a trivial addition. - nspawn will now register with logind and pass various bits of metadata along. A new option "--slice=" has been added to place the container in a specific slice. - loginctl gained commands to list, introspect and terminate machines. - user.slice and machine.slice will now be pulled in by logind.service, since only logind.service requires this slice.
2013-06-17core: add new .slice unit type for partitioning systemsLennart Poettering
In order to prepare for the kernel cgroup rework, let's introduce a new unit type to systemd, the "slice". Slices can be arranged in a tree and are useful to partition resources freely and hierarchally by the user. Each service unit can now be assigned to one of these slices, and later on login users and machines may too. Slices translate pretty directly to the cgroup hierarchy, and the various objects can be assigned to any of the slices in the tree.
2013-04-16nspawn: introduce the new /machine/ tree in the cgroup tree and move ↵Lennart Poettering
containers there Containers will now carry a label (normally derived from the root directory name, but configurable by the user), and the container's root cgroup is /machine/<label>. This label is called "machine name", and can cover both containers and VMs (as soon as libvirt also makes use of /machine/). libsystemd-login can be used to query the machine name from a process. This patch also includes numerous clean-ups for the cgroup code.