Skip to contentSkip to conversation

scripts: Speedup MAX_SMP check

PATCH In review Christoffer Dall 3 participants 5 messages Sep 3, 2018 – Jan 30, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts: Speedup MAX_SMP check

The current MAX_SMP check launches QEMU for every value of the SMP parameter to check if the SMP parameter based on the native is higher than the QEMU maximum supported configuration.

On something like a TX2, which has 224 threads, this takes a very long time where the test script just sits there with no output.

Reduce the wait time by taking the log2 of MAX_SMP in each iteration of the loop instead.

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +1 -1
index a31ae91..1e2c288 100644
@@ -140,5 +140,5 @@ function run()
 # just remove it...
 while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
 		|& grep -qi 'exceeds max CPUs'; do
-	((--MAX_SMP))
+	MAX_SMP=$((MAX_SMP >> 1))
 done
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Christoffer Dall

The current MAX_SMP check launches QEMU for every value of the SMP parameter to check if the SMP parameter based on the native is higher than the QEMU maximum supported configuration.

On something like a TX2, which has 224 threads, this takes a very long time where the test script just sits there with no output.

Reduce the wait time by taking the log2 of MAX_SMP in each iteration of the loop instead.

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +1 -1
index a31ae91..1e2c288 100644
@@ -140,5 +140,5 @@ function run()
 # just remove it...
 while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
 		|& grep -qi 'exceeds max CPUs'; do
-	((--MAX_SMP))
+	MAX_SMP=$((MAX_SMP >> 1))
 done
Signature · 1 line
2.7.4

Someday I should move this into arch-specific code and replace it with something like:

if gic-v3
MAX_SMP = MIN(_SC_NPROCESSORS_ONLN, 255)
else
MAX_SMP = MIN(_SC_NPROCESSORS_ONLN, 8)

If other archs ever care about it (they currently don't), then they can implement their own thing.

Thanks,
drew

#2 lore raw
Quoted 34 lines · Andrew Jones
Quoted 29 lines · Christoffer Dall

The current MAX_SMP check launches QEMU for every value of the SMP parameter to check if the SMP parameter based on the native is higher than the QEMU maximum supported configuration.

On something like a TX2, which has 224 threads, this takes a very long time where the test script just sits there with no output.

Reduce the wait time by taking the log2 of MAX_SMP in each iteration of the loop instead.

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runtime.bash +1 -1
index a31ae91..1e2c288 100644
@@ -140,5 +140,5 @@ function run()
 # just remove it...
 while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
 		|& grep -qi 'exceeds max CPUs'; do
-	((--MAX_SMP))
+	MAX_SMP=$((MAX_SMP >> 1))
 done
Signature · 1 line
2.7.4
Quoted 5 lines

Someday I should move this into arch-specific code and replace it with something like:

if gic-v3
MAX_SMP = MIN(_SC_NPROCESSORS_ONLN, 255)

Not quite, becasue QEMU can't seem to support more than 123 CPUs with it current default set of parameters used by kvmtool at least. But perhaps that's being fixed with some changes to QEMU/KVM (I lost track).

Thanks for the reviews.

Christoffer

Quoted 6 lines

else
MAX_SMP = MIN(_SC_NPROCESSORS_ONLN, 8)

If other archs ever care about it (they currently don't), then they can implement their own thing.

#3 lore raw
In reply to Andrew Jones
Quoted 16 lines · Andrew Jones
Quoted 15 lines · Christoffer Dall

The current MAX_SMP check launches QEMU for every value of the SMP parameter to check if the SMP parameter based on the native is higher than the QEMU maximum supported configuration.

On something like a TX2, which has 224 threads, this takes a very long time where the test script just sits there with no output.

Reduce the wait time by taking the log2 of MAX_SMP in each iteration of the loop instead.

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 18 lines
Quoted 14 lines
scripts/runtime.bash +1 -1
index a31ae91..1e2c288 100644
@@ -140,5 +140,5 @@ function run()
 # just remove it...
 while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
 		|& grep -qi 'exceeds max CPUs'; do
-	((--MAX_SMP))
+	MAX_SMP=$((MAX_SMP >> 1))
 done
Signature · 1 line
2.7.4

Paolo, if you're ok with this patch, could you apply it?

(I failed to CC you the first time around, only had the kvm list.)

Thanks,

Christoffer

maintainer
#4 lore raw
Quoted 36 lines · Christoffer Dall
Quoted 16 lines · Andrew Jones
Quoted 15 lines · Christoffer Dall

The current MAX_SMP check launches QEMU for every value of the SMP parameter to check if the SMP parameter based on the native is higher than the QEMU maximum supported configuration.

On something like a TX2, which has 224 threads, this takes a very long time where the test script just sits there with no output.

Reduce the wait time by taking the log2 of MAX_SMP in each iteration of the loop instead.

---
 scripts/runtime.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 18 lines
Quoted 14 lines
scripts/runtime.bash +1 -1
index a31ae91..1e2c288 100644
@@ -140,5 +140,5 @@ function run()
 # just remove it...
 while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
 		|& grep -qi 'exceeds max CPUs'; do
-	((--MAX_SMP))
+	MAX_SMP=$((MAX_SMP >> 1))
 done
Signature · 1 line
2.7.4
Quoted 8 lines

Paolo, if you're ok with this patch, could you apply it?

(I failed to CC you the first time around, only had the kvm list.)

Thanks,

Christoffer

Queued now.

Paolo