ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
64ccc2
From 1ad8be47cd41f017faa5a9ca9614cbcbe784d43b Mon Sep 17 00:00:00 2001
64ccc2
From: Jacek Migacz <jmigacz@redhat.com>
64ccc2
Date: Mon, 25 Apr 2022 21:12:40 +0200
64ccc2
Subject: [PATCH] Revert "basic: use comma as separator in cpuset cgroup cpu
64ccc2
 ranges"
64ccc2
64ccc2
This reverts commit 9fe3b9c7165afeedcf9f31959c436bcec233bb4d.
64ccc2
64ccc2
RHEL-only
64ccc2
64ccc2
Resolves: #1858220
64ccc2
---
64ccc2
 src/basic/cpu-set-util.c | 45 ----------------------------------------
64ccc2
 src/basic/cpu-set-util.h |  1 -
64ccc2
 src/core/cgroup.c        |  2 +-
64ccc2
 3 files changed, 1 insertion(+), 47 deletions(-)
64ccc2
64ccc2
diff --git a/src/basic/cpu-set-util.c b/src/basic/cpu-set-util.c
64ccc2
index 1922c95864..db2e1d6c97 100644
64ccc2
--- a/src/basic/cpu-set-util.c
64ccc2
+++ b/src/basic/cpu-set-util.c
64ccc2
@@ -88,51 +88,6 @@ char *cpu_set_to_range_string(const CPUSet *set) {
64ccc2
         return TAKE_PTR(str) ?: strdup("");
64ccc2
 }
64ccc2
 
64ccc2
-/* XXX(msekleta): this is the workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1819152, remove in 8.3 */
64ccc2
-char *cpu_set_to_range_string_kernel(const CPUSet *set) {
64ccc2
-        unsigned range_start = 0, range_end;
64ccc2
-        _cleanup_free_ char *str = NULL;
64ccc2
-        size_t allocated = 0, len = 0;
64ccc2
-        bool in_range = false;
64ccc2
-        int r;
64ccc2
-
64ccc2
-        for (unsigned i = 0; i < set->allocated * 8; i++)
64ccc2
-                if (CPU_ISSET_S(i, set->allocated, set->set)) {
64ccc2
-                        if (in_range)
64ccc2
-                                range_end++;
64ccc2
-                        else {
64ccc2
-                                range_start = range_end = i;
64ccc2
-                                in_range = true;
64ccc2
-                        }
64ccc2
-                } else if (in_range) {
64ccc2
-                        in_range = false;
64ccc2
-
64ccc2
-                        if (!GREEDY_REALLOC(str, allocated, len + 2 + 2 * DECIMAL_STR_MAX(unsigned)))
64ccc2
-                                return NULL;
64ccc2
-
64ccc2
-                        if (range_end > range_start)
64ccc2
-                                r = sprintf(str + len, len > 0 ? ",%d-%d" : "%d-%d", range_start, range_end);
64ccc2
-                        else
64ccc2
-                                r = sprintf(str + len, len > 0 ? ",%d" : "%d", range_start);
64ccc2
-                        assert_se(r > 0);
64ccc2
-                        len += r;
64ccc2
-                }
64ccc2
-
64ccc2
-        if (in_range) {
64ccc2
-                if (!GREEDY_REALLOC(str, allocated, len + 2 + 2 * DECIMAL_STR_MAX(int)))
64ccc2
-                        return NULL;
64ccc2
-
64ccc2
-                if (range_end > range_start)
64ccc2
-                        r = sprintf(str + len, len > 0 ? ",%d-%d" : "%d-%d", range_start, range_end);
64ccc2
-                else
64ccc2
-                        r = sprintf(str + len, len > 0 ? ",%d" : "%d", range_start);
64ccc2
-                assert_se(r > 0);
64ccc2
-        }
64ccc2
-
64ccc2
-        return TAKE_PTR(str) ?: strdup("");
64ccc2
-}
64ccc2
-
64ccc2
-
64ccc2
 int cpu_set_realloc(CPUSet *cpu_set, unsigned ncpus) {
64ccc2
         size_t need;
64ccc2
 
64ccc2
diff --git a/src/basic/cpu-set-util.h b/src/basic/cpu-set-util.h
64ccc2
index 795be807af..406b08ee11 100644
64ccc2
--- a/src/basic/cpu-set-util.h
64ccc2
+++ b/src/basic/cpu-set-util.h
64ccc2
@@ -27,7 +27,6 @@ int cpu_set_add_all(CPUSet *a, const CPUSet *b);
64ccc2
 
64ccc2
 char* cpu_set_to_string(const CPUSet *a);
64ccc2
 char *cpu_set_to_range_string(const CPUSet *a);
64ccc2
-char *cpu_set_to_range_string_kernel(const CPUSet *a);
64ccc2
 int cpu_set_realloc(CPUSet *cpu_set, unsigned ncpus);
64ccc2
 
64ccc2
 int parse_cpu_set_full(
64ccc2
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
64ccc2
index f02cc31c6e..f89bce3d61 100644
64ccc2
--- a/src/core/cgroup.c
64ccc2
+++ b/src/core/cgroup.c
64ccc2
@@ -687,7 +687,7 @@ static void cgroup_apply_unified_cpuset(Unit *u, CPUSet cpus, const char *name)
64ccc2
         _cleanup_free_ char *buf = NULL;
64ccc2
         int r;
64ccc2
 
64ccc2
-        buf = cpu_set_to_range_string_kernel(&cpus);
64ccc2
+        buf = cpu_set_to_range_string(&cpus);
64ccc2
         if (!buf)
64ccc2
             return;
64ccc2