]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cpuset: add cpu_map_configured() to know if a cpu-map was found
authorWilly Tarreau <w@1wt.eu>
Tue, 18 Jul 2023 15:14:10 +0000 (17:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Jul 2023 09:01:09 +0000 (11:01 +0200)
Since we'll soon want to adjust the "thread-groups" degree of freedom
based on the presence of cpu-map, we first need to be able to detect
if cpu-map was used. This function scans all cpu-map sets to detect if
any is present, and returns true accordingly.

include/haproxy/cpuset.h
src/cpuset.c

index 2977b38feb903099d5677317b6e8b0e00347df98..4f795f2643ae4a4f12746e03aa0b287c91a1914b 100644 (file)
@@ -41,4 +41,9 @@ void ha_cpuset_assign(struct hap_cpuset *dst, struct hap_cpuset *src);
  */
 int ha_cpuset_size(void);
 
+/* Returns true if at least one cpu-map directive was configured, otherwise
+ * false.
+ */
+int cpu_map_configured(void);
+
 #endif /* _HAPROXY_CPUSET_H */
index e789b23a9030e53314af6520ecb048ac3d92ae99..76fad1fb211ebff8ee0518edb3fa30828480e90c 100644 (file)
@@ -118,3 +118,20 @@ int ha_cpuset_size()
 
 #endif
 }
+
+/* Returns true if at least one cpu-map directive was configured, otherwise
+ * false.
+ */
+int cpu_map_configured(void)
+{
+       int grp, thr;
+
+       for (grp = 0; grp < MAX_TGROUPS; grp++) {
+               if (ha_cpuset_count(&cpu_map[grp].proc))
+                       return 1;
+               for (thr = 0; thr < MAX_THREADS_PER_GROUP; thr++)
+                       if (ha_cpuset_count(&cpu_map[grp].thread[thr]))
+                               return 1;
+       }
+       return 0;
+}