Commit graph

36856 commits

Author SHA1 Message Date
Lennart Poettering 27c4ed790a cgroup: simplify check whether it makes sense to realize a cgroup 2018-11-23 13:41:37 +01:00
Lennart Poettering e00068e71f cgroup: in unit_invalidate_cgroup() actually modify invalidation mask
Previously this would manipulate the realization mask for invalidating
the realization. This is a bit ugly though as the realization mask's
primary purpose to is to reflect in which hierarchies a cgroup currently
exists, and it's probably a good idea to keep that in sync with
realities.

We nowadays have the an explicit fields for invalidating cgroup
controller information, the "cgroup_invalidated_mask", let's use this
one instead.

The effect is pretty much the same, as the main consumer of these masks
(unit_has_mask_realize()) checks both anyway.
2018-11-23 13:41:37 +01:00
Lennart Poettering 27adcc9737 cgroup: be more careful with which controllers we can enable/disable on a cgroup
This changes cg_enable_everywhere() to return which controllers are
enabled for the specified cgroup. This information is then used to
correctly track the enablement mask currently in effect for a unit.
Moreover, when we try to turn off a controller, and this works, then
this is indicates that the parent unit might succesfully turn it off
now, too as our unit might have kept it busy.

So far, when realizing cgroups, i.e. when syncing up the kernel
representation of relevant cgroups with our own idea we would strictly
work from the root to the leaves. This is generally a good approach, as
when controllers are enabled this has to happen in root-to-leaves order.
However, when controllers are disabled this has to happen in the
opposite order: in leaves-to-root order (this is because controllers can
only be enabled in a child if it is already enabled in the parent, and
if it shall be disabled in the parent then it has to be disabled in the
child first, otherwise it is considered busy when it is attempted to
remove it in the parent).

To make things complicated when invalidating a unit's cgroup membershup
systemd can actually turn off some controllers previously turned on at
the very same time as it turns on other controllers previously turned
off. In such a case we have to work up leaves-to-root *and*
root-to-leaves right after each other. With this patch this is
implemented: we still generally operate root-to-leaves, but as soon as
we noticed we successfully turned off a controller previously turned on
for a cgroup we'll re-enqueue the cgroup realization for all parents of
a unit, thus implementing leaves-to-root where necessary.
2018-11-23 13:41:37 +01:00
Lennart Poettering 94f344fb03 cgroup: tweak log message, so that it doesn't claim we always enable controllers when we actually disable them 2018-11-23 12:24:37 +01:00
Lennart Poettering 54b5ba1d1f cgroup: propagate errors when we cannot open cgroup.subtree_control 2018-11-23 12:24:37 +01:00
Lennart Poettering 26a17ca280 cgroup: add explanatory comment 2018-11-23 12:24:37 +01:00
Lennart Poettering 442ce7759c cgroup: units that aren't loaded properly should not result in cgroup controllers being pulled in
This shouldn't make much difference in real life, but is a bit cleaner.
2018-11-23 12:24:37 +01:00
Lennart Poettering 0adf88b68c cgroup: dump delegation mask too 2018-11-23 12:24:37 +01:00
Lennart Poettering 1649244588 cgroup: make unit_get_needs_bpf_firewall() static too 2018-11-23 12:24:37 +01:00
Lennart Poettering 53aea74a60 cgroup: make some functions static 2018-11-23 12:24:37 +01:00
Lennart Poettering 52fecf20b9 cgroup: fine tune when to apply cgroup attributes to the root cgroup
Let's tweak when precisely to apply cgroup attributes on the root
cgroup.

With this we now follow the following rules:

1. On cgroupsv2 we never apply any regular cgroups to the host root,
   since the attributes generally do not exist there.

2. On cgroupsv1 we do not apply any "weight" or "shares" style
   attributes to the host root cgroup, since they don't make much sense
   on the top level where there's only one group, hence no need to
   compare weights against each other. The other attributes are applied
   to the host root cgroup however.

3. In any case we don't apply attributes to the root of container
   environments (and --user roots), under the assumption that this is
   managed by the manager further up. (Note that on cgroupsv2 this is
   even enforced by the kernel)

4. BPF pseudo-attributes are applied in all cases (since we can have as
   many of them as we want)
2018-11-23 12:24:37 +01:00
Lennart Poettering 589a5f7a38 cgroup: append \n to static strings we write to cgroup attributes
This is a bit cleaner since we when we format numeric limits we append
it. And this way write_string_file() doesn't have to append it.
2018-11-23 12:24:37 +01:00
Lennart Poettering 28cfdc5aeb cgroup: tighten manager_owns_host_root_cgroup() a bit
This tightening is not strictly necessary (as the m->cgroup_root check
further down does the same), but let's make this explicit.
2018-11-23 12:24:37 +01:00
Lennart Poettering 611c4f8afb cgroup: rename {manager_owns|unit_has}_root_cgroup() → .._host_root_cgroup()
Let's emphasize that this function checks for the host root cgroup, i.e.
returns false for the root cgroup when we run in a container where
CLONE_NEWCGROUP is used. There has been some confusion around this
already, for example cgroup_context_apply() uses the function
incorrectly (which we'll fix in a later commit).

Just some refactoring, not change in behaviour.
2018-11-23 12:24:37 +01:00
Lennart Poettering 293d32df39 cgroup: add a common routine for writing to attributes, and logging about it
We can use this at quite a few places, and this allows us to shorten our
code quite a bit.
2018-11-23 12:24:37 +01:00
Lennart Poettering 39b9fefb2e cgroup: add a new macro for determining log level for cgroup attr write failures
For now, let's use it only at one place, but a follow-up commit will
make more use of it.
2018-11-23 12:24:37 +01:00
Lennart Poettering 2c74e12bb3 cgroup: ignore EPERM for a couple of more attribute writes 2018-11-23 12:24:37 +01:00
Lennart Poettering 8c83840772 cgroup: add comment explaining why we ignore EINVAL at two places
These are just copies from further down.
2018-11-23 12:24:37 +01:00
Lennart Poettering 73fe5314bf cgroup: suffix settings with "=" in log messages where appropriate 2018-11-23 12:24:37 +01:00
Lennart Poettering a0c339ed4b cgroup: only install cgroup release agent when we own the root cgroup
If we run in a container we shouldn't patch around this, and most likely
we can't anyway, and there's not much point in complaining about this.
Hence let's strictly say: the agent is private property of the host's
system instance, nothing else.
2018-11-23 12:24:37 +01:00
Lennart Poettering de8a711a58 cgroup: use structured initialization 2018-11-23 12:24:37 +01:00
Zbigniew Jędrzejewski-Szmek 91540eaa5c
Merge pull request #10861 from yuwata/udev-list-cleanups
libudev: several cleanups for udev-list
2018-11-23 09:12:56 +01:00
Zbigniew Jędrzejewski-Szmek 7f22ad1083
Merge pull request #10886 from yuwata/sd-device-monitor-fix-filter
sd-device: fix subsystem filter
2018-11-23 08:53:33 +01:00
Lennart Poettering 00e7b3c8e5 unit: minor optimization, use stack over heap, when we can 2018-11-23 00:46:56 +01:00
Daniel van Vugt 26d7cf3daf 70-mouse.hwdb: Set DPI for MS Classic IntelliMouse
It defaults to 3200 DPI and 1000 Hz. Note the ?? is required to
match the multibyte UTF-8 character '®'.
2018-11-23 00:46:35 +01:00
Lennart Poettering 50111496dd
Merge pull request #10891 from yuwata/use-main-macro-2
tree-wide: use recently introduced macros
2018-11-23 00:46:02 +01:00
Lennart Poettering 27da878e7e unit: drop an unused fields from Unit struct 2018-11-23 00:37:00 +01:00
Yu Watanabe a5a59a2447 test: add more tests for subsystem filter 2018-11-23 06:46:29 +09:00
Lennart Poettering 66fa4bdd70 core: add two minor comments (#10890) 2018-11-23 06:25:27 +09:00
Yu Watanabe c6f09e6a2d locale: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe af7865c1b7 locale: store polkit_registry in Context 2018-11-23 06:22:30 +09:00
Yu Watanabe 6804d7a849 locale: rename context_free() to context_clear() 2018-11-23 06:22:30 +09:00
Yu Watanabe f6aa61909e resolvectl: use static destructor and define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 7a83c3aee0 rfkill: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 5f5f0afc8b rfkill: store write queue and rfkill fd in struct Context 2018-11-23 06:22:30 +09:00
Yu Watanabe a160567e20 socket-proxy: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe dd2fd972b7 sysusers: use ordered_hashmap_steal_first_key_and_value() 2018-11-23 06:22:30 +09:00
Yu Watanabe 1d03c5c16f time-wait: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 1f47bc3349 timedate: define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe fd1bff7db5 update-done: quit earlier on failure 2018-11-23 06:22:30 +09:00
Yu Watanabe 3664cbabdd update-utmp: use _cleanup_ attribute to finalize process 2018-11-23 06:22:30 +09:00
Yu Watanabe d850ad9a30 veritysetup-generator: use static destructors and define main through macro 2018-11-23 06:22:30 +09:00
Yu Watanabe 2cb52121e5 veritysetup-generator: make arg_dest const 2018-11-23 06:22:30 +09:00
Yu Watanabe 6b9306b29c veritysetup: use static destructors and define main through macro
This also changes the return value when crypt_init_by_name() fails in 'detach'.
2018-11-23 06:22:30 +09:00
Evgeny Vereshchagin 4928e8adba tests: add a fuzzer for catalog_import_file 2018-11-22 21:02:34 +01:00
Zbigniew Jędrzejewski-Szmek c43acf69e4 man: update description of Description=
The way this is used drifted a bit from the original intent. Let's update
the description and add some examples to inspire people to texts that look
less bad during initial boot.
2018-11-22 20:58:43 +01:00
Zbigniew Jędrzejewski-Szmek 74a01105b7
Merge pull request #10884 from yuwata/udev-debug
meson: add more debug options
2018-11-22 20:47:33 +01:00
Yu Watanabe 65fe9c319f sd-device-monitor: fix subsystem filter
This fixes a bug introduced by 759d9f3f8d.

Fixes #10882.
2018-11-23 02:49:28 +09:00
Yu Watanabe 8c19dc54d3 udev-rules: update log messages 2018-11-23 01:15:42 +09:00
Yu Watanabe d6601495be meson: also add option for debugging siphash 2018-11-23 00:36:35 +09:00