mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-03 01:17:45 +03:00
core: ensure init.scope is realized after drop-ins have been loaded
If we add a drop-in for init.scope (e.g.: to set some memory limit), it will be loaded long after the cgroup has already been realized. Do it again when creating the special unit. (cherry picked from commit020b2e41ea
) (cherry picked from commit786b7a7208
)
This commit is contained in:
parent
ba3029cfb4
commit
ffa329c45c
@ -2459,7 +2459,7 @@ static bool unit_has_mask_enables_realized(
|
|||||||
((u->cgroup_enabled_mask | enable_mask) & CGROUP_MASK_V2) == (u->cgroup_enabled_mask & CGROUP_MASK_V2);
|
((u->cgroup_enabled_mask | enable_mask) & CGROUP_MASK_V2) == (u->cgroup_enabled_mask & CGROUP_MASK_V2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unit_add_to_cgroup_realize_queue(Unit *u) {
|
void unit_add_to_cgroup_realize_queue(Unit *u) {
|
||||||
assert(u);
|
assert(u);
|
||||||
|
|
||||||
if (u->in_cgroup_realize_queue)
|
if (u->in_cgroup_realize_queue)
|
||||||
|
@ -262,6 +262,7 @@ int unit_realize_cgroup(Unit *u);
|
|||||||
void unit_prune_cgroup(Unit *u);
|
void unit_prune_cgroup(Unit *u);
|
||||||
int unit_watch_cgroup(Unit *u);
|
int unit_watch_cgroup(Unit *u);
|
||||||
int unit_watch_cgroup_memory(Unit *u);
|
int unit_watch_cgroup_memory(Unit *u);
|
||||||
|
void unit_add_to_cgroup_realize_queue(Unit *u);
|
||||||
|
|
||||||
void unit_release_cgroup(Unit *u);
|
void unit_release_cgroup(Unit *u);
|
||||||
/* Releases the cgroup only if it is recursively empty.
|
/* Releases the cgroup only if it is recursively empty.
|
||||||
|
@ -653,6 +653,10 @@ static void scope_enumerate_perpetual(Manager *m) {
|
|||||||
|
|
||||||
unit_add_to_load_queue(u);
|
unit_add_to_load_queue(u);
|
||||||
unit_add_to_dbus_queue(u);
|
unit_add_to_dbus_queue(u);
|
||||||
|
/* Enqueue an explicit cgroup realization here. Unlike other cgroups this one already exists and is
|
||||||
|
* populated (by us, after all!) already, even when we are not in a reload cycle. Hence we cannot
|
||||||
|
* apply the settings at creation time anymore, but let's at least apply them asynchronously. */
|
||||||
|
unit_add_to_cgroup_realize_queue(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* const scope_result_table[_SCOPE_RESULT_MAX] = {
|
static const char* const scope_result_table[_SCOPE_RESULT_MAX] = {
|
||||||
|
@ -16,6 +16,12 @@ test_append_files() {
|
|||||||
|
|
||||||
cat >>"${initdir:?}/etc/fstab" <<EOF
|
cat >>"${initdir:?}/etc/fstab" <<EOF
|
||||||
UUID=$(blkid -o value -s UUID "${LOOPDEV}p2") none swap defaults 0 0
|
UUID=$(blkid -o value -s UUID "${LOOPDEV}p2") none swap defaults 0 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p "${initdir:?}/etc/systemd/system/init.scope.d/"
|
||||||
|
cat >>"${initdir:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF
|
||||||
|
[Scope]
|
||||||
|
MemoryHigh=10G
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ set -o pipefail
|
|||||||
systemd-analyze log-level debug
|
systemd-analyze log-level debug
|
||||||
systemd-analyze log-target console
|
systemd-analyze log-target console
|
||||||
|
|
||||||
|
# Ensure that the init.scope.d drop-in is applied on boot
|
||||||
|
test "$(cat /sys/fs/cgroup/init.scope/memory.high)" != "max"
|
||||||
|
|
||||||
# Loose checks to ensure the environment has the necessary features for systemd-oomd
|
# Loose checks to ensure the environment has the necessary features for systemd-oomd
|
||||||
[[ -e /proc/pressure ]] || echo "no PSI" >>/skipped
|
[[ -e /proc/pressure ]] || echo "no PSI" >>/skipped
|
||||||
cgroup_type="$(stat -fc %T /sys/fs/cgroup/)"
|
cgroup_type="$(stat -fc %T /sys/fs/cgroup/)"
|
||||||
|
Loading…
Reference in New Issue
Block a user