From: Zbigniew Jędrzejewski-Szmek Date: Thu, 9 Mar 2023 08:27:31 +0000 (+0100) Subject: manager: in dump, show controllers in "Delegate:" X-Git-Tag: v254-rc1~1081 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b3693e4e4c9cae50fca65136278a62fae11327e;p=thirdparty%2Fsystemd.git manager: in dump, show controllers in "Delegate:" After Delegate= was converted from boolean to a controller list, the dump output was changed to have a separate line about the delegated controllers: ... DevicePolicy: auto DisableControllers: Delegate: yes ManagedOOMSwap: auto ManagedOOMMemoryPressure: auto ManagedOOMMemoryPressureLimit: 0.00% ManagedOOMPreference: none DelegateControllers: cpu memory pids ... The line with "Delegate:" is redundant, it effectively shows if "DelegateControllers:" is non-empty. It is nicer to keep the lines about controllers adjacent. And to avoid duplicate output, Delegate: will now show which controllers are enabled. This makes the output for that line again match the configuration stanza Delegate=: DisableControllers: Delegate: cpu io memory pids ManagedOOMSwap: auto ManagedOOMMemoryPressure: auto ManagedOOMMemoryPressureLimit: 0.00% ManagedOOMPreference: none MemoryPressureWatch: auto MemoryPressureThresholdSec: 100ms Dump output is for debugging, we don't need to maintain strict backwards-compat. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 41eb755fa5d..19469c4ae08 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -448,7 +448,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) { - _cleanup_free_ char *disable_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_cpus = NULL, *cpuset_mems = NULL, *startup_cpuset_cpus = NULL, *startup_cpuset_mems = NULL; CGroupContext *c; struct in_addr_prefix *iaai; @@ -472,6 +472,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix = strempty(prefix); (void) cg_mask_to_string(c->disable_controllers, &disable_controllers_str); + (void) cg_mask_to_string(c->delegate_controllers, &delegate_controllers_str); cpuset_cpus = cpu_set_to_range_string(&c->cpuset_cpus); startup_cpuset_cpus = cpu_set_to_range_string(&c->startup_cpuset_cpus); @@ -559,7 +560,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, tasks_max_resolve(&c->tasks_max), prefix, cgroup_device_policy_to_string(c->device_policy), prefix, strempty(disable_controllers_str), - prefix, yes_no(c->delegate), + prefix, strempty(delegate_controllers_str), prefix, managed_oom_mode_to_string(c->moom_swap), prefix, managed_oom_mode_to_string(c->moom_mem_pressure), prefix, PERMYRIAD_AS_PERCENT_FORMAT_VAL(UINT32_SCALE_TO_PERMYRIAD(c->moom_mem_pressure_limit)), @@ -570,16 +571,6 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { fprintf(f, "%sMemoryPressureThresholdSec: %s\n", prefix, FORMAT_TIMESPAN(c->memory_pressure_threshold_usec, 1)); - if (c->delegate) { - _cleanup_free_ char *t = NULL; - - (void) cg_mask_to_string(c->delegate_controllers, &t); - - fprintf(f, "%sDelegateControllers: %s\n", - prefix, - strempty(t)); - } - LIST_FOREACH(device_allow, a, c->device_allow) fprintf(f, "%sDeviceAllow: %s %s%s%s\n",