Projects
openEuler:24.03:SP1:Everything:64G
systemd
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:systemd.spec
Changed
@@ -25,7 +25,7 @@ Name: systemd Url: https://systemd.io/ Version: 255 -Release: 21 +Release: 22 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -1658,6 +1658,9 @@ %{_unitdir}/veritysetup.target %changelog +* Mon Sep 23 2024 xujing <xujing125@huawei.com> - 255-22 +- DESC:fix cgroup v2 cpuset function error and optimize the code of cpuset and freezer + * Tue Aug 13 2024 huyubiao <huyubiao@huawei.com> - 255-21 - DESC:dont create dont-synthesize-nobody when login shell is /sbin/nologin or /usr/sbin/nologin
View file
_service:tar_scm:bugfix-for-cgroup-Swap-cgroup-v1-deletion-and-migration.patch
Changed
@@ -15,7 +15,7 @@ u->cgroup_enabled_mask = result_mask; migrate_mask = u->cgroup_realized_mask ^ target_mask; -+ if (u->type != UNIT_SLICE && FLAGS_SET(target_mask, CGROUP_MASK_CPUSET)) ++ if (u->type != UNIT_SLICE && FLAGS_SET(target_mask, CGROUP_MASK_CPUSET) && cg_all_unified() == 0) + migrate_mask |= CGROUP_MASK_CPUSET; }
View file
_service:tar_scm:core-cgroup-support-cpuset.patch
Changed
@@ -1,34 +1,32 @@ -From 2ea8175b3d8ec118fa0f42392485ce0f4308456a Mon Sep 17 00:00:00 2001 +From 8fc496f1e5b6d71d29eb446e02f6317bdc45c7c2 Mon Sep 17 00:00:00 2001 From: licunlong <licunlong1@huawei.com> Date: Thu, 6 May 2021 09:38:54 +0800 Subject: PATCH core-cgroup: support cpuset This patch add support for cpuset subsystem. --- - meson.build | 2 + - meson_options.txt | 3 + - src/basic/cgroup-util.c | 3 +- - src/basic/cgroup-util.h | 14 ++- - src/basic/string-util.c | 42 +++++++ - src/basic/string-util.h | 1 + - src/core/cgroup.c | 112 ++++++++++++++---- - src/core/cgroup.h | 14 ++- - src/core/dbus-cgroup.c | 60 ++++++++-- - src/core/dbus-manager.c | 1 + - src/core/execute-serialize.c | 44 +++---- - src/core/load-fragment-gperf.gperf.in | 13 +- - src/core/load-fragment.c | 69 +++++++++++ - src/core/load-fragment.h | 1 + - src/core/main.c | 1 + - src/core/manager.c | 2 + - src/core/manager.h | 1 + - src/core/system.conf.in | 1 + - src/core/unit.c | 1 + - src/shared/bus-unit-util.c | 15 ++- - src/shared/cpu-set-util.c | 1 + - src/test/test-cgroup-mask.c | 5 +- - .../fuzz-unit-file/directives-all.service | 5 + - 23 files changed, 338 insertions(+), 73 deletions(-) + meson.build | 2 + + meson_options.txt | 3 + + src/basic/cgroup-util.h | 8 ++- + src/basic/string-util.c | 42 +++++++++++ + src/basic/string-util.h | 1 + + src/core/cgroup.c | 62 ++++++++++++++++- + src/core/cgroup.h | 6 ++ + src/core/dbus-cgroup.c | 42 +++++++++++ + src/core/dbus-manager.c | 1 + + src/core/load-fragment-gperf.gperf.in | 5 ++ + src/core/load-fragment.c | 69 +++++++++++++++++++ + src/core/load-fragment.h | 1 + + src/core/main.c | 1 + + src/core/manager.c | 2 + + src/core/manager.h | 1 + + src/core/system.conf.in | 1 + + src/core/unit.c | 1 + + src/shared/bus-unit-util.c | 15 +++- + src/shared/cpu-set-util.c | 1 + + src/test/test-cgroup-mask.c | 1 + + .../fuzz-unit-file/directives-all.service | 5 ++ + 21 files changed, 264 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 7419e2b..614013b 100644 @@ -61,60 +59,20 @@ + +option('cpuset-cgv1', type : 'boolean', value : 'true', + description : 'enable cgroup v1 cpuset support') -diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c -index 18b16ec..abd1f91 100644 ---- a/src/basic/cgroup-util.c -+++ b/src/basic/cgroup-util.c -@@ -2352,12 +2352,13 @@ bool fd_is_cgroup_fs(int fd) { - static const char *const cgroup_controller_table_CGROUP_CONTROLLER_MAX = { - CGROUP_CONTROLLER_CPU = "cpu", - CGROUP_CONTROLLER_CPUACCT = "cpuacct", -- CGROUP_CONTROLLER_CPUSET = "cpuset", -+ CGROUP_CONTROLLER_CPUSET2 = "cpuset2", - CGROUP_CONTROLLER_IO = "io", - CGROUP_CONTROLLER_BLKIO = "blkio", - CGROUP_CONTROLLER_MEMORY = "memory", - CGROUP_CONTROLLER_DEVICES = "devices", - CGROUP_CONTROLLER_PIDS = "pids", -+ CGROUP_CONTROLLER_CPUSET = "cpuset", - CGROUP_CONTROLLER_BPF_FIREWALL = "bpf-firewall", - CGROUP_CONTROLLER_BPF_DEVICES = "bpf-devices", - CGROUP_CONTROLLER_BPF_FOREIGN = "bpf-foreign", diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h -index 6ab14c7..dd3df28 100644 +index 6ab14c7..831f8ce 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h -@@ -22,12 +22,13 @@ typedef enum CGroupController { +@@ -22,7 +22,7 @@ typedef enum CGroupController { /* Original cgroup controllers */ CGROUP_CONTROLLER_CPU, CGROUP_CONTROLLER_CPUACCT, /* v1 only */ - CGROUP_CONTROLLER_CPUSET, /* v2 only */ -+ CGROUP_CONTROLLER_CPUSET2, /* v2 only */ ++ CGROUP_CONTROLLER_CPUSET, CGROUP_CONTROLLER_IO, /* v2 only */ CGROUP_CONTROLLER_BLKIO, /* v1 only */ CGROUP_CONTROLLER_MEMORY, - CGROUP_CONTROLLER_DEVICES, /* v1 only */ - CGROUP_CONTROLLER_PIDS, -+ CGROUP_CONTROLLER_CPUSET, - - /* BPF-based pseudo-controllers, v2 only */ - CGROUP_CONTROLLER_BPF_FIREWALL, -@@ -49,12 +50,13 @@ typedef enum CGroupController { - typedef enum CGroupMask { - CGROUP_MASK_CPU = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPU), - CGROUP_MASK_CPUACCT = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUACCT), -- CGROUP_MASK_CPUSET = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET), -+ CGROUP_MASK_CPUSET2 = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET2), - CGROUP_MASK_IO = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_IO), - CGROUP_MASK_BLKIO = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BLKIO), - CGROUP_MASK_MEMORY = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_MEMORY), - CGROUP_MASK_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_DEVICES), - CGROUP_MASK_PIDS = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_PIDS), -+ CGROUP_MASK_CPUSET = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET), - CGROUP_MASK_BPF_FIREWALL = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FIREWALL), - CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES), - CGROUP_MASK_BPF_FOREIGN = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FOREIGN), -@@ -62,10 +64,14 @@ typedef enum CGroupMask { +@@ -62,7 +62,11 @@ typedef enum CGroupMask { CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_RESTRICT_NETWORK_INTERFACES), /* All real cgroup v1 controllers */ @@ -126,11 +84,7 @@ + , /* All real cgroup v2 controllers */ -- CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, -+ CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET2|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, - - /* All cgroup v2 BPF pseudo-controllers */ - CGROUP_MASK_BPF = CGROUP_MASK_BPF_FIREWALL|CGROUP_MASK_BPF_DEVICES|CGROUP_MASK_BPF_FOREIGN|CGROUP_MASK_BPF_SOCKET_BIND|CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES, + CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 7329bfa..0fecb40 100644 --- a/src/basic/string-util.c @@ -197,65 +151,23 @@ char *string_replace_char(char *str, char old_char, char new_char); diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 78bc551..cd1e97d 100644 +index 78bc551..3154fd3 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c -@@ -91,8 +91,8 @@ bool unit_has_startup_cgroup_constraints(Unit *u) { - return c->startup_cpu_shares != CGROUP_CPU_SHARES_INVALID || - c->startup_io_weight != CGROUP_WEIGHT_INVALID || - c->startup_blockio_weight != CGROUP_BLKIO_WEIGHT_INVALID || -- c->startup_cpuset_cpus.set || -- c->startup_cpuset_mems.set || -+ c->startup_cpuset_cpus2.set || -+ c->startup_cpuset_mems2.set || - c->startup_memory_high_set || - c->startup_memory_max_set || - c->startup_memory_swap_max_set|| -@@ -293,10 +293,16 @@ void cgroup_context_done(CGroupContext *c) { +@@ -293,6 +293,12 @@ void cgroup_context_done(CGroupContext *c) { c->restrict_network_interfaces = set_free_free(c->restrict_network_interfaces); -- cpu_set_reset(&c->cpuset_cpus); -- cpu_set_reset(&c->startup_cpuset_cpus); -- cpu_set_reset(&c->cpuset_mems); -- cpu_set_reset(&c->startup_cpuset_mems); -+ if (c->cpuset_cpus) -+ c->cpuset_cpus = mfree(c->cpuset_cpus); ++ if (c->cpuset_cpus_v1) ++ c->cpuset_cpus_v1 = mfree(c->cpuset_cpus_v1); + -+ if (c->cpuset_mems) -+ c->cpuset_mems = mfree(c->cpuset_mems); ++ if (c->cpuset_mems_v1) ++ c->cpuset_mems_v1 = mfree(c->cpuset_mems_v1); + -+ cpu_set_reset(&c->cpuset_cpus2); -+ cpu_set_reset(&c->startup_cpuset_cpus2); -+ cpu_set_reset(&c->cpuset_mems2); -+ cpu_set_reset(&c->startup_cpuset_mems2); - - c->delegate_subgroup = mfree(c->delegate_subgroup); - -@@ -496,7 +502,7 @@ CGroupDevicePermissions cgroup_device_permissions_from_string(const char *s) { - } - - void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { -- _cleanup_free_ char *disable_controllers_str = NULL, *delegate_controllers_str = NULL, *cpuset_cpus = NULL, *cpuset_mems = NULL, *startup_cpuset_cpus = NULL, *startup_cpuset_mems = NULL; -+ _cleanup_free_ char *disable_controllers_str = NULL, *delegate_controllers_str = NULL, *cpuset_cpus2 = NULL, *cpuset_mems2 = NULL, *startup_cpuset_cpus2 = NULL, *startup_cpuset_mems2 = NULL; - CGroupContext *c; - struct in_addr_prefix *iaai; - -@@ -525,16 +531,17 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { - /* "Delegate=" means "yes, but no controllers". Show this as "(none)". */ - const char *delegate_str = delegate_controllers_str ?: c->delegate ? "(none)" : "no"; - -- cpuset_cpus = cpu_set_to_range_string(&c->cpuset_cpus); -- startup_cpuset_cpus = cpu_set_to_range_string(&c->startup_cpuset_cpus); -- cpuset_mems = cpu_set_to_range_string(&c->cpuset_mems); -- startup_cpuset_mems = cpu_set_to_range_string(&c->startup_cpuset_mems); -+ cpuset_cpus2 = cpu_set_to_range_string(&c->cpuset_cpus2); -+ startup_cpuset_cpus2 = cpu_set_to_range_string(&c->startup_cpuset_cpus2); -+ cpuset_mems2 = cpu_set_to_range_string(&c->cpuset_mems2); -+ startup_cpuset_mems2 = cpu_set_to_range_string(&c->startup_cpuset_mems2); - - fprintf(f, - "%sCPUAccounting: %s\n" + cpu_set_reset(&c->cpuset_cpus); + cpu_set_reset(&c->startup_cpuset_cpus); + cpu_set_reset(&c->cpuset_mems); +@@ -535,6 +541,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { "%sIOAccounting: %s\n" "%sBlockIOAccounting: %s\n" "%sMemoryAccounting: %s\n" @@ -282,158 +194,79 @@ prefix, yes_no(c->tasks_accounting), prefix, yes_no(c->ip_accounting), prefix, c->cpu_weight, -@@ -587,10 +599,10 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { - prefix, c->startup_cpu_shares, - prefix, FORMAT_TIMESPAN(c->cpu_quota_per_sec_usec, 1), - prefix, FORMAT_TIMESPAN(c->cpu_quota_period_usec, 1), -- prefix, strempty(cpuset_cpus), -- prefix, strempty(startup_cpuset_cpus), -- prefix, strempty(cpuset_mems), -- prefix, strempty(startup_cpuset_mems), -+ prefix, strempty(cpuset_cpus2), -+ prefix, strempty(startup_cpuset_cpus2), -+ prefix, strempty(cpuset_mems2), -+ prefix, strempty(startup_cpuset_mems2), - prefix, c->io_weight, - prefix, c->startup_io_weight, - prefix, c->blockio_weight, @@ -609,6 +621,10 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, c->memory_zswap_max, format_cgroup_memory_limit_comparison(cdj, sizeof(cdj), u, "MemoryZSwapMax"), prefix, c->startup_memory_zswap_max, format_cgroup_memory_limit_comparison(cdk, sizeof(cdk), u, "StartupMemoryZSwapMax"), prefix, c->memory_limit, -+ prefix, c->cpuset_cpus, -+ prefix, c->cpuset_mems, ++ prefix, c->cpuset_cpus_v1, ++ prefix, c->cpuset_mems_v1, + prefix, yes_no(c->cpuset_clone_children), + prefix, yes_no(c->cpuset_memory_migrate), prefix, cgroup_tasks_max_resolve(&c->tasks_max), prefix, cgroup_device_policy_to_string(c->device_policy), prefix, strempty(disable_controllers_str), -@@ -1113,11 +1129,11 @@ static bool cgroup_context_has_cpu_shares(CGroupContext *c) { - } - - static bool cgroup_context_has_allowed_cpus(CGroupContext *c) { -- return c->cpuset_cpus.set || c->startup_cpuset_cpus.set; -+ return c->cpuset_cpus2.set || c->startup_cpuset_cpus2.set; - } - - static bool cgroup_context_has_allowed_mems(CGroupContext *c) { -- return c->cpuset_mems.set || c->startup_cpuset_mems.set; -+ return c->cpuset_mems2.set || c->startup_cpuset_mems2.set; - } - - uint64_t cgroup_context_cpu_weight(CGroupContext *c, ManagerState state) { -@@ -1144,18 +1160,18 @@ static uint64_t cgroup_context_cpu_shares(CGroupContext *c, ManagerState state) - - static CPUSet *cgroup_context_allowed_cpus(CGroupContext *c, ManagerState state) { - if (IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING, MANAGER_STOPPING) && -- c->startup_cpuset_cpus.set) -- return &c->startup_cpuset_cpus; -+ c->startup_cpuset_cpus2.set) -+ return &c->startup_cpuset_cpus2; - else -- return &c->cpuset_cpus; -+ return &c->cpuset_cpus2; - } - - static CPUSet *cgroup_context_allowed_mems(CGroupContext *c, ManagerState state) { - if (IN_SET(state, MANAGER_STARTING, MANAGER_INITIALIZING, MANAGER_STOPPING) && -- c->startup_cpuset_mems.set) -- return &c->startup_cpuset_mems; -+ c->startup_cpuset_mems2.set) -+ return &c->startup_cpuset_mems2; - else -- return &c->cpuset_mems; -+ return &c->cpuset_mems2; - } - - usec_t cgroup_cpu_adjust_period(usec_t period, usec_t quota, usec_t resolution, usec_t max_period) { -@@ -1727,7 +1743,7 @@ static void cgroup_context_apply( - } +@@ -1728,8 +1744,47 @@ static void cgroup_context_apply( } -- if ((apply_mask & CGROUP_MASK_CPUSET) && !is_local_root) { -+ if ((apply_mask & CGROUP_MASK_CPUSET2) && !is_local_root) { - cgroup_apply_unified_cpuset(u, cgroup_context_allowed_cpus(c, state), "cpuset.cpus"); - cgroup_apply_unified_cpuset(u, cgroup_context_allowed_mems(c, state), "cpuset.mems"); - } -@@ -1902,6 +1918,45 @@ static void cgroup_context_apply( - } - } - -+ if ((apply_mask & CGROUP_MASK_CPUSET) && !is_local_root) { -+ (void) set_attribute_and_warn(u, "cpuset", "cgroup.clone_children", one_zero(c->cpuset_clone_children)); -+ (void) set_attribute_and_warn(u, "cpuset", "cpuset.memory_migrate", one_zero(c->cpuset_memory_migrate)); -+ if (c->cpuset_cpus) { -+ if (streq(c->cpuset_cpus, "all")) { -+ _cleanup_free_ char *str_cpuset_cpus = NULL; -+ _cleanup_free_ char *cg_root_path_cpus = NULL; -+ r = cg_get_root_path(&cg_root_path_cpus); -+ if (r < 0) -+ log_info_errno(r, "Failed to determine root cgroup, ignoring cgroup cpuset cpus: %m"); -+ if (cg_root_path_cpus) { -+ r = cg_get_attribute("cpuset", cg_root_path_cpus, "cpuset.cpus", &str_cpuset_cpus); + if ((apply_mask & CGROUP_MASK_CPUSET) && !is_local_root) { +- cgroup_apply_unified_cpuset(u, cgroup_context_allowed_cpus(c, state), "cpuset.cpus"); +- cgroup_apply_unified_cpuset(u, cgroup_context_allowed_mems(c, state), "cpuset.mems"); ++ if (cg_all_unified() == 0) { ++ (void) set_attribute_and_warn(u, "cpuset", "cgroup.clone_children", one_zero(c->cpuset_clone_children)); ++ (void) set_attribute_and_warn(u, "cpuset", "cpuset.memory_migrate", one_zero(c->cpuset_memory_migrate)); ++ if (c->cpuset_cpus_v1) { ++ if (streq(c->cpuset_cpus_v1, "all")) { ++ _cleanup_free_ char *str_cpuset_cpus = NULL; ++ _cleanup_free_ char *cg_root_path_cpus = NULL; ++ r = cg_get_root_path(&cg_root_path_cpus); + if (r < 0) -+ log_error("cgroup context apply: cg get attribute is error(%d), path=%s.", r, cg_root_path_cpus); -+ if (str_cpuset_cpus) -+ (void) set_attribute_and_warn(u, "cpuset", "cpuset.cpus", str_cpuset_cpus); -+ } -+ } else -+ (void) set_attribute_and_warn(u, "cpuset", "cpuset.cpus", c->cpuset_cpus); -+ } -+ if (c->cpuset_mems) { -+ if (streq(c->cpuset_mems, "all")) { -+ _cleanup_free_ char *str_cpuset_mems = NULL; -+ _cleanup_free_ char *cg_root_path_mems = NULL; -+ r = cg_get_root_path(&cg_root_path_mems); -+ if (r < 0) -+ log_info_errno(r, "Failed to determine root cgroup, ignoring cgroup cpuset mems: %m"); -+ if (cg_root_path_mems) { -+ r = cg_get_attribute("cpuset", cg_root_path_mems, "cpuset.mems", &str_cpuset_mems); ++ log_info_errno(r, "Failed to determine root cgroup, ignoring cgroup cpuset cpus: %m"); ++ if (cg_root_path_cpus) { ++ r = cg_get_attribute("cpuset", cg_root_path_cpus, "cpuset.cpus", &str_cpuset_cpus); ++ if (r < 0) ++ log_error("cgroup context apply: cg get attribute is error(%d), path=%s.", r, cg_root_path_cpus); ++ if (str_cpuset_cpus) ++ (void) set_attribute_and_warn(u, "cpuset", "cpuset.cpus", str_cpuset_cpus); ++ } ++ } else ++ (void) set_attribute_and_warn(u, "cpuset", "cpuset.cpus", c->cpuset_cpus_v1); ++ } ++ if (c->cpuset_mems_v1) { ++ if (streq(c->cpuset_mems_v1, "all")) { ++ _cleanup_free_ char *str_cpuset_mems = NULL; ++ _cleanup_free_ char *cg_root_path_mems = NULL; ++ r = cg_get_root_path(&cg_root_path_mems); + if (r < 0) -+ log_error("cgroup context apply: cg get attribute is error(%d), path=%s.", r, cg_root_path_mems); -+ if (str_cpuset_mems) -+ (void) set_attribute_and_warn(u, "cpuset", "cpuset.mems", str_cpuset_mems); -+ } -+ } else -+ (void) set_attribute_and_warn(u, "cpuset", "cpuset.mems", c->cpuset_mems); ++ log_info_errno(r, "Failed to determine root cgroup, ignoring cgroup cpuset mems: %m"); ++ if (cg_root_path_mems) { ++ r = cg_get_attribute("cpuset", cg_root_path_mems, "cpuset.mems", &str_cpuset_mems); ++ if (r < 0) ++ log_error("cgroup context apply: cg get attribute is error(%d), path=%s.", r, cg_root_path_mems); ++ if (str_cpuset_mems) ++ (void) set_attribute_and_warn(u, "cpuset", "cpuset.mems", str_cpuset_mems); ++ } ++ } else ++ (void) set_attribute_and_warn(u, "cpuset", "cpuset.mems", c->cpuset_mems_v1); ++ } ++ } else { ++ cgroup_apply_unified_cpuset(u, cgroup_context_allowed_cpus(c, state), "cpuset.cpus"); ++ cgroup_apply_unified_cpuset(u, cgroup_context_allowed_mems(c, state), "cpuset.mems"); + } -+ } -+ - /* On cgroup v2 we can apply BPF everywhere. On cgroup v1 we apply it everywhere except for the root of - * containers, where we leave this to the manager */ - if ((apply_mask & (CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES)) && -@@ -2045,7 +2100,7 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { + } + + /* The 'io' controller attributes are not exported on the host's root cgroup (being a pure cgroup v2 +@@ -2044,7 +2099,8 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { + c->cpu_quota_per_sec_usec != USEC_INFINITY) mask |= CGROUP_MASK_CPU; - if (cgroup_context_has_allowed_cpus(c) || cgroup_context_has_allowed_mems(c)) -- mask |= CGROUP_MASK_CPUSET; -+ mask |= CGROUP_MASK_CPUSET2; +- if (cgroup_context_has_allowed_cpus(c) || cgroup_context_has_allowed_mems(c)) ++ if (cgroup_context_has_allowed_cpus(c) || cgroup_context_has_allowed_mems(c) || ++ c->cpuset_accounting || c->cpuset_cpus_v1 || c->cpuset_mems_v1) + mask |= CGROUP_MASK_CPUSET; if (cgroup_context_has_io_config(c) || cgroup_context_has_blockio_config(c)) - mask |= CGROUP_MASK_IO | CGROUP_MASK_BLKIO; -@@ -2055,6 +2110,11 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { - unit_has_unified_memory_config(u)) - mask |= CGROUP_MASK_MEMORY; - -+ if (c->cpuset_accounting || -+ c->cpuset_cpus || -+ c->cpuset_mems) -+ mask |= CGROUP_MASK_CPUSET; -+ - if (c->device_allow || - c->device_policy != CGROUP_DEVICE_POLICY_AUTO) - mask |= CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES; -@@ -4597,7 +4657,7 @@ int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name) { - if (!u->cgroup_path) - return -ENODATA; - -- if ((u->cgroup_realized_mask & CGROUP_MASK_CPUSET) == 0) -+ if ((u->cgroup_realized_mask & CGROUP_MASK_CPUSET2) == 0) - return -ENODATA; - - r = cg_all_unified(); diff --git a/src/core/cgroup.h b/src/core/cgroup.h -index f1b674b..04a7f25 100644 +index f1b674b..a4bd959 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -134,6 +134,7 @@ struct CGroupContext { @@ -444,27 +277,12 @@ bool tasks_accounting; bool ip_accounting; -@@ -151,10 +152,10 @@ struct CGroupContext { - usec_t cpu_quota_per_sec_usec; - usec_t cpu_quota_period_usec; - -- CPUSet cpuset_cpus; -- CPUSet startup_cpuset_cpus; -- CPUSet cpuset_mems; -- CPUSet startup_cpuset_mems; -+ CPUSet cpuset_cpus2; -+ CPUSet startup_cpuset_cpus2; -+ CPUSet cpuset_mems2; -+ CPUSet startup_cpuset_mems2; - - uint64_t io_weight; - uint64_t startup_io_weight; @@ -177,6 +178,11 @@ struct CGroupContext { uint64_t memory_zswap_max; uint64_t startup_memory_zswap_max; -+ char *cpuset_cpus; -+ char *cpuset_mems; ++ char *cpuset_cpus_v1; ++ char *cpuset_mems_v1; + bool cpuset_clone_children; + bool cpuset_memory_migrate; + @@ -472,31 +290,16 @@ bool default_memory_low_set:1; bool default_startup_memory_low_set:1; diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c -index 4237e69..05fd445 100644 +index 4237e69..e82d56e 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c -@@ -453,10 +453,10 @@ const sd_bus_vtable bus_cgroup_vtable = { - SD_BUS_PROPERTY("StartupCPUShares", "t", NULL, offsetof(CGroupContext, startup_cpu_shares), 0), - SD_BUS_PROPERTY("CPUQuotaPerSecUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_per_sec_usec), 0), - SD_BUS_PROPERTY("CPUQuotaPeriodUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_period_usec), 0), -- SD_BUS_PROPERTY("AllowedCPUs", "ay", property_get_cpuset, offsetof(CGroupContext, cpuset_cpus), 0), -- SD_BUS_PROPERTY("StartupAllowedCPUs", "ay", property_get_cpuset, offsetof(CGroupContext, startup_cpuset_cpus), 0), -- SD_BUS_PROPERTY("AllowedMemoryNodes", "ay", property_get_cpuset, offsetof(CGroupContext, cpuset_mems), 0), -- SD_BUS_PROPERTY("StartupAllowedMemoryNodes", "ay", property_get_cpuset, offsetof(CGroupContext, startup_cpuset_mems), 0), -+ SD_BUS_PROPERTY("AllowedCPUs", "ay", property_get_cpuset, offsetof(CGroupContext, cpuset_cpus2), 0), -+ SD_BUS_PROPERTY("StartupAllowedCPUs", "ay", property_get_cpuset, offsetof(CGroupContext, startup_cpuset_cpus2), 0), -+ SD_BUS_PROPERTY("AllowedMemoryNodes", "ay", property_get_cpuset, offsetof(CGroupContext, cpuset_mems2), 0), -+ SD_BUS_PROPERTY("StartupAllowedMemoryNodes", "ay", property_get_cpuset, offsetof(CGroupContext, startup_cpuset_mems2), 0), - SD_BUS_PROPERTY("IOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, io_accounting), 0), - SD_BUS_PROPERTY("IOWeight", "t", NULL, offsetof(CGroupContext, io_weight), 0), - SD_BUS_PROPERTY("StartupIOWeight", "t", NULL, offsetof(CGroupContext, startup_io_weight), 0), @@ -488,6 +488,11 @@ const sd_bus_vtable bus_cgroup_vtable = { SD_BUS_PROPERTY("MemoryZSwapMax", "t", NULL, offsetof(CGroupContext, memory_zswap_max), 0), SD_BUS_PROPERTY("StartupMemoryZSwapMax", "t", NULL, offsetof(CGroupContext, startup_memory_zswap_max), 0), SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0), + SD_BUS_PROPERTY("CPUSetAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_accounting), 0), -+ SD_BUS_PROPERTY("CPUSetCpus", "s", NULL, offsetof(CGroupContext, cpuset_cpus), 0), -+ SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems), 0), ++ SD_BUS_PROPERTY("CPUSetCpus", "s", NULL, offsetof(CGroupContext, cpuset_cpus_v1), 0), ++ SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems_v1), 0), + SD_BUS_PROPERTY("CPUSetCloneChildren", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_clone_children), 0), + SD_BUS_PROPERTY("CPUSetMemMigrate", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_memory_migrate), 0), SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0), @@ -519,17 +322,17 @@ + if (!UNIT_WRITE_FLAGS_NOOP(flags)) { + unit_invalidate_cgroup(u, CGROUP_MASK_CPUSET); + if (streq(name, "CPUSetCpus")) { -+ if (c->cpuset_cpus) -+ c->cpuset_cpus = mfree(c->cpuset_cpus); -+ c->cpuset_cpus = strdup(cpuset_str); -+ if (!c->cpuset_cpus) ++ if (c->cpuset_cpus_v1) ++ c->cpuset_cpus_v1 = mfree(c->cpuset_cpus_v1); ++ c->cpuset_cpus_v1 = strdup(cpuset_str); ++ if (!c->cpuset_cpus_v1) + return -ENOMEM; + unit_write_settingf(u, flags, name, "CPUSetCpus=%s", cpuset_str); + } else { -+ if (c->cpuset_mems) -+ c->cpuset_mems = mfree(c->cpuset_mems); -+ c->cpuset_mems = strdup(cpuset_str); -+ if (!c->cpuset_mems) ++ if (c->cpuset_mems_v1) ++ c->cpuset_mems_v1 = mfree(c->cpuset_mems_v1); ++ c->cpuset_mems_v1 = strdup(cpuset_str); ++ if (!c->cpuset_mems_v1) + return -ENOMEM; + unit_write_settingf(u, flags, name, "CPUSetMems=%s", cpuset_str); + } @@ -546,33 +349,6 @@ if (streq(name, "TasksAccounting")) return bus_cgroup_set_boolean(u, name, &c->tasks_accounting, CGROUP_MASK_PIDS, message, flags, error); -@@ -1358,13 +1400,13 @@ int bus_cgroup_set_property( - return -ENOMEM; - - if (streq(name, "AllowedCPUs")) -- set = &c->cpuset_cpus; -+ set = &c->cpuset_cpus2; - else if (streq(name, "StartupAllowedCPUs")) -- set = &c->startup_cpuset_cpus; -+ set = &c->startup_cpuset_cpus2; - else if (streq(name, "AllowedMemoryNodes")) -- set = &c->cpuset_mems; -+ set = &c->cpuset_mems2; - else if (streq(name, "StartupAllowedMemoryNodes")) -- set = &c->startup_cpuset_mems; -+ set = &c->startup_cpuset_mems2; - - assert(set); - -@@ -1372,7 +1414,7 @@ int bus_cgroup_set_property( - *set = new_set; - new_set = (CPUSet) {}; - -- unit_invalidate_cgroup(u, CGROUP_MASK_CPUSET); -+ unit_invalidate_cgroup(u, CGROUP_MASK_CPUSET2); - unit_write_settingf(u, flags, name, "%s=\n%s=%s", name, name, setstr); - } - diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 745f5cc..fc49e7d 100644 --- a/src/core/dbus-manager.c @@ -585,155 +361,17 @@ SD_BUS_PROPERTY("DefaultTasksAccounting", "b", bus_property_get_bool, offsetof(Manager, defaults.tasks_accounting), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultLimitCPU", "t", bus_property_get_rlimit, offsetof(Manager, defaults.rlimitRLIMIT_CPU), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultLimitCPUSoft", "t", bus_property_get_rlimit, offsetof(Manager, defaults.rlimitRLIMIT_CPU), SD_BUS_VTABLE_PROPERTY_CONST), -diff --git a/src/core/execute-serialize.c b/src/core/execute-serialize.c -index 6c19cd4..e585188 100644 ---- a/src/core/execute-serialize.c -+++ b/src/core/execute-serialize.c -@@ -21,8 +21,8 @@ - - static int exec_cgroup_context_serialize(const CGroupContext *c, FILE *f) { - _cleanup_free_ char *disable_controllers_str = NULL, *delegate_controllers_str = NULL, -- *cpuset_cpus = NULL, *cpuset_mems = NULL, *startup_cpuset_cpus = NULL, -- *startup_cpuset_mems = NULL; -+ *cpuset_cpus2 = NULL, *cpuset_mems2 = NULL, *startup_cpuset_cpus2 = NULL, -+ *startup_cpuset_mems2 = NULL; - char *iface; - struct in_addr_prefix *iaai; - int r; -@@ -96,35 +96,35 @@ static int exec_cgroup_context_serialize(const CGroupContext *c, FILE *f) { - return r; - } - -- cpuset_cpus = cpu_set_to_range_string(&c->cpuset_cpus); -- if (!cpuset_cpus) -+ cpuset_cpus2 = cpu_set_to_range_string(&c->cpuset_cpus2); -+ if (!cpuset_cpus2) - return log_oom_debug(); - -- r = serialize_item(f, "exec-cgroup-context-allowed-cpus", cpuset_cpus); -+ r = serialize_item(f, "exec-cgroup-context-allowed-cpus", cpuset_cpus2); - if (r < 0) - return r; - -- startup_cpuset_cpus = cpu_set_to_range_string(&c->startup_cpuset_cpus); -- if (!startup_cpuset_cpus) -+ startup_cpuset_cpus2 = cpu_set_to_range_string(&c->startup_cpuset_cpus2); -+ if (!startup_cpuset_cpus2) - return log_oom_debug(); - -- r = serialize_item(f, "exec-cgroup-context-startup-allowed-cpus", startup_cpuset_cpus); -+ r = serialize_item(f, "exec-cgroup-context-startup-allowed-cpus", startup_cpuset_cpus2); - if (r < 0) - return r; - -- cpuset_mems = cpu_set_to_range_string(&c->cpuset_mems); -- if (!cpuset_mems) -+ cpuset_mems2 = cpu_set_to_range_string(&c->cpuset_mems2); -+ if (!cpuset_mems2) - return log_oom_debug(); - -- r = serialize_item(f, "exec-cgroup-context-allowed-memory-nodes", cpuset_mems); -+ r = serialize_item(f, "exec-cgroup-context-allowed-memory-nodes", cpuset_mems2); - if (r < 0) - return r; - -- startup_cpuset_mems = cpu_set_to_range_string(&c->startup_cpuset_mems); -- if (!startup_cpuset_mems) -+ startup_cpuset_mems2 = cpu_set_to_range_string(&c->startup_cpuset_mems2); -+ if (!startup_cpuset_mems2) - return log_oom_debug(); - -- r = serialize_item(f, "exec-cgroup-context-startup-allowed-memory-nodes", startup_cpuset_mems); -+ r = serialize_item(f, "exec-cgroup-context-startup-allowed-memory-nodes", startup_cpuset_mems2); - if (r < 0) - return r; - -@@ -555,12 +555,12 @@ static int exec_cgroup_context_deserialize(CGroupContext *c, FILE *f) { - if (r < 0) - return r; - } else if ((val = startswith(l, "exec-cgroup-context-allowed-cpus="))) { -- if (c->cpuset_cpus.set) -+ if (c->cpuset_cpus2.set) - return -EINVAL; /* duplicated */ - - r = parse_cpu_set_full( - val, -- &c->cpuset_cpus, -+ &c->cpuset_cpus2, - /* warn= */ false, - /* unit= */ NULL, - /* filename= */ NULL, -@@ -569,12 +569,12 @@ static int exec_cgroup_context_deserialize(CGroupContext *c, FILE *f) { - if (r < 0) - return r; - } else if ((val = startswith(l, "exec-cgroup-context-startup-allowed-cpus="))) { -- if (c->startup_cpuset_cpus.set) -+ if (c->startup_cpuset_cpus2.set) - return -EINVAL; /* duplicated */ - - r = parse_cpu_set_full( - val, -- &c->startup_cpuset_cpus, -+ &c->startup_cpuset_cpus2, - /* warn= */ false, - /* unit= */ NULL, - /* filename= */ NULL, -@@ -583,12 +583,12 @@ static int exec_cgroup_context_deserialize(CGroupContext *c, FILE *f) { - if (r < 0) - return r; - } else if ((val = startswith(l, "exec-cgroup-context-allowed-memory-nodes="))) { -- if (c->cpuset_mems.set) -+ if (c->cpuset_mems2.set) - return -EINVAL; /* duplicated */ - - r = parse_cpu_set_full( - val, -- &c->cpuset_mems, -+ &c->cpuset_mems2, - /* warn= */ false, - /* unit= */ NULL, - /* filename= */ NULL, -@@ -597,12 +597,12 @@ static int exec_cgroup_context_deserialize(CGroupContext *c, FILE *f) { - if (r < 0) - return r; - } else if ((val = startswith(l, "exec-cgroup-context-startup-allowed-memory-nodes="))) { -- if (c->startup_cpuset_mems.set) -+ if (c->startup_cpuset_mems2.set) - return -EINVAL; /* duplicated */ - - r = parse_cpu_set_full( - val, -- &c->startup_cpuset_mems, -+ &c->startup_cpuset_mems2, - /* warn= */ false, - /* unit= */ NULL, - /* filename= */ NULL, diff --git a/src/core/load-fragment-gperf.gperf.in b/src/core/load-fragment-gperf.gperf.in -index 45f9ab0..1e46af4 100644 +index 45f9ab0..62c4027 100644 --- a/src/core/load-fragment-gperf.gperf.in +++ b/src/core/load-fragment-gperf.gperf.in -@@ -194,10 +194,10 @@ - - {%- macro CGROUP_CONTEXT_CONFIG_ITEMS(type) -%} - {{type}}.Slice, config_parse_unit_slice, 0, 0 --{{type}}.AllowedCPUs, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.cpuset_cpus) --{{type}}.StartupAllowedCPUs, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.startup_cpuset_cpus) --{{type}}.AllowedMemoryNodes, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.cpuset_mems) --{{type}}.StartupAllowedMemoryNodes, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.startup_cpuset_mems) -+{{type}}.AllowedCPUs, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.cpuset_cpus2) -+{{type}}.StartupAllowedCPUs, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.startup_cpuset_cpus2) -+{{type}}.AllowedMemoryNodes, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.cpuset_mems2) -+{{type}}.StartupAllowedMemoryNodes, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.startup_cpuset_mems2) - {{type}}.CPUAccounting, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpu_accounting) - {{type}}.CPUWeight, config_parse_cg_cpu_weight, 0, offsetof({{type}}, cgroup_context.cpu_weight) - {{type}}.StartupCPUWeight, config_parse_cg_cpu_weight, 0, offsetof({{type}}, cgroup_context.startup_cpu_weight) @@ -221,6 +221,11 @@ {{type}}.MemoryZSwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.StartupMemoryZSwapMax, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.MemoryLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) +{{type}}.CPUSetAccounting, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_accounting) -+{{type}}.CPUSetCpus, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_cpus) -+{{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems) ++{{type}}.CPUSetCpus, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_cpus_v1) ++{{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems_v1) +{{type}}.CPUSetCloneChildren, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_clone_children) +{{type}}.CPUSetMemMigrate, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_memory_migrate) {{type}}.DeviceAllow, config_parse_device_allow, 0, offsetof({{type}}, cgroup_context) @@ -762,7 +400,7 @@ + char **pcpumems = data; + char *pinstr = NULL; + int iret = 0; -+ ++ + assert(filename); + assert(lvalue); + assert(rvalue); @@ -832,7 +470,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_delegate); CONFIG_PARSER_PROTOTYPE(config_parse_delegate_subgroup); diff --git a/src/core/main.c b/src/core/main.c -index 62112dc..de3f536 100644 +index bfdcc13..724593a 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -678,6 +678,7 @@ static int parse_config_file(void) { @@ -888,7 +526,7 @@ #DefaultTasksMax=80% #DefaultLimitCPU= diff --git a/src/core/unit.c b/src/core/unit.c -index 69fc998..38017d0 100644 +index 3d60904..e38a535 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -188,6 +188,7 @@ static void unit_init(Unit *u) { @@ -945,7 +583,7 @@ #include "errno-util.h" #include "extract-word.h" diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c -index bfc8fac..37ec6d6 100644 +index bfc8fac..5dd569f 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -55,6 +55,7 @@ TEST_RET(cgroup_mask, .sd_booted = true) { @@ -956,19 +594,6 @@ m->defaults.blockio_accounting = m->defaults.io_accounting = m->defaults.tasks_accounting = false; -@@ -140,10 +141,10 @@ static void test_cg_mask_to_string_one(CGroupMask mask, const char *t) { - - TEST(cg_mask_to_string) { - test_cg_mask_to_string_one(0, NULL); -- test_cg_mask_to_string_one(_CGROUP_MASK_ALL, "cpu cpuacct cpuset io blkio memory devices pids bpf-firewall bpf-devices bpf-foreign bpf-socket-bind bpf-restrict-network-interfaces"); -+ test_cg_mask_to_string_one(_CGROUP_MASK_ALL, "cpu cpuacct cpuset2 io blkio memory devices pids cpuset bpf-firewall bpf-devices bpf-foreign bpf-socket-bind bpf-restrict-network-interfaces"); - test_cg_mask_to_string_one(CGROUP_MASK_CPU, "cpu"); - test_cg_mask_to_string_one(CGROUP_MASK_CPUACCT, "cpuacct"); -- test_cg_mask_to_string_one(CGROUP_MASK_CPUSET, "cpuset"); -+ test_cg_mask_to_string_one(CGROUP_MASK_CPUSET2, "cpuset2"); - test_cg_mask_to_string_one(CGROUP_MASK_IO, "io"); - test_cg_mask_to_string_one(CGROUP_MASK_BLKIO, "blkio"); - test_cg_mask_to_string_one(CGROUP_MASK_MEMORY, "memory"); diff --git a/test/fuzz/fuzz-unit-file/directives-all.service b/test/fuzz/fuzz-unit-file/directives-all.service index 4bdc48a..0e953f2 100644 --- a/test/fuzz/fuzz-unit-file/directives-all.service @@ -986,5 +611,5 @@ CPUWeight= CapabilityBoundingSet= -- -2.41.0 +2.23.0
View file
_service:tar_scm:core-cgroup-support-freezer.patch
Changed
@@ -65,9 +65,9 @@ --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -2359,6 +2359,7 @@ static const char *const cgroup_controller_table_CGROUP_CONTROLLER_MAX = { + CGROUP_CONTROLLER_MEMORY = "memory", CGROUP_CONTROLLER_DEVICES = "devices", CGROUP_CONTROLLER_PIDS = "pids", - CGROUP_CONTROLLER_CPUSET = "cpuset", + CGROUP_CONTROLLER_FREEZER = "freezer", CGROUP_CONTROLLER_BPF_FIREWALL = "bpf-firewall", CGROUP_CONTROLLER_BPF_DEVICES = "bpf-devices", @@ -77,17 +77,17 @@ --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -29,6 +29,7 @@ typedef enum CGroupController { + CGROUP_CONTROLLER_MEMORY, CGROUP_CONTROLLER_DEVICES, /* v1 only */ CGROUP_CONTROLLER_PIDS, - CGROUP_CONTROLLER_CPUSET, -+ CGROUP_CONTROLLER_FREEZER, ++ CGROUP_CONTROLLER_FREEZER, /* v1 only */ /* BPF-based pseudo-controllers, v2 only */ CGROUP_CONTROLLER_BPF_FIREWALL, @@ -57,6 +58,7 @@ typedef enum CGroupMask { + CGROUP_MASK_MEMORY = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_MEMORY), CGROUP_MASK_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_DEVICES), CGROUP_MASK_PIDS = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_PIDS), - CGROUP_MASK_CPUSET = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUSET), + CGROUP_MASK_FREEZER = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_FREEZER), CGROUP_MASK_BPF_FIREWALL = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FIREWALL), CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES), @@ -110,16 +110,16 @@ .startup_blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID, .tasks_max = CGROUP_TASKS_MAX_UNSET, -+ .freezer_state = NULL, ++ .freezer_state_v1 = NULL, .moom_swap = MANAGED_OOM_AUTO, .moom_mem_pressure = MANAGED_OOM_AUTO, @@ -304,6 +305,9 @@ void cgroup_context_done(CGroupContext *c) { - cpu_set_reset(&c->cpuset_mems2); - cpu_set_reset(&c->startup_cpuset_mems2); + cpu_set_reset(&c->cpuset_mems); + cpu_set_reset(&c->startup_cpuset_mems); -+ if (c->freezer_state) -+ c->freezer_state = mfree(c->freezer_state); ++ if (c->freezer_state_v1) ++ c->freezer_state_v1 = mfree(c->freezer_state_v1); + c->delegate_subgroup = mfree(c->delegate_subgroup); @@ -152,7 +152,7 @@ prefix, yes_no(c->cpuset_clone_children), prefix, yes_no(c->cpuset_memory_migrate), prefix, cgroup_tasks_max_resolve(&c->tasks_max), -+ prefix, c->freezer_state, ++ prefix, c->freezer_state_v1, prefix, cgroup_device_policy_to_string(c->device_policy), prefix, strempty(disable_controllers_str), prefix, delegate_str, @@ -160,19 +160,19 @@ } } -+ if ((apply_mask & CGROUP_MASK_FREEZER) && !is_local_root) { -+ if (c->freezer_state) -+ (void) set_attribute_and_warn(u, "freezer", "freezer.state", c->freezer_state); ++ if ((apply_mask & CGROUP_MASK_FREEZER) && !is_local_root && cg_all_unified() == 0) { ++ if (c->freezer_state_v1) ++ (void) set_attribute_and_warn(u, "freezer", "freezer.state", c->freezer_state_v1); + } + /* On cgroup v2 we can apply BPF everywhere. On cgroup v1 we apply it everywhere except for the root of * containers, where we leave this to the manager */ if ((apply_mask & (CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES)) && @@ -2115,6 +2128,9 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { - c->cpuset_mems) - mask |= CGROUP_MASK_CPUSET; + unit_has_unified_memory_config(u)) + mask |= CGROUP_MASK_MEMORY; -+ if (c->freezer_accounting || c->freezer_state) ++ if (c->freezer_accounting || c->freezer_state_v1) + mask |= CGROUP_MASK_FREEZER; + if (c->device_allow || @@ -195,7 +195,7 @@ CGroupTasksMax tasks_max; + /* Freezer */ -+ char *freezer_state; ++ char *freezer_state_v1; + /* Settings for systemd-oomd */ ManagedOOMMode moom_swap; @@ -205,11 +205,11 @@ --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -493,6 +493,8 @@ const sd_bus_vtable bus_cgroup_vtable = { - SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems), 0), + SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems_v1), 0), SD_BUS_PROPERTY("CPUSetCloneChildren", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_clone_children), 0), SD_BUS_PROPERTY("CPUSetMemMigrate", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_memory_migrate), 0), + SD_BUS_PROPERTY("FreezerAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, freezer_accounting), 0), -+ SD_BUS_PROPERTY("FreezerState", "s", NULL, offsetof(CGroupContext, freezer_state), 0), ++ SD_BUS_PROPERTY("FreezerState", "s", NULL, offsetof(CGroupContext, freezer_state_v1), 0), SD_BUS_PROPERTY("DevicePolicy", "s", property_get_cgroup_device_policy, offsetof(CGroupContext, device_policy), 0), SD_BUS_PROPERTY("DeviceAllow", "a(ss)", property_get_device_allow, 0, 0), SD_BUS_PROPERTY("TasksAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, tasks_accounting), 0), @@ -237,13 +237,13 @@ + if (!UNIT_WRITE_FLAGS_NOOP(flags)) { + unit_invalidate_cgroup(u, CGROUP_MASK_FREEZER); + -+ if (c->freezer_state) { -+ free(c->freezer_state); -+ c->freezer_state = NULL; ++ if (c->freezer_state_v1) { ++ free(c->freezer_state_v1); ++ c->freezer_state_v1 = NULL; + } + -+ c->freezer_state = strdup(state); -+ if (!c->freezer_state) ++ c->freezer_state_v1 = strdup(state); ++ if (!c->freezer_state_v1) + return -ENOMEM; + + unit_write_settingf(u, flags, name, "FreezerState=%s", state); @@ -271,11 +271,11 @@ --- a/src/core/load-fragment-gperf.gperf.in +++ b/src/core/load-fragment-gperf.gperf.in @@ -226,6 +226,8 @@ - {{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems) + {{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems_v1) {{type}}.CPUSetCloneChildren, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_clone_children) {{type}}.CPUSetMemMigrate, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_memory_migrate) +{{type}}.FreezerAccounting, config_parse_bool, 0, offsetof({{type}}, cgroup_context.freezer_accounting) -+{{type}}.FreezerState, config_parse_freezer_state, 0, offsetof({{type}}, cgroup_context.freezer_state) ++{{type}}.FreezerState, config_parse_freezer_state, 0, offsetof({{type}}, cgroup_context.freezer_state_v1) {{type}}.DeviceAllow, config_parse_device_allow, 0, offsetof({{type}}, cgroup_context) {{type}}.DevicePolicy, config_parse_device_policy, 0, offsetof({{type}}, cgroup_context.device_policy) {{type}}.IOAccounting, config_parse_bool, 0, offsetof({{type}}, cgroup_context.io_accounting) @@ -511,11 +511,11 @@ TEST(cg_mask_to_string) { test_cg_mask_to_string_one(0, NULL); -- test_cg_mask_to_string_one(_CGROUP_MASK_ALL, "cpu cpuacct cpuset2 io blkio memory devices pids cpuset bpf-firewall bpf-devices bpf-foreign bpf-socket-bind bpf-restrict-network-interfaces"); -+ test_cg_mask_to_string_one(_CGROUP_MASK_ALL, "cpu cpuacct cpuset2 io blkio memory devices pids cpuset freezer bpf-firewall bpf-devices bpf-foreign bpf-socket-bind bpf-restrict-network-interfaces"); +- test_cg_mask_to_string_one(_CGROUP_MASK_ALL, "cpu cpuacct cpuset io blkio memory devices pids bpf-firewall bpf-devices bpf-foreign bpf-socket-bind bpf-restrict-network-interfaces"); ++ test_cg_mask_to_string_one(_CGROUP_MASK_ALL, "cpu cpuacct cpuset io blkio memory devices pids freezer bpf-firewall bpf-devices bpf-foreign bpf-socket-bind bpf-restrict-network-interfaces"); test_cg_mask_to_string_one(CGROUP_MASK_CPU, "cpu"); test_cg_mask_to_string_one(CGROUP_MASK_CPUACCT, "cpuacct"); - test_cg_mask_to_string_one(CGROUP_MASK_CPUSET2, "cpuset2"); + test_cg_mask_to_string_one(CGROUP_MASK_CPUSET, "cpuset"); diff --git a/test/fuzz/fuzz-unit-file/directives-all.service b/test/fuzz/fuzz-unit-file/directives-all.service index 0e953f2..123c98e 100644 --- a/test/fuzz/fuzz-unit-file/directives-all.service
View file
_service:tar_scm:core-cgroup-support-memorysw.patch
Changed
@@ -41,8 +41,8 @@ prefix, c->startup_memory_zswap_max, format_cgroup_memory_limit_comparison(cdk, sizeof(cdk), u, "StartupMemoryZSwapMax"), prefix, c->memory_limit, + prefix, c->memory_memsw_limit, - prefix, c->cpuset_cpus, - prefix, c->cpuset_mems, + prefix, c->cpuset_cpus_v1, + prefix, c->cpuset_mems_v1, prefix, yes_no(c->cpuset_clone_children), @@ -1908,14 +1911,17 @@ static void cgroup_context_apply( @@ -107,8 +107,8 @@ SD_BUS_PROPERTY("MemoryLimit", "t", NULL, offsetof(CGroupContext, memory_limit), 0), + SD_BUS_PROPERTY("MemoryMemswLimit", "t", NULL, offsetof(CGroupContext, memory_memsw_limit), 0), SD_BUS_PROPERTY("CPUSetAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpuset_accounting), 0), - SD_BUS_PROPERTY("CPUSetCpus", "s", NULL, offsetof(CGroupContext, cpuset_cpus), 0), - SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems), 0), + SD_BUS_PROPERTY("CPUSetCpus", "s", NULL, offsetof(CGroupContext, cpuset_cpus_v1), 0), + SD_BUS_PROPERTY("CPUSetMems", "s", NULL, offsetof(CGroupContext, cpuset_mems_v1), 0), @@ -1243,6 +1244,9 @@ int bus_cgroup_set_property( if (streq(name, "MemoryLimit")) return bus_cgroup_set_memory(u, name, &c->memory_limit, message, flags, error); @@ -129,8 +129,8 @@ {{type}}.MemoryLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) +{{type}}.MemoryMemswLimit, config_parse_memory_limit, 0, offsetof({{type}}, cgroup_context) {{type}}.CPUSetAccounting, config_parse_bool, 0, offsetof({{type}}, cgroup_context.cpuset_accounting) - {{type}}.CPUSetCpus, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_cpus) - {{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems) + {{type}}.CPUSetCpus, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_cpus_v1) + {{type}}.CPUSetMems, config_parse_cpuset_cpumems, 0, offsetof({{type}}, cgroup_context.cpuset_mems_v1) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 8648fb1..aaf906f 100644 --- a/src/core/load-fragment.c
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/systemd.git</param> - <param name="revision">openEuler-24.03-LTS-Next</param> + <param name="revision">openEuler-24.03-LTS-SP1</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2