Skip to contentSkip to conversation

btreplay: Fix typo in scaling up the dynamic cpu set size.

PATCH Applied Jeff Mahoney 2 participants 2 messages Aug 20, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btreplay: Fix typo in scaling up the dynamic cpu set size.

From: Josef Cejka <[email protected]>

In get_ncpus, we default to using 4096 CPUs if _SC_NPROCESSORS_CONF isn't enabled. If that is insufficient, sched_getaffinity will fail and we retry after doubling the size of the cpu_set_t allocation. There's a typo in there that means we don't actually double the size and will loop forever allocating the same sized cpu_set_t instead.

---

 btreplay/btreplay.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
btreplay/btreplay.c +1 -1
@@ -516,7 +516,7 @@ realloc:
 	if (sched_getaffinity(getpid(), size, cpus)) {
 		if( errno = EINVAL && nrcpus < (4096<<4) ) {
 			CPU_FREE(cpus);
-			nrcpus <= 1;
+			nrcpus <<= 1;
 			goto realloc;
 		}
 		fatal("sched_getaffinity", ERR_SYSCALL, "Can't get CPU info\n");
Signature · 2 lines
Jeff Mahoney
SUSE Labs
Applied
#1 lore raw
Quoted 18 lines · Jeff Mahoney

From: Josef Cejka <[email protected]>

In get_ncpus, we default to using 4096 CPUs if _SC_NPROCESSORS_CONF isn't enabled. If that is insufficient, sched_getaffinity will fail and we retry after doubling the size of the cpu_set_t allocation. There's a typo in there that means we don't actually double the size and will loop forever allocating the same sized cpu_set_t instead.

---

  btreplay/btreplay.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

btreplay/btreplay.c realloc: · line 519

Quoted 5 lines
btreplay/btreplay.c +1 -1
@@ -516,7 +516,7 @@ realloc:
  	if (sched_getaffinity(getpid(), size, cpus)) {
  		if( errno = EINVAL && nrcpus < (4096<<4) ) {
  			CPU_FREE(cpus);
-			nrcpus <= 1;
+			nrcpus <<= 1;

Hah, well that sucks. Looks like commit 0a915aabe88ff added that problem, and wasn't caught in review.

Thanks, applied.

Signature · 1 line
Jens Axboe