From 7239ebdbadd184b8c44a2c90a7a9b83f506f7ccc Mon Sep 17 00:00:00 2001 From: h30032433 Date: Tue, 27 Feb 2024 15:51:38 +0800 Subject: [PATCH] add cpuset-cgv1 and freezer-cgv1 macros and enabled by default (cherry picked from commit 68868dbe7e14c45dcb44d2ef4860bca1aaa9e085) --- core-cgroup-support-cpuset.patch | 103 ++++++++++++++++++++---------- core-cgroup-support-freezer.patch | 85 ++++++++++++++++-------- systemd.spec | 5 +- 3 files changed, 134 insertions(+), 59 deletions(-) diff --git a/core-cgroup-support-cpuset.patch b/core-cgroup-support-cpuset.patch index 7902994..3bb80b3 100644 --- a/core-cgroup-support-cpuset.patch +++ b/core-cgroup-support-cpuset.patch @@ -5,8 +5,10 @@ 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 | 10 ++- + src/basic/cgroup-util.h | 14 ++- src/basic/string-util.c | 42 +++++++++ src/basic/string-util.h | 2 + src/core/cgroup.c | 86 ++++++++++++++++--- @@ -31,8 +33,39 @@ This patch add support for cpuset subsystem. test/fuzz/fuzz-unit-file/directives.slice | 5 ++ test/fuzz/fuzz-unit-file/directives.socket | 5 ++ test/fuzz/fuzz-unit-file/directives.swap | 5 ++ - 26 files changed, 319 insertions(+), 30 deletions(-) + 28 files changed, 328 insertions(+), 30 deletions(-) +diff --git a/meson.build b/meson.build +index b04551f..b089ac4 100644 +--- a/meson.build ++++ b/meson.build +@@ -1502,6 +1502,7 @@ foreach term : ['analyze', + 'backlight', + 'binfmt', + 'coredump', ++ 'cpuset-cgv1', + 'efi', + 'environment-d', + 'firstboot', +@@ -3905,6 +3906,7 @@ foreach tuple : [ + ['link-timesyncd-shared', get_option('link-timesyncd-shared')], + ['fexecve'], + ['standalone-binaries', get_option('standalone-binaries')], ++ ['cpuset-cgv1'], + ] + + if tuple.length() >= 2 +diff --git a/meson_options.txt b/meson_options.txt +index bb51cfb..4c45798 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -460,3 +460,6 @@ option('analyze', type: 'boolean', value: 'true', + + option('bpf-framework', type : 'combo', choices : ['auto', 'true', 'false'], + description: 'build BPF programs from source code in restricted C') ++ ++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 1ff6160..01a4181 100644 --- a/src/basic/cgroup-util.c @@ -53,7 +86,7 @@ index 1ff6160..01a4181 100644 [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 ce2f4c6..06a23ff 100644 +index ce2f4c6..09b3109 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -20,12 +20,13 @@ typedef enum CGroupController { @@ -71,7 +104,7 @@ index ce2f4c6..06a23ff 100644 /* BPF-based pseudo-controllers, v2 only */ CGROUP_CONTROLLER_BPF_FIREWALL, -@@ -43,22 +44,23 @@ typedef enum CGroupController { +@@ -43,22 +44,27 @@ 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), @@ -90,7 +123,11 @@ index ce2f4c6..06a23ff 100644 /* All real cgroup v1 controllers */ - CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, -+ CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_CPUSET|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, ++ CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS ++#if ENABLE_CPUSET_CGV1 ++ | CGROUP_MASK_CPUSET ++#endif ++ , /* All real cgroup v2 controllers */ - CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, @@ -159,10 +196,10 @@ index 9155e50..338dcd5 100644 + +int string_isvalid_interval(const char *instr); diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index de1d5f4..2c2d1b0 100644 +index b27fce8..895f6b2 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c -@@ -246,8 +246,14 @@ void cgroup_context_done(CGroupContext *c) { +@@ -252,8 +252,14 @@ void cgroup_context_done(CGroupContext *c) { while (c->bpf_foreign_programs) cgroup_context_remove_bpf_foreign_program(c, c->bpf_foreign_programs); @@ -179,7 +216,7 @@ index de1d5f4..2c2d1b0 100644 } static int unit_get_kernel_memory_limit(Unit *u, const char *file, uint64_t *ret) { -@@ -382,7 +388,7 @@ static char *format_cgroup_memory_limit_comparison(char *buf, size_t l, Unit *u, +@@ -388,7 +394,7 @@ static char *format_cgroup_memory_limit_comparison(char *buf, size_t l, Unit *u, } void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { @@ -188,7 +225,7 @@ index de1d5f4..2c2d1b0 100644 CGroupIODeviceLimit *il; CGroupIODeviceWeight *iw; CGroupIODeviceLatency *l; -@@ -412,14 +418,15 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { +@@ -418,14 +424,15 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { (void) cg_mask_to_string(c->disable_controllers, &disable_controllers_str); @@ -206,7 +243,7 @@ index de1d5f4..2c2d1b0 100644 "%sTasksAccounting: %s\n" "%sIPAccounting: %s\n" "%sCPUWeight: %" PRIu64 "\n" -@@ -442,6 +449,10 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { +@@ -448,6 +455,10 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { "%sMemoryMax: %" PRIu64 "%s\n" "%sMemorySwapMax: %" PRIu64 "%s\n" "%sMemoryLimit: %" PRIu64 "\n" @@ -217,7 +254,7 @@ index de1d5f4..2c2d1b0 100644 "%sTasksMax: %" PRIu64 "\n" "%sDevicePolicy: %s\n" "%sDisableControllers: %s\n" -@@ -454,6 +465,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { +@@ -460,6 +471,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, yes_no(c->io_accounting), prefix, yes_no(c->blockio_accounting), prefix, yes_no(c->memory_accounting), @@ -225,7 +262,7 @@ index de1d5f4..2c2d1b0 100644 prefix, yes_no(c->tasks_accounting), prefix, yes_no(c->ip_accounting), prefix, c->cpu_weight, -@@ -462,8 +474,8 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { +@@ -468,8 +480,8 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, c->startup_cpu_shares, prefix, format_timespan(q, sizeof(q), c->cpu_quota_per_sec_usec, 1), prefix, format_timespan(v, sizeof(v), c->cpu_quota_period_usec, 1), @@ -236,7 +273,7 @@ index de1d5f4..2c2d1b0 100644 prefix, c->io_weight, prefix, c->startup_io_weight, prefix, c->blockio_weight, -@@ -476,6 +488,10 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { +@@ -482,6 +494,10 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, c->memory_max, format_cgroup_memory_limit_comparison(cdd, sizeof(cdd), u, "MemoryMax"), prefix, c->memory_swap_max, format_cgroup_memory_limit_comparison(cde, sizeof(cde), u, "MemorySwapMax"), prefix, c->memory_limit, @@ -247,7 +284,7 @@ index de1d5f4..2c2d1b0 100644 prefix, tasks_max_resolve(&c->tasks_max), prefix, cgroup_device_policy_to_string(c->device_policy), prefix, strempty(disable_controllers_str), -@@ -1277,9 +1293,9 @@ static void cgroup_context_apply( +@@ -1325,9 +1341,9 @@ static void cgroup_context_apply( } } @@ -260,7 +297,7 @@ index de1d5f4..2c2d1b0 100644 } /* The 'io' controller attributes are not exported on the host's root cgroup (being a pure cgroup v2 -@@ -1477,6 +1493,45 @@ static void cgroup_context_apply( +@@ -1511,6 +1527,45 @@ static void cgroup_context_apply( } } @@ -306,7 +343,7 @@ index de1d5f4..2c2d1b0 100644 /* 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)) && -@@ -1603,8 +1658,8 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { +@@ -1637,8 +1692,8 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { c->cpu_quota_per_sec_usec != USEC_INFINITY) mask |= CGROUP_MASK_CPU; @@ -317,7 +354,7 @@ index de1d5f4..2c2d1b0 100644 if (cgroup_context_has_io_config(c) || cgroup_context_has_blockio_config(c)) mask |= CGROUP_MASK_IO | CGROUP_MASK_BLKIO; -@@ -1614,6 +1669,11 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { +@@ -1648,6 +1703,11 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { unit_has_unified_memory_config(u)) mask |= CGROUP_MASK_MEMORY; @@ -329,7 +366,7 @@ index de1d5f4..2c2d1b0 100644 if (c->device_allow || c->device_policy != CGROUP_DEVICE_POLICY_AUTO) mask |= CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES; -@@ -3984,7 +4044,7 @@ int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name) { +@@ -4040,7 +4100,7 @@ int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name) { if (!u->cgroup_path) return -ENODATA; @@ -339,7 +376,7 @@ index de1d5f4..2c2d1b0 100644 r = cg_all_unified(); diff --git a/src/core/cgroup.h b/src/core/cgroup.h -index ea92936..a8a4726 100644 +index 3f8cad8..1e27104 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -115,6 +115,7 @@ struct CGroupContext { @@ -464,10 +501,10 @@ index 84c3caf..0cdc98c 100644 } diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c -index de057a0..82896af 100644 +index 05daba4..3d899a5 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c -@@ -2690,6 +2690,7 @@ const sd_bus_vtable bus_manager_vtable[] = { +@@ -2696,6 +2696,7 @@ const sd_bus_vtable bus_manager_vtable[] = { SD_BUS_PROPERTY("DefaultCPUAccounting", "b", bus_property_get_bool, offsetof(Manager, default_cpu_accounting), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultBlockIOAccounting", "b", bus_property_get_bool, offsetof(Manager, default_blockio_accounting), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultMemoryAccounting", "b", bus_property_get_bool, offsetof(Manager, default_memory_accounting), SD_BUS_VTABLE_PROPERTY_CONST), @@ -492,7 +529,7 @@ index 42441ea..60c9dbc 100644 {{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) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c -index 399a759..ad80a64 100644 +index f357408..ed72997 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3632,7 +3632,7 @@ int config_parse_allowed_cpus( @@ -602,7 +639,7 @@ index 45e9c39..1ecad67 100644 CONFIG_PARSER_PROTOTYPE(config_parse_delegate); CONFIG_PARSER_PROTOTYPE(config_parse_managed_oom_mode); diff --git a/src/core/main.c b/src/core/main.c -index 9282b09..c4564e8 100644 +index a9c6222..5726b35 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -148,6 +148,7 @@ static bool arg_default_io_accounting; @@ -613,7 +650,7 @@ index 9282b09..c4564e8 100644 static bool arg_default_tasks_accounting; static TasksMax arg_default_tasks_max; static sd_id128_t arg_machine_id; -@@ -693,6 +694,7 @@ static int parse_config_file(void) { +@@ -702,6 +703,7 @@ static int parse_config_file(void) { { "Manager", "DefaultIPAccounting", config_parse_bool, 0, &arg_default_ip_accounting }, { "Manager", "DefaultBlockIOAccounting", config_parse_bool, 0, &arg_default_blockio_accounting }, { "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting }, @@ -621,7 +658,7 @@ index 9282b09..c4564e8 100644 { "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting }, { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, -@@ -764,6 +766,7 @@ static void set_manager_defaults(Manager *m) { +@@ -773,6 +775,7 @@ static void set_manager_defaults(Manager *m) { m->default_ip_accounting = arg_default_ip_accounting; m->default_blockio_accounting = arg_default_blockio_accounting; m->default_memory_accounting = arg_default_memory_accounting; @@ -629,7 +666,7 @@ index 9282b09..c4564e8 100644 m->default_tasks_accounting = arg_default_tasks_accounting; m->default_tasks_max = arg_default_tasks_max; m->default_oom_policy = arg_default_oom_policy; -@@ -2358,6 +2361,7 @@ static void reset_arguments(void) { +@@ -2414,6 +2417,7 @@ static void reset_arguments(void) { arg_default_ip_accounting = false; arg_default_blockio_accounting = false; arg_default_memory_accounting = MEMORY_ACCOUNTING_DEFAULT; @@ -638,10 +675,10 @@ index 9282b09..c4564e8 100644 arg_default_tasks_max = DEFAULT_TASKS_MAX; arg_machine_id = (sd_id128_t) {}; diff --git a/src/core/manager.c b/src/core/manager.c -index 38482c0..3a12d6d 100644 +index 452d68a..5196619 100644 --- a/src/core/manager.c +++ b/src/core/manager.c -@@ -776,6 +776,7 @@ int manager_new(UnitFileScope scope, ManagerTestRunFlags test_run_flags, Manager +@@ -745,6 +745,7 @@ int manager_new(UnitFileScope scope, ManagerTestRunFlags test_run_flags, Manager .default_timer_accuracy_usec = USEC_PER_MINUTE, .default_memory_accounting = MEMORY_ACCOUNTING_DEFAULT, @@ -650,7 +687,7 @@ index 38482c0..3a12d6d 100644 .default_tasks_max = TASKS_MAX_UNSET, .default_timeout_start_usec = DEFAULT_TIMEOUT_USEC, diff --git a/src/core/manager.h b/src/core/manager.h -index 0c39626..f658caa 100644 +index 5ce9361..50ccb1e 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -360,6 +360,7 @@ struct Manager { @@ -662,7 +699,7 @@ index 0c39626..f658caa 100644 bool default_blockio_accounting; bool default_tasks_accounting; diff --git a/src/core/system.conf.in b/src/core/system.conf.in -index f2c75fc..fcc20d0 100644 +index 4369703..015088c 100644 --- a/src/core/system.conf.in +++ b/src/core/system.conf.in @@ -53,6 +53,7 @@ @@ -674,10 +711,10 @@ index f2c75fc..fcc20d0 100644 #DefaultTasksMax=80% #DefaultLimitCPU= diff --git a/src/core/unit.c b/src/core/unit.c -index e30c14b..bfd47cf 100644 +index 366f602..d601f0c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c -@@ -176,6 +176,7 @@ static void unit_init(Unit *u) { +@@ -177,6 +177,7 @@ static void unit_init(Unit *u) { cc->io_accounting = u->manager->default_io_accounting; cc->blockio_accounting = u->manager->default_blockio_accounting; cc->memory_accounting = u->manager->default_memory_accounting; @@ -868,5 +905,5 @@ index 582a136..bc07775 100644 CPUWeight= CacheDirectory= -- -2.23.0 +2.33.0 diff --git a/core-cgroup-support-freezer.patch b/core-cgroup-support-freezer.patch index e383190..add8298 100644 --- a/core-cgroup-support-freezer.patch +++ b/core-cgroup-support-freezer.patch @@ -5,8 +5,10 @@ Subject: [PATCH] core-cgroup: support freezer. This patch add support for freezer subsystem. --- + meson.build | 2 + + meson_options.txt | 3 ++ src/basic/cgroup-util.c | 1 + - src/basic/cgroup-util.h | 4 +- + src/basic/cgroup-util.h | 5 +++ src/core/cgroup.c | 16 +++++++ src/core/cgroup.h | 4 ++ src/core/dbus-cgroup.c | 29 +++++++++++++ @@ -29,9 +31,40 @@ This patch add support for freezer subsystem. test/fuzz/fuzz-unit-file/directives.slice | 2 + test/fuzz/fuzz-unit-file/directives.socket | 2 + test/fuzz/fuzz-unit-file/directives.swap | 2 + - 24 files changed, 173 insertions(+), 2 deletions(-) + 26 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 src/test/test-cgroup-freezer.c +diff --git a/meson.build b/meson.build +index b089ac4..3b8d7eb 100644 +--- a/meson.build ++++ b/meson.build +@@ -1506,6 +1506,7 @@ foreach term : ['analyze', + 'efi', + 'environment-d', + 'firstboot', ++ 'freezer-cgv1', + 'gshadow', + 'hibernate', + 'hostnamed', +@@ -3907,6 +3908,7 @@ foreach tuple : [ + ['fexecve'], + ['standalone-binaries', get_option('standalone-binaries')], + ['cpuset-cgv1'], ++ ['freezer-cgv1'], + ] + + if tuple.length() >= 2 +diff --git a/meson_options.txt b/meson_options.txt +index 4c45798..1b829df 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -463,3 +463,6 @@ option('bpf-framework', type : 'combo', choices : ['auto', 'true', 'false'], + + option('cpuset-cgv1', type : 'boolean', value : 'true', + description : 'enable cgroup v1 cpuset support') ++ ++option('freezer-cgv1', type : 'boolean', value : 'true', ++ description : 'enable cgroup v1 freezer support') diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 01a4181..f912b65 100644 --- a/src/basic/cgroup-util.c @@ -45,7 +78,7 @@ index 01a4181..f912b65 100644 [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 06a23ff..a491eca 100644 +index 09b3109..6a27808 100644 --- a/src/basic/cgroup-util.h +++ b/src/basic/cgroup-util.h @@ -27,6 +27,7 @@ typedef enum CGroupController { @@ -56,7 +89,7 @@ index 06a23ff..a491eca 100644 /* BPF-based pseudo-controllers, v2 only */ CGROUP_CONTROLLER_BPF_FIREWALL, -@@ -51,13 +52,14 @@ typedef enum CGroupMask { +@@ -51,6 +52,7 @@ typedef enum CGroupMask { 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), @@ -64,16 +97,18 @@ index 06a23ff..a491eca 100644 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), - CGROUP_MASK_BPF_SOCKET_BIND = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_SOCKET_BIND), +@@ -60,6 +62,9 @@ typedef enum CGroupMask { + CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS + #if ENABLE_CPUSET_CGV1 + | CGROUP_MASK_CPUSET ++#endif ++#if ENABLE_FREEZER_CGV1 ++ | CGROUP_MASK_FREEZER + #endif + , - /* All real cgroup v1 controllers */ -- CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_CPUSET|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, -+ CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_CPUSET|CGROUP_MASK_FREEZER|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, - - /* All real cgroup v2 controllers */ - CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET2|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 83e94c7..f811a8b 100644 +index 895f6b2..4295c6d 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -139,6 +139,7 @@ void cgroup_context_init(CGroupContext *c) { @@ -225,10 +260,10 @@ index 0cdc98c..8527a1a 100644 return bus_cgroup_set_boolean(u, name, &c->tasks_accounting, CGROUP_MASK_PIDS, message, flags, error); diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c -index 82896af..184df9d 100644 +index 3d899a5..5e1ef8d 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c -@@ -2691,6 +2691,7 @@ const sd_bus_vtable bus_manager_vtable[] = { +@@ -2697,6 +2697,7 @@ const sd_bus_vtable bus_manager_vtable[] = { SD_BUS_PROPERTY("DefaultBlockIOAccounting", "b", bus_property_get_bool, offsetof(Manager, default_blockio_accounting), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultMemoryAccounting", "b", bus_property_get_bool, offsetof(Manager, default_memory_accounting), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DefaultCpusetAccounting", "b", bus_property_get_bool, offsetof(Manager, default_cpuset_accounting), SD_BUS_VTABLE_PROPERTY_CONST), @@ -250,7 +285,7 @@ index 60c9dbc..5b7ecd2 100644 {{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) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c -index 5f6a703..d5eb932 100644 +index ed72997..eded5a8 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3791,6 +3791,39 @@ int config_parse_cpuset_cpumems( @@ -306,7 +341,7 @@ index 1ecad67..090776c 100644 CONFIG_PARSER_PROTOTYPE(config_parse_delegate); CONFIG_PARSER_PROTOTYPE(config_parse_managed_oom_mode); diff --git a/src/core/main.c b/src/core/main.c -index 6309aab..9cc7fec 100644 +index 5726b35..801e64b 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -149,6 +149,7 @@ static bool arg_default_ip_accounting; @@ -317,7 +352,7 @@ index 6309aab..9cc7fec 100644 static bool arg_default_tasks_accounting; static TasksMax arg_default_tasks_max; static sd_id128_t arg_machine_id; -@@ -695,6 +696,7 @@ static int parse_config_file(void) { +@@ -704,6 +705,7 @@ static int parse_config_file(void) { { "Manager", "DefaultBlockIOAccounting", config_parse_bool, 0, &arg_default_blockio_accounting }, { "Manager", "DefaultMemoryAccounting", config_parse_bool, 0, &arg_default_memory_accounting }, { "Manager", "DefaultCpusetAccounting", config_parse_bool, 0, &arg_default_cpuset_accounting }, @@ -325,7 +360,7 @@ index 6309aab..9cc7fec 100644 { "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting }, { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, -@@ -767,6 +769,7 @@ static void set_manager_defaults(Manager *m) { +@@ -776,6 +778,7 @@ static void set_manager_defaults(Manager *m) { m->default_blockio_accounting = arg_default_blockio_accounting; m->default_memory_accounting = arg_default_memory_accounting; m->default_cpuset_accounting = arg_default_cpuset_accounting; @@ -333,7 +368,7 @@ index 6309aab..9cc7fec 100644 m->default_tasks_accounting = arg_default_tasks_accounting; m->default_tasks_max = arg_default_tasks_max; m->default_oom_policy = arg_default_oom_policy; -@@ -2405,6 +2408,7 @@ static void reset_arguments(void) { +@@ -2418,6 +2421,7 @@ static void reset_arguments(void) { arg_default_blockio_accounting = false; arg_default_memory_accounting = MEMORY_ACCOUNTING_DEFAULT; arg_default_cpuset_accounting = false; @@ -342,7 +377,7 @@ index 6309aab..9cc7fec 100644 arg_default_tasks_max = DEFAULT_TASKS_MAX; arg_machine_id = (sd_id128_t) {}; diff --git a/src/core/manager.h b/src/core/manager.h -index b7a51cf..72fd86e 100644 +index 50ccb1e..92190c8 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -361,6 +361,7 @@ struct Manager { @@ -354,7 +389,7 @@ index b7a51cf..72fd86e 100644 bool default_blockio_accounting; bool default_tasks_accounting; diff --git a/src/core/system.conf.in b/src/core/system.conf.in -index fcc20d0..f97bd2f 100644 +index 015088c..dfc2477 100644 --- a/src/core/system.conf.in +++ b/src/core/system.conf.in @@ -54,6 +54,7 @@ @@ -366,10 +401,10 @@ index fcc20d0..f97bd2f 100644 #DefaultTasksMax=80% #DefaultLimitCPU= diff --git a/src/core/unit.c b/src/core/unit.c -index 2f20053..70849e4 100644 +index d601f0c..aa1c8a3 100644 --- a/src/core/unit.c +++ b/src/core/unit.c -@@ -177,6 +177,7 @@ static void unit_init(Unit *u) { +@@ -178,6 +178,7 @@ static void unit_init(Unit *u) { cc->blockio_accounting = u->manager->default_blockio_accounting; cc->memory_accounting = u->manager->default_memory_accounting; cc->cpuset_accounting = u->manager->default_cpuset_accounting; @@ -407,7 +442,7 @@ index caad3ab..f20fcbf 100644 if (isempty(eq)) r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", USEC_INFINITY); diff --git a/src/test/meson.build b/src/test/meson.build -index c0faeb4..fc891bb 100644 +index 7d3ab51..870649a 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -450,6 +450,12 @@ tests += [ @@ -585,5 +620,5 @@ index bc07775..6ca6198 100644 IOAccounting= IODeviceLatencyTargetSec= -- -2.23.0 +2.33.0 diff --git a/systemd.spec b/systemd.spec index d3b81e5..8dd0293 100644 --- a/systemd.spec +++ b/systemd.spec @@ -21,7 +21,7 @@ Name: systemd Url: https://www.freedesktop.org/wiki/Software/systemd Version: 249 -Release: 68 +Release: 69 License: MIT and LGPLv2+ and GPLv2+ Summary: System and Service Manager @@ -2131,6 +2131,9 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null && %{_libdir}/security/pam_systemd.so %changelog +* Tue Feb 27 2024 huyubiao - 249-69 +- add cpuset-cgv1 and freezer-cgv1 macros and enabled by default + * Mon Feb 26 2024 jiangchuangang - 249-68 - avoid calling manager_status_printf to reduce the size of systemd-shutdown