Currently, blktrace uses _SC_NPROCESSORS_CONF to find out the number of
CPUs. This is a problem, because if you reduce the number of online
CPUs by passing kernel parameter maxcpus, then blktrace fails to start
with the error:
FAILED to start thread on CPU 4: 22/Invalid argument
FAILED to start thread on CPU 5: 22/Invalid argument
...
The attached patch fixes it to use _SC_NPROCESSORS_ONLN.
Signed-off-by: Jens Axboe <axboe@fb.com>
setlocale(LC_NUMERIC, "en_US");
pagesize = getpagesize();
- ncpus = sysconf(_SC_NPROCESSORS_CONF);
+ ncpus = sysconf(_SC_NPROCESSORS_ONLN);
if (ncpus < 0) {
- fprintf(stderr, "sysconf(_SC_NPROCESSORS_CONF) failed %d/%s\n",
+ fprintf(stderr, "sysconf(_SC_NPROCESSORS_ONLN) failed %d/%s\n",
errno, strerror(errno));
ret = 1;
goto out;
*/
static void get_ncpus(void)
{
-#ifdef _SC_NPROCESSORS_CONF
- ncpus = sysconf(_SC_NPROCESSORS_CONF);
+#ifdef _SC_NPROCESSORS_ONLN
+ ncpus = sysconf(_SC_NPROCESSORS_ONLN);
#else
int nrcpus = 4096;
cpu_set_t * cpus;
unsigned int seq;
FILE *f;
-#ifdef _SC_NPROCESSORS_CONF
- MAX_CPUS = sysconf(_SC_NPROCESSORS_CONF);
+#ifdef _SC_NPROCESSORS_ONLN
+ MAX_CPUS = sysconf(_SC_NPROCESSORS_ONLN);
if (MAX_CPUS < 1)
{
fprintf(stderr, "Could not determine number of CPUs online:\n%s\n",