3 * Copyright (C) Nginx, Inc.
7 #include <ngx_config.h>
11 #if (NGX_HAVE_CPUSET_SETAFFINITY)
13 #include <sys/cpuset.h>
16 ngx_setaffinity(uint64_t cpu_affinity
, ngx_log_t
*log
)
21 ngx_log_error(NGX_LOG_NOTICE
, log
, 0,
22 "cpuset_setaffinity(0x%08Xl)", cpu_affinity
);
27 if (cpu_affinity
& 1) {
32 } while (cpu_affinity
);
34 if (cpuset_setaffinity(CPU_LEVEL_WHICH
, CPU_WHICH_PID
, -1,
35 sizeof(cpuset_t
), &mask
) == -1)
37 ngx_log_error(NGX_LOG_ALERT
, log
, ngx_errno
,
38 "cpuset_setaffinity() failed");
42 #elif (NGX_HAVE_SCHED_SETAFFINITY)
45 ngx_setaffinity(uint64_t cpu_affinity
, ngx_log_t
*log
)
50 ngx_log_error(NGX_LOG_NOTICE
, log
, 0,
51 "sched_setaffinity(0x%08Xl)", cpu_affinity
);
56 if (cpu_affinity
& 1) {
61 } while (cpu_affinity
);
63 if (sched_setaffinity(0, sizeof(cpu_set_t
), &mask
) == -1) {
64 ngx_log_error(NGX_LOG_ALERT
, log
, ngx_errno
,
65 "sched_setaffinity() failed");