]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cpu-topo: Turn the cpu policy configuration into a struct
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 26 Nov 2025 17:13:14 +0000 (18:13 +0100)
committerOlivier Houchard <cognet@ci0.org>
Thu, 18 Dec 2025 17:52:52 +0000 (18:52 +0100)
Turn the cpu policy configuration into a struct. Right now it just
contains an int, that represents the policy used, but will get more
information soon.

src/cpu_topo.c

index b5840e5078a323cab1189b0bae9e54e753e94f80..ba35b45ab1b859d86bf2764d69e4b1ee84420add 100644 (file)
@@ -48,7 +48,11 @@ struct cpu_set_cfg {
 } cpu_set_cfg;
 
 /* CPU policy choice */
-static int cpu_policy = 1; // "first-usable-node"
+struct {
+       int cpu_policy;
+} cpu_policy_conf = {
+                       1, /* "first-usable-node" */
+};
 
 /* list of CPU policies for "cpu-policy". The default one is the first one. */
 static int cpu_policy_first_usable_node(int policy, int tmin, int tmax, int gmin, int gmax, char **err);
@@ -1459,12 +1463,12 @@ int cpu_apply_policy(int tmin, int tmax, int gmin, int gmax, char **err)
                return 0;
        }
 
-       if (!ha_cpu_policy[cpu_policy].fct) {
+       if (!ha_cpu_policy[cpu_policy_conf.cpu_policy].fct) {
                /* nothing to do */
                return 0;
        }
 
-       if (ha_cpu_policy[cpu_policy].fct(cpu_policy, tmin, tmax, gmin, gmax, err) < 0)
+       if (ha_cpu_policy[cpu_policy_conf.cpu_policy].fct(cpu_policy_conf.cpu_policy, tmin, tmax, gmin, gmax, err) < 0)
                return -1;
 
        return 0;
@@ -1942,7 +1946,7 @@ static int cfg_parse_cpu_policy(char **args, int section_type, struct proxy *cur
 
        for (i = 0; ha_cpu_policy[i].name; i++) {
                if (strcmp(args[1], ha_cpu_policy[i].name) == 0) {
-                       cpu_policy = i;
+                       cpu_policy_conf.cpu_policy = i;
                        return 0;
                }
        }