diff options
author | Vladimir Homutov <vl@nginx.com> | 2016-02-18 13:58:49 +0300 |
---|---|---|
committer | Vladimir Homutov <vl@nginx.com> | 2016-02-18 13:58:49 +0300 |
commit | faa96e82d273bec6cb8bdf37f78e038aecf7621a (patch) | |
tree | 205d92f8de5efb70b378703307f7a98d3c304e5e /src/os/unix/ngx_setaffinity.c | |
parent | b5d7d3f024f587682e320d891e52e693939a5f14 (diff) | |
download | nginx-faa96e82d273bec6cb8bdf37f78e038aecf7621a.tar.gz nginx-faa96e82d273bec6cb8bdf37f78e038aecf7621a.zip |
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Diffstat (limited to 'src/os/unix/ngx_setaffinity.c')
-rw-r--r-- | src/os/unix/ngx_setaffinity.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/os/unix/ngx_setaffinity.c b/src/os/unix/ngx_setaffinity.c index 8f6cf3594..34ec390b7 100644 --- a/src/os/unix/ngx_setaffinity.c +++ b/src/os/unix/ngx_setaffinity.c @@ -10,29 +10,20 @@ #if (NGX_HAVE_CPUSET_SETAFFINITY) -#include <sys/cpuset.h> - void -ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log) +ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log) { - cpuset_t mask; ngx_uint_t i; - ngx_log_error(NGX_LOG_NOTICE, log, 0, - "cpuset_setaffinity(0x%08Xl)", cpu_affinity); - - CPU_ZERO(&mask); - i = 0; - do { - if (cpu_affinity & 1) { - CPU_SET(i, &mask); + for (i = 0; i < CPU_SETSIZE; i++) { + if (CPU_ISSET(i, cpu_affinity)) { + ngx_log_error(NGX_LOG_NOTICE, log, 0, + "cpuset_setaffinity(): using cpu #%ui", i); } - i++; - cpu_affinity >>= 1; - } while (cpu_affinity); + } if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, - sizeof(cpuset_t), &mask) == -1) + sizeof(cpuset_t), cpu_affinity) == -1) { ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "cpuset_setaffinity() failed"); @@ -42,25 +33,18 @@ ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log) #elif (NGX_HAVE_SCHED_SETAFFINITY) void -ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log) +ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log) { - cpu_set_t mask; ngx_uint_t i; - ngx_log_error(NGX_LOG_NOTICE, log, 0, - "sched_setaffinity(0x%08Xl)", cpu_affinity); - - CPU_ZERO(&mask); - i = 0; - do { - if (cpu_affinity & 1) { - CPU_SET(i, &mask); + for (i = 0; i < CPU_SETSIZE; i++) { + if (CPU_ISSET(i, cpu_affinity)) { + ngx_log_error(NGX_LOG_NOTICE, log, 0, + "sched_setaffinity(): using cpu #%ui", i); } - i++; - cpu_affinity >>= 1; - } while (cpu_affinity); + } - if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) == -1) { + if (sched_setaffinity(0, sizeof(cpu_set_t), cpu_affinity) == -1) { ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "sched_setaffinity() failed"); } |