aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Zimmer <nzimmer@sgi.com>2013-04-15 09:53:34 -0500
committerJens Axboe <axboe@kernel.dk>2013-08-01 12:13:26 -0600
commitfb69749415ae2bd7c3180605d01a5a39f3bd988f (patch)
treec73b96ce90568ef0a1ea59c977cf244275e5dee8
parent0c2df13d11dd91a1c3933dcc8faa98f2b59a5793 (diff)
downloadblktrace-fb69749415ae2bd7c3180605d01a5a39f3bd988f.tar.gz
btreplay: use sysconf to get the number of configured cpus
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>
-rw-r--r--btreplay/btreplay.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index 6f0ba63..fe6cd80 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -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*/