diff --git a/include/haproxy/cpuset.h b/include/haproxy/cpuset.h index 2977b38fe..4f795f264 100644 --- a/include/haproxy/cpuset.h +++ b/include/haproxy/cpuset.h @@ -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 */ diff --git a/src/cpuset.c b/src/cpuset.c index e789b23a9..76fad1fb2 100644 --- a/src/cpuset.c +++ b/src/cpuset.c @@ -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; +}