mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-07 15:51:23 -05:00
BUG/MEDIUM: cpu-map: fix thread 1's affinity affecting all threads
Since 2.7-dev2 with commit5b09341c02("MEDIUM: cpu-map: replace the process number with the thread group number"), the thread group has replaced the process number in the "cpu-map" directive. In part due to a design limit in 2.4 and 2.5, a special case was made of thread 1 in commitbda7c1decd("MEDIUM: config: simplify cpu-map handling"), because there was no other location to store a single-threaded setup's mask by then. The combination of the two resulted in a problem with thread groups, by which as soon as one line exhibiting thread number 1 alone was found in a config, the mask would be applied to all threads in the group. The loop was reworked to avoid this obsolete special case, and was factored for better legibility. One obsolete comment about nbproc was also removed. No backport is needed.
This commit is contained in:
parent
ea4a5cbbdf
commit
3cd71acd06
1 changed files with 15 additions and 22 deletions
|
|
@ -1094,21 +1094,19 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||
* cpu-map P-Q => mapping for whole tgroups, numbers P to Q
|
||||
* cpu-map P-Q/1 => mapping of first thread of groups P to Q
|
||||
* cpu-map P/T-U => mapping of threads T to U of tgroup P
|
||||
* Otherwise other combinations are silently ignored since nbthread
|
||||
* and nbproc cannot both be >1 :
|
||||
* cpu-map P-Q/T => mapping for thread T for processes P to Q.
|
||||
* Only one of T,Q may be > 1, others ignored.
|
||||
* cpu-map P/T-U => mapping for threads T to U of process P. Only
|
||||
* one of P,U may be > 1, others ignored.
|
||||
*/
|
||||
if (!thread || thread == 0x1) {
|
||||
/* mapping for whole tgroups. E.g. cpu-map 1 0-3 or cpu-map 1/1 0-3 */
|
||||
for (g = 0; g < MAX_TGROUPS; g++) {
|
||||
/* No mapping for this tgroup */
|
||||
if (!(tgroup & (1UL << g)))
|
||||
continue;
|
||||
/* first tgroup, iterate on threads. E.g. cpu-map 1/1-4 0-3 */
|
||||
for (g = 0; g < MAX_TGROUPS; g++) {
|
||||
/* No mapping for this tgroup */
|
||||
if (!(tgroup & (1UL << g)))
|
||||
continue;
|
||||
|
||||
ha_cpuset_assign(&cpus_copy, &cpus);
|
||||
ha_cpuset_assign(&cpus_copy, &cpus);
|
||||
|
||||
if (!thread) {
|
||||
/* no thread set was specified, apply
|
||||
* the CPU set to the whole group.
|
||||
*/
|
||||
if (!autoinc)
|
||||
ha_cpuset_assign(&cpu_map[g].proc, &cpus);
|
||||
else {
|
||||
|
|
@ -1117,15 +1115,10 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||
ha_cpuset_clr(&cpus_copy, n);
|
||||
ha_cpuset_set(&cpu_map[g].proc, n);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* first tgroup, iterate on threads. E.g. cpu-map 1/1-4 0-3 */
|
||||
for (g = 0; g < MAX_TGROUPS; g++) {
|
||||
/* No mapping for this tgroup */
|
||||
if (!(tgroup & (1UL << g)))
|
||||
continue;
|
||||
|
||||
ha_cpuset_assign(&cpus_copy, &cpus);
|
||||
} 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)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue