report a bug : worker_cpu_affinity

许立强 feifengxlq at gmail.com
Thu Jan 20 18:54:15 MSK 2011


Hi,All,
I'm running a 4-core processor server. linux , libc 2.3.4。
In nginx.conf, i have

 worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;

But i see in my error log the following :
 2011/01/20 14:29:57 [notice] 19362#0: sched_setaffinity(0x00000004)
2011/01/20 14:29:57 [alert] 19362#0: sched_setaffinity(0x00000004)
failed (22: Invalid argument)

By analyzing the source code of nginx(0.8.54), i found :
 *if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) {*
*            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,*
*
                          "sched_setaffinity(0x%08Xl) failed", cpu_affinity);
*
*        }*
and
*u_long         cpu_affinity;*

in my opinion, the reason is :
1、sizeof(cpu_set_t) > sizeof(u_long)
2、cpu_affinity is not initialized。

so ,i hack it
*cput_set_t *mask = (cpu_set_t *) (&cpu_affinity);*
*bzero(mask, sizeog(cpu_set_t));*

configure & make  & make install.

it works well!

is it a bug?

Cheers,
-feifengxlq
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20110120/d100527e/attachment.html>


More information about the nginx-devel mailing list