<div><font size="3" color="#000080" face="宋体">Hi,All<span id="_FoxToName"></span>,</font></div>
<div style="text-indent: 2em;"><font size="3" color="#000080" face="宋体">I&#39;m&nbsp;running a 
4-core&nbsp;processor&nbsp;server. linux , libc 2.3.4。</font></div>
<div style="text-indent: 2em;"><font size="3" color="#000080" face="宋体">In nginx.conf, 
i have</font></div>
<div style="text-indent: 2em;">&nbsp;</div>
<div style="text-indent: 2em;"><font size="3" color="#000080">
<div><font face="宋体">worker_processes&nbsp;4;</font></div>
<div><font face="宋体">worker_cpu_affinity&nbsp;0001&nbsp;0010&nbsp;0100&nbsp;1000;</font></div>
<div>&nbsp;</div>
<div><font face="宋体">But i see in my error log the following :</font></div>
<div>
<div><font face="宋体">2011/01/20&nbsp;14:29:57&nbsp;[notice]&nbsp;19362#0:&nbsp;sched_setaffinity(0x00000004)</font></div>
<div><font face="宋体">2011/01/20&nbsp;14:29:57&nbsp;[alert]&nbsp;19362#0:&nbsp;sched_setaffinity(0x00000004)&nbsp;failed&nbsp;(22:&nbsp;Invalid&nbsp;argument)</font></div>
<div>&nbsp;</div>
<div><font face="宋体">By&nbsp;analyzing&nbsp;the&nbsp;source&nbsp;code of nginx(0.8.54), i found : 
</font></div>
<div>
<div style="text-indent: 4em;"><em><font face="宋体">if&nbsp;(sched_setaffinity(0,&nbsp;32,&nbsp;(cpu_set_t&nbsp;*)&nbsp;&amp;cpu_affinity)&nbsp;==&nbsp;-1)&nbsp;{</font></em></div>
<div><em><font face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ngx_log_error(NGX_LOG_ALERT,&nbsp;cycle-&gt;log,&nbsp;ngx_errno,</font></em></div>
<div><em><font face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;sched_setaffinity(0x%08Xl)&nbsp;failed&quot;,&nbsp;cpu_affinity);</font></em></div>
<div><em><font face="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</font></em></div>
<div><font face="宋体">and </font></div>
<div style="text-indent: 4em;"><em><font face="宋体">u_long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
cpu_affinity;</font></em></div>
<div style="text-indent: 2em;">&nbsp;</div>
<div style="text-indent: 2em;"><font face="宋体">in my opinion, the reason is : 
</font></div>
<div style="text-indent: 4em;"><font face="宋体">1、sizeof(cpu_set_t) &gt; 
sizeof(u_long)</font></div>
<div style="text-indent: 4em;"><font face="宋体">2、cpu_affinity is not 
initialized。</font></div>
<div style="text-indent: 2em;">&nbsp;</div>
<div><font face="宋体">so ,i hack it</font></div>
<div style="text-indent: 4em;"><em><font face="宋体">cput_set_t *mask = 
(cpu_set_t&nbsp;*)&nbsp;(&amp;cpu_affinity);</font></em></div>
<div style="text-indent: 4em;"><em><font face="宋体">bzero(mask, 
sizeog(cpu_set_t));</font></em></div>
<div style="text-indent: 2em;">&nbsp;</div>
<div style="text-indent: 2em;"><font face="宋体">configure &amp; make&nbsp; &amp; make 
install.</font></div>
<div style="text-indent: 2em;">&nbsp;</div>
<div style="text-indent: 2em;"><font face="宋体">it works well!</font></div>
<div style="text-indent: 2em;">&nbsp;</div>
<div style="text-indent: 2em;"><font face="宋体">is it a 
bug?<br><br>Cheers,<br>-feifengxlq <br></font></div></div></div></font></div>