ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
b9a53a
From b90f935f8d2268522480a7c12f7e2213a7a5e19d Mon Sep 17 00:00:00 2001
b9a53a
From: Michal Sekletar <msekleta@redhat.com>
b9a53a
Date: Fri, 31 May 2019 18:02:20 +0200
b9a53a
Subject: [PATCH] execute: dump CPUAffinity as a range string instead of a list
b9a53a
 of CPUs
b9a53a
b9a53a
We do this already when printing the property in systemctl so be
b9a53a
consistent and do the same for systemd-analyze dump.
b9a53a
b9a53a
(cherry picked from commit e7fca352ba43988682a927de6b1f629b3f10a415)
b9a53a
b9a53a
Related: #1734787
b9a53a
---
b9a53a
 src/core/execute.c | 9 ++++-----
b9a53a
 1 file changed, 4 insertions(+), 5 deletions(-)
b9a53a
b9a53a
diff --git a/src/core/execute.c b/src/core/execute.c
b9a53a
index 22e5825905..bc26aa66e7 100644
b9a53a
--- a/src/core/execute.c
b9a53a
+++ b/src/core/execute.c
b9a53a
@@ -4098,11 +4098,10 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
b9a53a
         }
b9a53a
 
b9a53a
         if (c->cpu_set.set) {
b9a53a
-                fprintf(f, "%sCPUAffinity:", prefix);
b9a53a
-                for (i = 0; i < c->cpu_set.allocated * 8; i++)
b9a53a
-                        if (CPU_ISSET_S(i, c->cpu_set.allocated, c->cpu_set.set))
b9a53a
-                                fprintf(f, " %u", i);
b9a53a
-                fputs("\n", f);
b9a53a
+                _cleanup_free_ char *affinity = NULL;
b9a53a
+
b9a53a
+                affinity = cpu_set_to_range_string(&c->cpu_set);
b9a53a
+                fprintf(f, "%sCPUAffinity: %s\n", prefix, affinity);
b9a53a
         }
b9a53a
 
b9a53a
         if (c->timer_slack_nsec != NSEC_INFINITY)