mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: init: Fix CPU affinity setting on FreeBSD.
Use a cpuset_t instead of assuming the cpu mask is an unsigned long. This should fix setting the CPU affinity on FreeBSD >= 11. This patch should be backported to stable releases.
This commit is contained in:
parent
0d00593361
commit
97148f60b8
@ -2558,7 +2558,18 @@ int main(int argc, char **argv)
|
||||
proc < LONGBITS && /* only the first 32/64 processes may be pinned */
|
||||
global.cpu_map[proc]) /* only do this if the process has a CPU map */
|
||||
#ifdef __FreeBSD__
|
||||
cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(unsigned long), (void *)&global.cpu_map[proc]);
|
||||
{
|
||||
cpuset_t cpuset;
|
||||
int i;
|
||||
unsigned long cpu_map = global.cpu_map[proc];
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
while ((i = ffsl(cpu_map)) > 0) {
|
||||
CPU_SET(i - 1, &cpuset);
|
||||
cpu_map &= ~(1 << (i - 1));
|
||||
}
|
||||
ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset), &cpuset);
|
||||
}
|
||||
#else
|
||||
sched_setaffinity(0, sizeof(unsigned long), (void *)&global.cpu_map[proc]);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user