btreplay: use sysconf to get the number of configured cpus
authorNathan Zimmer <nzimmer@sgi.com>
Mon, 15 Apr 2013 14:53:34 +0000 (09:53 -0500)
committerJens Axboe <axboe@kernel.dk>
Thu, 1 Aug 2013 18:13:26 +0000 (12:13 -0600)
We should use the standard methods for getting the number of cpus in the
system when they are available.  It is good practice to leave the old ways in
place for people stuck on older systems.

Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
btreplay/btreplay.c

index 6f0ba634024d9f75b54bde8b54e44234a1174a63..fe6cd80050c76368717bf196cc8f46ea5b9182e5 100644 (file)
@@ -502,6 +502,9 @@ static inline void start_iter(void)
  */
 static void get_ncpus(void)
 {
+#ifdef _SC_NPROCESSORS_CONF
+       ncpus = sysconf(_SC_NPROCESSORS_CONF);
+#else
        long last_cpu;
        cpu_set_t cpus;
 
@@ -515,6 +518,7 @@ static void get_ncpus(void)
                if (CPU_ISSET( last_cpu, &cpus) ) 
                        ncpus = last_cpu;
        ncpus++;
+#endif
        if (ncpus == 0) {
                fatal(NULL, ERR_SYSCALL, "Insufficient number of CPUs\n");
                /*NOTREACHED*/