]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: in dump, show controllers in "Delegate:"
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 9 Mar 2023 08:27:31 +0000 (09:27 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Mar 2023 12:36:38 +0000 (21:36 +0900)
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.

src/core/cgroup.c

index 41eb755fa5d0c5dfc1f6f7e60a4f11ea99b10656..19469c4ae08aaccf8bf3beb256ea8d580638a4f3 100644 (file)
@@ -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",