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