mirror of
https://github.com/systemd/systemd
synced 2026-03-27 17:24:51 +01:00
Compare commits
7 Commits
de829ff593
...
54966b7cee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54966b7cee | ||
|
|
7417f06187 | ||
|
|
ca589b1b41 | ||
|
|
8b2e22579a | ||
|
|
28fb998615 | ||
|
|
594c383554 | ||
|
|
dccdbf9b35 |
@ -2001,7 +2001,7 @@ int cg_mask_supported(CGroupMask *ret) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cg_kernel_controllers(Set **ret) {
|
int cg_kernel_controllers(Set **ret) {
|
||||||
_cleanup_set_free_free_ Set *controllers = NULL;
|
_cleanup_set_free_ Set *controllers = NULL;
|
||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -2011,10 +2011,6 @@ int cg_kernel_controllers(Set **ret) {
|
|||||||
* and controllers that aren't currently accessible (because not mounted). This does not include "name="
|
* and controllers that aren't currently accessible (because not mounted). This does not include "name="
|
||||||
* pseudo-controllers. */
|
* pseudo-controllers. */
|
||||||
|
|
||||||
controllers = set_new(&string_hash_ops);
|
|
||||||
if (!controllers)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
r = fopen_unlocked("/proc/cgroups", "re", &f);
|
r = fopen_unlocked("/proc/cgroups", "re", &f);
|
||||||
if (r == -ENOENT) {
|
if (r == -ENOENT) {
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
@ -2027,7 +2023,7 @@ int cg_kernel_controllers(Set **ret) {
|
|||||||
(void) read_line(f, SIZE_MAX, NULL);
|
(void) read_line(f, SIZE_MAX, NULL);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char *controller;
|
_cleanup_free_ char *controller = NULL;
|
||||||
int enabled = 0;
|
int enabled = 0;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -2042,17 +2038,13 @@ int cg_kernel_controllers(Set **ret) {
|
|||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled) {
|
if (!enabled)
|
||||||
free(controller);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (!cg_controller_is_valid(controller)) {
|
if (!cg_controller_is_valid(controller))
|
||||||
free(controller);
|
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
}
|
|
||||||
|
|
||||||
r = set_consume(controllers, controller);
|
r = set_ensure_consume(&controllers, &string_hash_ops_free, TAKE_PTR(controller));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -406,7 +406,7 @@ static int mount_legacy_cgns_unsupported(
|
|||||||
uid_t uid_range,
|
uid_t uid_range,
|
||||||
const char *selinux_apifs_context) {
|
const char *selinux_apifs_context) {
|
||||||
|
|
||||||
_cleanup_set_free_free_ Set *controllers = NULL;
|
_cleanup_set_free_ Set *controllers = NULL;
|
||||||
const char *cgroup_root;
|
const char *cgroup_root;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|||||||
@ -120,6 +120,7 @@ static int run(int argc, char *argv[]) {
|
|||||||
_cleanup_(manager_freep) Manager *m = NULL;
|
_cleanup_(manager_freep) Manager *m = NULL;
|
||||||
_cleanup_free_ char *swap = NULL;
|
_cleanup_free_ char *swap = NULL;
|
||||||
unsigned long long s = 0;
|
unsigned long long s = 0;
|
||||||
|
CGroupMask mask;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
log_setup();
|
log_setup();
|
||||||
@ -153,6 +154,13 @@ static int run(int argc, char *argv[]) {
|
|||||||
if (r == 0)
|
if (r == 0)
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Requires the unified cgroups hierarchy");
|
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Requires the unified cgroups hierarchy");
|
||||||
|
|
||||||
|
r = cg_mask_supported(&mask);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to get supported cgroup controllers: %m");
|
||||||
|
|
||||||
|
if (!FLAGS_SET(mask, CGROUP_MASK_MEMORY))
|
||||||
|
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Requires the cgroup memory controller.");
|
||||||
|
|
||||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
|
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
|
||||||
|
|
||||||
if (arg_mem_pressure_usec > 0 && arg_mem_pressure_usec < 1 * USEC_PER_SEC)
|
if (arg_mem_pressure_usec > 0 && arg_mem_pressure_usec < 1 * USEC_PER_SEC)
|
||||||
|
|||||||
@ -90,6 +90,7 @@ static void test_oomd_cgroup_context_acquire_and_insert(void) {
|
|||||||
_cleanup_free_ char *cgroup = NULL;
|
_cleanup_free_ char *cgroup = NULL;
|
||||||
ManagedOOMPreference root_pref;
|
ManagedOOMPreference root_pref;
|
||||||
OomdCGroupContext *c1, *c2;
|
OomdCGroupContext *c1, *c2;
|
||||||
|
CGroupMask mask;
|
||||||
bool test_xattrs;
|
bool test_xattrs;
|
||||||
int root_xattrs, r;
|
int root_xattrs, r;
|
||||||
|
|
||||||
@ -102,6 +103,11 @@ static void test_oomd_cgroup_context_acquire_and_insert(void) {
|
|||||||
if (cg_all_unified() <= 0)
|
if (cg_all_unified() <= 0)
|
||||||
return (void) log_tests_skipped("cgroups are not running in unified mode");
|
return (void) log_tests_skipped("cgroups are not running in unified mode");
|
||||||
|
|
||||||
|
assert_se(cg_mask_supported(&mask) >= 0);
|
||||||
|
|
||||||
|
if (!FLAGS_SET(mask, CGROUP_MASK_MEMORY))
|
||||||
|
return (void) log_tests_skipped("cgroup memory controller is not available");
|
||||||
|
|
||||||
assert_se(cg_pid_get_path(NULL, 0, &cgroup) >= 0);
|
assert_se(cg_pid_get_path(NULL, 0, &cgroup) >= 0);
|
||||||
|
|
||||||
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities
|
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities
|
||||||
|
|||||||
@ -292,7 +292,7 @@ static int symlink_controller(const char *target, const char *alias) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int mount_cgroup_controllers(void) {
|
int mount_cgroup_controllers(void) {
|
||||||
_cleanup_set_free_free_ Set *controllers = NULL;
|
_cleanup_set_free_ Set *controllers = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!cg_is_legacy_wanted())
|
if (!cg_is_legacy_wanted())
|
||||||
|
|||||||
@ -7,4 +7,4 @@ MemoryAccounting=true
|
|||||||
IOAccounting=true
|
IOAccounting=true
|
||||||
TasksAccounting=true
|
TasksAccounting=true
|
||||||
ManagedOOMMemoryPressure=kill
|
ManagedOOMMemoryPressure=kill
|
||||||
ManagedOOMMemoryPressureLimit=1%
|
ManagedOOMMemoryPressureLimit=20%
|
||||||
|
|||||||
@ -38,7 +38,7 @@ systemctl start testsuite-55-testbloat.service
|
|||||||
|
|
||||||
# Verify systemd-oomd is monitoring the expected units
|
# Verify systemd-oomd is monitoring the expected units
|
||||||
oomctl | grep "/testsuite-55-workload.slice"
|
oomctl | grep "/testsuite-55-workload.slice"
|
||||||
oomctl | grep "1.00%"
|
oomctl | grep "20.00%"
|
||||||
oomctl | grep "Default Memory Pressure Duration: 2s"
|
oomctl | grep "Default Memory Pressure Duration: 2s"
|
||||||
|
|
||||||
systemctl status testsuite-55-testchill.service
|
systemctl status testsuite-55-testchill.service
|
||||||
@ -75,7 +75,7 @@ if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then
|
|||||||
if ! systemctl status testsuite-55-testmunch.service; then
|
if ! systemctl status testsuite-55-testmunch.service; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 5
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
# testmunch should be killed since testbloat had the avoid xattr on it
|
# testmunch should be killed since testbloat had the avoid xattr on it
|
||||||
|
|||||||
@ -14,6 +14,7 @@ DefaultDependencies=no
|
|||||||
Before=multi-user.target shutdown.target
|
Before=multi-user.target shutdown.target
|
||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
ConditionControlGroupController=v2
|
ConditionControlGroupController=v2
|
||||||
|
ConditionControlGroupController=memory
|
||||||
ConditionPathExists=/proc/pressure/cpu
|
ConditionPathExists=/proc/pressure/cpu
|
||||||
ConditionPathExists=/proc/pressure/io
|
ConditionPathExists=/proc/pressure/io
|
||||||
ConditionPathExists=/proc/pressure/memory
|
ConditionPathExists=/proc/pressure/memory
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user