[PATCH 2/5] btreplay: Machines are now large enough that holes need to be dealt with

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Signed-off-by: Nathan Zimmer <nzimmer@xxxxxxx>
---
 btreplay/btreplay.c | 12 ++++++------
 1 file 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*/
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrace" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux