naccyde / rpms / systemd

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