#include <haproxy/cpuset-t.h>
-extern struct cpu_map cpu_map[MAX_TGROUPS];
+extern struct cpu_map *cpu_map;
/* Unset all indexes in <set>.
*/
#include <haproxy/cpuset.h>
#include <haproxy/intops.h>
-struct cpu_map cpu_map[MAX_TGROUPS];
+struct cpu_map *cpu_map;
void ha_cpuset_zero(struct hap_cpuset *set)
{
}
return 0;
}
+
+/* Allocates everything needed to store CPU information at boot.
+ * Returns non-zero on success, zero on failure.
+ */
+static int cpuset_alloc(void)
+{
+ /* allocate the structures used to store CPU topology info */
+ cpu_map = (struct cpu_map*)calloc(MAX_TGROUPS, sizeof(*cpu_map));
+ if (!cpu_map)
+ return 0;
+
+ return 1;
+}
+
+static void cpuset_deinit(void)
+{
+ ha_free(&cpu_map);
+}
+
+INITCALL0(STG_ALLOC, cpuset_alloc);
+REGISTER_POST_DEINIT(cpuset_deinit);
exit(EXIT_FAILURE);
}
- /* Some CPU affinity stuff may have to be initialized */
-#ifdef USE_CPU_AFFINITY
- {
- int g, i;
-
- for (g = 0; g < MAX_TGROUPS; g++) {
- for (i = 0; i < MAX_THREADS_PER_GROUP; ++i) {
- ha_cpuset_zero(&cpu_map[g].thread[i]);
- }
- }
- }
-#endif
-
/* extract the program name from argv[0], it will be used for the logs
* and error messages.
*/