mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 23:01:03 +01:00
MEDIUM: cpu-set: make the proc a single bit field and not an array
We only have a single process now so we don't need to store the per-proc CPU binding anymore.
This commit is contained in:
parent
bda7c1decd
commit
44ea631b77
@ -40,8 +40,8 @@ struct hap_cpuset {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cpu_map {
|
struct cpu_map {
|
||||||
struct hap_cpuset proc[MAX_PROCS]; /* list of CPU masks for the 32/64 first processes */
|
struct hap_cpuset proc; /* list of CPU masks for the whole process */
|
||||||
struct hap_cpuset proc_t1[MAX_PROCS]; /* list of CPU masks for the 1st thread of each process */
|
struct hap_cpuset proc_t1 ; /* list of CPU masks for the 1st thread of the process */
|
||||||
struct hap_cpuset thread[MAX_THREADS]; /* list of CPU masks for the 32/64 first threads of the 1st process */
|
struct hap_cpuset thread[MAX_THREADS]; /* list of CPU masks for the 32/64 first threads of the 1st process */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1091,12 +1091,12 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
|||||||
ha_cpuset_assign(&cpus_copy, &cpus);
|
ha_cpuset_assign(&cpus_copy, &cpus);
|
||||||
|
|
||||||
if (!autoinc)
|
if (!autoinc)
|
||||||
ha_cpuset_assign(&cpu_map.proc[0], &cpus);
|
ha_cpuset_assign(&cpu_map.proc, &cpus);
|
||||||
else {
|
else {
|
||||||
ha_cpuset_zero(&cpu_map.proc[0]);
|
ha_cpuset_zero(&cpu_map.proc);
|
||||||
n = ha_cpuset_ffs(&cpus_copy) - 1;
|
n = ha_cpuset_ffs(&cpus_copy) - 1;
|
||||||
ha_cpuset_clr(&cpus_copy, n);
|
ha_cpuset_clr(&cpus_copy, n);
|
||||||
ha_cpuset_set(&cpu_map.proc[0], n);
|
ha_cpuset_set(&cpu_map.proc, n);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* first process, iterate on threads. E.g. cpu-map 1/1-4 0-3 */
|
/* first process, iterate on threads. E.g. cpu-map 1/1-4 0-3 */
|
||||||
|
|||||||
@ -1778,10 +1778,8 @@ static void init(int argc, char **argv)
|
|||||||
#ifdef USE_CPU_AFFINITY
|
#ifdef USE_CPU_AFFINITY
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < MAX_PROCS; ++i) {
|
ha_cpuset_zero(&cpu_map.proc);
|
||||||
ha_cpuset_zero(&cpu_map.proc[i]);
|
ha_cpuset_zero(&cpu_map.proc_t1);
|
||||||
ha_cpuset_zero(&cpu_map.proc_t1[i]);
|
|
||||||
}
|
|
||||||
for (i = 0; i < MAX_THREADS; ++i) {
|
for (i = 0; i < MAX_THREADS; ++i) {
|
||||||
ha_cpuset_zero(&cpu_map.thread[i]);
|
ha_cpuset_zero(&cpu_map.thread[i]);
|
||||||
}
|
}
|
||||||
@ -3193,13 +3191,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_CPU_AFFINITY
|
#ifdef USE_CPU_AFFINITY
|
||||||
if (!in_parent && ha_cpuset_count(&cpu_map.proc[0])) { /* only do this if the process has a CPU map */
|
if (!in_parent && ha_cpuset_count(&cpu_map.proc)) { /* only do this if the process has a CPU map */
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
struct hap_cpuset *set = &cpu_map.proc[0];
|
struct hap_cpuset *set = &cpu_map.proc;
|
||||||
ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(set->cpuset), &set->cpuset);
|
ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(set->cpuset), &set->cpuset);
|
||||||
#elif defined(__linux__) || defined(__DragonFly__)
|
#elif defined(__linux__) || defined(__DragonFly__)
|
||||||
struct hap_cpuset *set = &cpu_map.proc[0];
|
struct hap_cpuset *set = &cpu_map.proc;
|
||||||
sched_setaffinity(0, sizeof(set->cpuset), &set->cpuset);
|
sched_setaffinity(0, sizeof(set->cpuset), &set->cpuset);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -3397,8 +3395,8 @@ int main(int argc, char **argv)
|
|||||||
/* Now the CPU affinity for all threads */
|
/* Now the CPU affinity for all threads */
|
||||||
|
|
||||||
for (i = 0; i < global.nbthread; i++) {
|
for (i = 0; i < global.nbthread; i++) {
|
||||||
if (ha_cpuset_count(&cpu_map.proc[relative_pid-1]))
|
if (ha_cpuset_count(&cpu_map.proc))
|
||||||
ha_cpuset_and(&cpu_map.thread[i], &cpu_map.proc[relative_pid-1]);
|
ha_cpuset_and(&cpu_map.thread[i], &cpu_map.proc);
|
||||||
|
|
||||||
if (i < MAX_THREADS && /* only the first 32/64 threads may be pinned */
|
if (i < MAX_THREADS && /* only the first 32/64 threads may be pinned */
|
||||||
ha_cpuset_count(&cpu_map.thread[i])) {/* only do this if the thread has a THREAD map */
|
ha_cpuset_count(&cpu_map.thread[i])) {/* only do this if the thread has a THREAD map */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user