From 17601d0cafbd5c82df6d5a14a7dc314d0997a725 Mon Sep 17 00:00:00 2001 From: Michal Sekletar Date: Mar 16 2021 04:19:34 +0000 Subject: execute: dump CPUAffinity as a range string instead of a list of CPUs We do this already when printing the property in systemctl so be consistent and do the same for systemd-analyze dump. (cherry picked from commit e7fca352ba43988682a927de6b1f629b3f10a415) Related: #1734787 patch_name: 0286-execute-dump-CPUAffinity-as-a-range-string-instead-o.patch present_in_specfile: true location_in_specfile: 286 squash_commits: true --- diff --git a/src/core/execute.c b/src/core/execute.c index 22e5825..bc26aa6 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -4098,11 +4098,10 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { } if (c->cpu_set.set) { - fprintf(f, "%sCPUAffinity:", prefix); - for (i = 0; i < c->cpu_set.allocated * 8; i++) - if (CPU_ISSET_S(i, c->cpu_set.allocated, c->cpu_set.set)) - fprintf(f, " %u", i); - fputs("\n", f); + _cleanup_free_ char *affinity = NULL; + + affinity = cpu_set_to_range_string(&c->cpu_set); + fprintf(f, "%sCPUAffinity: %s\n", prefix, affinity); } if (c->timer_slack_nsec != NSEC_INFINITY)