summaryrefslogtreecommitdiff
path: root/btreplay
diff options
context:
space:
mode:
authorNathan Zimmer <nzimmer@sgi.com>2013-04-15 09:53:33 -0500
committerJens Axboe <axboe@kernel.dk>2013-08-01 12:13:26 -0600
commit0c2df13d11dd91a1c3933dcc8faa98f2b59a5793 (patch)
tree5a2255bad75d818dd831d90f8bc6b2146b3e8299 /btreplay
parent28fa9f69a23f70e4371fb483beb2d4881dbd074d (diff)
downloadblktrace-0c2df13d11dd91a1c3933dcc8faa98f2b59a5793.tar.gz
blktrace-0c2df13d11dd91a1c3933dcc8faa98f2b59a5793.tar.bz2
btreplay: Machines are now large enough that holes need to be dealt with
The current method fails if once we hit the first offlined cpu. This will correct that case. However this still underreports the number cpus if the last cpu are offlined. Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Nathan Zimmer <nzimmer@sgi.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'btreplay')
-rw-r--r--btreplay/btreplay.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index 20494e0..6f0ba63 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -502,6 +502,7 @@ static inline void start_iter(void)
*/
static void get_ncpus(void)
{
+ long last_cpu;
cpu_set_t cpus;
if (sched_getaffinity(getpid(), sizeof(cpus), &cpus)) {
@@ -509,12 +510,11 @@ static void get_ncpus(void)
/*NOTREACHED*/
}
- /*
- * XXX This assumes (perhaps wrongly) that there are no /holes/
- * XXX in the mask.
- */
- for (ncpus = 0; ncpus < CPU_SETSIZE && CPU_ISSET(ncpus, &cpus); ncpus++)
- ;
+ ncpus = -1;
+ for (last_cpu = 0; last_cpu < CPU_SETSIZE && CPU_ISSET(last_cpu, &cpus); last_cpu++)
+ if (CPU_ISSET( last_cpu, &cpus) )
+ ncpus = last_cpu;
+ ncpus++;
if (ncpus == 0) {
fatal(NULL, ERR_SYSCALL, "Insufficient number of CPUs\n");
/*NOTREACHED*/