Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r4913 - trunk/src/os/unix

Anonymous User
November 16, 2012 04:26AM
Author: ru
Date: 2012-11-16 09:25:52 +0000 (Fri, 16 Nov 2012)
New Revision: 4913
URL: http://trac.nginx.org/nginx/changeset/4913/nginx

Log:
Fixed setting of CPU affinity on respawn of dead worker processes.

Worker processes are now made aware of their sequential number needed
to select CPU affinity mask. This replaces a workaround from r4865.


Modified:
trunk/src/os/unix/ngx_process_cycle.c

Modified: trunk/src/os/unix/ngx_process_cycle.c
===================================================================
--- trunk/src/os/unix/ngx_process_cycle.c 2012-11-16 07:49:41 UTC (rev 4912)
+++ trunk/src/os/unix/ngx_process_cycle.c 2012-11-16 09:25:52 UTC (rev 4913)
@@ -20,7 +20,7 @@
static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
static void ngx_master_process_exit(ngx_cycle_t *cycle);
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
-static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
+static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker);
static void ngx_worker_process_exit(ngx_cycle_t *cycle);
static void ngx_channel_handler(ngx_event_t *ev);
#if (NGX_THREADS)
@@ -62,7 +62,6 @@
#endif


-uint64_t cpu_affinity;
static u_char master_process[] = "master process";


@@ -360,19 +359,15 @@

for (i = 0; i < n; i++) {

- cpu_affinity = ngx_get_cpu_affinity(i);
+ ngx_spawn_process(cycle, ngx_worker_process_cycle,
+ (void *) (intptr_t) i, "worker process", type);

- ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
- "worker process", type);
-
ch.pid = ngx_processes[ngx_process_slot].pid;
ch.slot = ngx_process_slot;
ch.fd = ngx_processes[ngx_process_slot].channel[0];

ngx_pass_open_channel(cycle, &ch);
}
-
- cpu_affinity = 0;
}


@@ -726,12 +721,14 @@
static void
ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
+ ngx_int_t worker = (intptr_t) data;
+
ngx_uint_t i;
ngx_connection_t *c;

ngx_process = NGX_PROCESS_WORKER;

- ngx_worker_process_init(cycle, 1);
+ ngx_worker_process_init(cycle, worker);

ngx_setproctitle("worker process");

@@ -837,9 +834,10 @@


static void
-ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
+ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker)
{
sigset_t set;
+ uint64_t cpu_affinity;
ngx_int_t n;
ngx_uint_t i;
struct rlimit rlmt;
@@ -853,7 +851,7 @@

ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);

- if (priority && ccf->priority != 0) {
+ if (worker >= 0 && ccf->priority != 0) {
if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"setpriority(%d) failed", ccf->priority);
@@ -917,8 +915,12 @@
}
}

- if (cpu_affinity) {
- ngx_setaffinity(cpu_affinity, cycle->log);
+ if (worker >= 0) {
+ cpu_affinity = ngx_get_cpu_affinity(worker);
+
+ if (cpu_affinity) {
+ ngx_setaffinity(cpu_affinity, cycle->log);
+ }
}

#if (NGX_HAVE_PR_SET_DUMPABLE)
@@ -1298,7 +1300,7 @@

ngx_process = NGX_PROCESS_HELPER;

- ngx_worker_process_init(cycle, 0);
+ ngx_worker_process_init(cycle, -1);

ngx_close_listening_sockets(cycle);


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r4913 - trunk/src/os/unix

Anonymous User 880 November 16, 2012 04:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 257
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready