a problem in CPU affinity

Maxim Dounin mdounin at mdounin.ru
Tue Sep 18 08:07:09 UTC 2012


Hello!

On Mon, Sep 17, 2012 at 03:11:33PM +0800, chen cw wrote:

> Hi,
> 
> When a worker is down, the master will spawn a new one. However, in case
> that we enable CPU affinity, the newly created workers will be bound to the
> same CPU, as the CPU which was bound to by the latest worker spawn at the
> startup or during the reload. This problem still exists in the latest
> version 1.3.6.

Yes, thank you for report.  Quick and dirty fix would be:

--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -371,6 +371,8 @@ ngx_start_worker_processes(ngx_cycle_t *
 
         ngx_pass_open_channel(cycle, &ch);
     }
+
+    cpu_affinity = 0;
 }
 
 
With this patch workers respawn after crashes won't have cpu 
affinity set, which is probably better.  It's still not ideal, but 
after all real problem is a worker crash, respawn is just an 
emergency mechanism.

Maxim Dounin



More information about the nginx-devel mailing list