]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: cfgparse: modify preprocessor guards around numa detection code
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 15 Dec 2021 08:48:39 +0000 (09:48 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 15 Dec 2021 10:05:51 +0000 (11:05 +0100)
numa_detect_topology() is always define now if USE_CPU_AFFINITY is
activated. For the moment, only on Linux an actual implementation is
provided. For other platforms, it always return 0.

This change has been made to easily add implementation of NUMA detection
for other platforms. The phrasing of the documentation has also been
edited to removed the mention of Linux-only on numa-cpu-mapping
configuration option.

doc/configuration.txt
src/cfgparse.c

index b1fbd6480e68a7821f19159f785f1a88d5f59783..2620706c188c8fad0ba20c5858d5401d9747e058 100644 (file)
@@ -1736,15 +1736,16 @@ nbthread <number>
   output of "haproxy -vv".
 
 numa-cpu-mapping
-  By default, if running on Linux, HAProxy inspects on startup the CPU topology
-  of the machine. If a multi-socket machine is detected, the affinity is
-  automatically calculated to run on the CPUs of a single node. This is done in
-  order to not suffer from the performance penalties caused by the inter-socket
-  bus latency. However, if the applied binding is non optimal on a particular
-  architecture, it can be disabled with the statement 'no numa-cpu-mapping'.
-  This automatic binding is also not applied if a nbthread statement is present
-  in the configuration, or the affinity of the process is already specified,
-  for example via the 'cpu-map' directive or the taskset utility.
+  If running on a NUMA-aware platform, HAProxy inspects on startup the CPU
+  topology of the machine. If a multi-socket machine is detected, the affinity
+  is automatically calculated to run on the CPUs of a single node. This is done
+  in order to not suffer from the performance penalties caused by the
+  inter-socket bus latency. However, if the applied binding is non optimal on a
+  particular architecture, it can be disabled with the statement 'no
+  numa-cpu-mapping'. This automatic binding is also not applied if a nbthread
+  statement is present in the configuration, or the affinity of the process is
+  already specified, for example via the 'cpu-map' directive or the taskset
+  utility.
 
 pidfile <pidfile>
   Writes PIDs of all daemons into file <pidfile> when daemon mode or writes PID
index 06352e294f239e1b869f600e3af405d5399abb7f..7b350529d1ad10d30d53bd4f81b2732ac67877c1 100644 (file)
@@ -2212,7 +2212,9 @@ err:
        return err_code;
 }
 
-#if defined(USE_THREAD) && defined(__linux__) && defined USE_CPU_AFFINITY
+#if defined(USE_THREAD) && defined USE_CPU_AFFINITY
+#if defined(__linux__)
+
 /* filter directory name of the pattern node<X> */
 static int numa_filter(const struct dirent *dir)
 {
@@ -2372,7 +2374,15 @@ static int numa_detect_topology()
 
        return ha_cpuset_count(&node_cpu_set);
 }
-#endif /* __linux__ && USE_CPU_AFFINITY */
+
+#else
+static int numa_detect_topology()
+{
+       return 0;
+}
+
+#endif
+#endif /* USE_THREAD && USE_CPU_AFFINITY */
 
 /*
  * Returns the error code, 0 if OK, or any combination of :
@@ -2425,7 +2435,7 @@ int check_config_validity()
 #if defined(USE_THREAD)
                {
                        int numa_cores = 0;
-#if defined(__linux__) && defined USE_CPU_AFFINITY
+#if defined(USE_CPU_AFFINITY)
                        if (global.numa_cpu_mapping && !thread_cpu_mask_forced())
                                numa_cores = numa_detect_topology();
 #endif