From: Pierre-Marc Fournier Date: Tue, 2 Feb 2010 02:43:03 +0000 (-0500) Subject: _SC_NPROCESSORS_ONLN -> _SC_NPROCESSORS_CONF X-Git-Tag: v1.9.1~759 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a0243ab12a9cdab191c624ef23e035d97f08d60e;p=lttng-ust.git _SC_NPROCESSORS_ONLN -> _SC_NPROCESSORS_CONF --- diff --git a/libust/buffers.c b/libust/buffers.c index 13660a89..7d2dd473 100644 --- a/libust/buffers.c +++ b/libust/buffers.c @@ -45,7 +45,15 @@ static int get_n_cpus(void) return n_cpus; } - result = sysconf(_SC_NPROCESSORS_ONLN); + /* On Linux, when some processors are offline + * _SC_NPROCESSORS_CONF counts the offline + * processors, whereas _SC_NPROCESSORS_ONLN + * does not. If we used _SC_NPROCESSORS_ONLN, + * getcpu() could return a value greater than + * this sysconf, in which case the arrays + * indexed by processor would overflow. + */ + result = sysconf(_SC_NPROCESSORS_CONF); if(result == -1) { return -1; }