goto out;
}
*slash = '/';
- }
+ } else
+ thread = ~0UL; /* missing '/' = 'all' */
+
+ /* from now on, thread cannot be NULL anymore */
if (parse_cpu_set((const char **)args+2, &cpus, &errmsg)) {
ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg);
ha_cpuset_assign(&cpus_copy, &cpus);
- if (!thread) {
- /* no thread set was specified, apply
- * the CPU set to the whole group.
- */
+ /* a thread set is specified, apply the
+ * CPU set to these threads.
+ */
+ for (j = n = 0; j < MAX_THREADS_PER_GROUP; j++) {
+ /* No mapping for this thread */
+ if (!(thread & (1UL << j)))
+ continue;
+
if (!autoinc)
- ha_cpuset_assign(&cpu_map[g].proc, &cpus);
+ ha_cpuset_assign(&cpu_map[g].thread[j], &cpus);
else {
- ha_cpuset_zero(&cpu_map[g].proc);
+ ha_cpuset_zero(&cpu_map[g].thread[j]);
n = ha_cpuset_ffs(&cpus_copy) - 1;
ha_cpuset_clr(&cpus_copy, n);
- ha_cpuset_set(&cpu_map[g].proc, n);
- }
- } else {
- /* a thread set is specified, apply the
- * CPU set to these threads.
- */
- for (j = n = 0; j < MAX_THREADS_PER_GROUP; j++) {
- /* No mapping for this thread */
- if (!(thread & (1UL << j)))
- continue;
-
- if (!autoinc)
- ha_cpuset_assign(&cpu_map[g].thread[j], &cpus);
- else {
- ha_cpuset_zero(&cpu_map[g].thread[j]);
- n = ha_cpuset_ffs(&cpus_copy) - 1;
- ha_cpuset_clr(&cpus_copy, n);
- ha_cpuset_set(&cpu_map[g].thread[j], n);
- }
+ ha_cpuset_set(&cpu_map[g].thread[j], n);
}
}
}
int g, i;
for (g = 0; g < MAX_TGROUPS; g++) {
- ha_cpuset_zero(&cpu_map[g].proc);
ha_cpuset_zero(&cpu_map[g].proc_t1);
for (i = 0; i < MAX_THREADS_PER_GROUP; ++i) {
ha_cpuset_zero(&cpu_map[g].thread[i]);
in_parent = 1;
}
-#ifdef USE_CPU_AFFINITY
- if (!in_parent && ha_cpuset_count(&cpu_map[0].proc)) { /* only do this if the process has a CPU map */
+#if !defined(USE_THREAD) && defined(USE_CPU_AFFINITY)
+ if (!in_parent && ha_cpuset_count(&cpu_map[0].thread[0])) { /* only do this if the process has a CPU map */
#if defined(CPUSET_USE_CPUSET) || defined(__DragonFly__)
- struct hap_cpuset *set = &cpu_map[0].proc;
+ struct hap_cpuset *set = &cpu_map[0].thread[0];
sched_setaffinity(0, sizeof(set->cpuset), &set->cpuset);
#elif defined(__FreeBSD__)
- struct hap_cpuset *set = &cpu_map[0].proc;
+ struct hap_cpuset *set = &cpu_map[0].thread[0];
ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(set->cpuset), &set->cpuset);
#endif
}