dryang / rpms / systemd

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