1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-22 22:03:43 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-03-09 09:27:31 +01:00 committed by Yu Watanabe
parent 5d2ab010df
commit 7b3693e4e4

View 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",