arm: Replace MAX_SMP probe loop
v4 cover arm: Replace MAX_SMP probe loop
v4:
Remove last mention of awk and fix spelling mistakes in commit message.
Colton Lewis (1):
arm: Replace MAX_SMP probe loop in favor of reading directly
scripts/runtime.bash | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
--
2.39.1.456.gfc5497dd1b-goog
PATCH v4 1/1 arm: Replace MAX_SMP probe loop in favor of reading directly
Replace the MAX_SMP probe loop in favor of reading a number directly from the QEMU error message. This is equally safe as the existing code because the error message has had the same format as long as it has existed, since QEMU v2.10. The final number before the end of the error message line indicates the max QEMU supports.
This loop logic is broken for machines with a number of CPUs that isn't a power of two. This problem was noticed for gicv2 tests on machines with a non-power-of-two number of CPUs greater than 8 because tests were running with MAX_SMP less than 8. As a hypothetical example, a machine with 12 CPUs will test with MAX_SMP=6 because 12 >> 1 ==
6. This can, in rare circumstances, lead to different test results depending only on the number of CPUs the machine has.
A previous comment explains the loop should only apply to kernels <=v4.3 on arm and suggests deletion when it becomes tiresome to maintain. However, it is always theoretically possible to test on a machine that has more CPUs than QEMU supports, so it makes sense to leave some check in place.
--- scripts/runtime.bash | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
scripts/runtime.bash +7 -9
@@ -188,12 +188,10 @@ function run() # Probe for MAX_SMP, in case it's less than the number of host cpus. # # This probing currently only works for ARM, as x86 bails on another -# error first. Also, this probing isn't necessary for any ARM hosts -# running kernels later than v4.3, i.e. those including ef748917b52 -# "arm/arm64: KVM: Remove 'config KVM_ARM_MAX_VCPUS'". So, at some -# point when maintaining the while loop gets too tiresome, we can -# just remove it... -while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ - |& grep -qi 'exceeds max CPUs'; do - MAX_SMP=$((MAX_SMP >> 1)) -done +# error first. The awk program takes the last number from the QEMU +# error message, which gives the allowable MAX_SMP. +if smp=$($RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ + |& grep 'exceeds max CPUs'); then + smp=${smp##*(} + MAX_SMP=${smp:0:-1} +fi
Signature · 1 line
2.39.1.456.gfc5497dd1b-goog
Re: [kvm-unit-tests PATCH v4 1/1] arm: Replace MAX_SMP probe loop in favor of reading directly
Quoted 33 lines · Colton Lewis
Replace the
MAX_SMPprobe loop in favor of reading a number directly from the QEMU error message. This is equally safe as the existing code because the error message has had the same format as long as it has existed, since QEMU v2.10. The final number before the end of the error message line indicates the max QEMU supports.This loop logic is broken for machines with a number of CPUs that isn't a power of two. This problem was noticed for gicv2 tests on machines with a non-power-of-two number of CPUs greater than 8 because tests were running with
MAX_SMPless than 8. As a hypothetical example, a machine with 12 CPUs will test with MAX_SMP=6 because 12 >> 1 ==
6. This can, in rare circumstances, lead to different test results depending only on the number of CPUs the machine has.A previous comment explains the loop should only apply to kernels <=v4.3 on arm and suggests deletion when it becomes tiresome to maintain. However, it is always theoretically possible to test on a machine that has more CPUs than QEMU supports, so it makes sense to leave some check in place.
Signed-off-by Colton Lewis <[email protected]>--- scripts/runtime.bash | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)scripts/runtime.bash +0
-0@@ -188,12 +188,10 @@ function run() # Probe for MAX_SMP, in case it's less than the number of host cpus. # # This probing currently only works for ARM, as x86 bails on another
scripts/runtime.bash function run() · line 191
Quoted 10 lines
scripts/runtime.bash +1
-9-# error first. Also, this probing isn't necessary for any ARM hosts -# running kernels later than v4.3, i.e. those including ef748917b52 -# "arm/arm64: KVM: Remove 'config KVM_ARM_MAX_VCPUS'". So, at some -# point when maintaining the while loop gets too tiresome, we can -# just remove it... -while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ - |& grep -qi 'exceeds max CPUs'; do - MAX_SMP=$((MAX_SMP >> 1)) -done +# error first. The awk program takes the last number from the QEMU
I point this awk reference out in the last review. I also stated we should do something else, which is not done in this version. Go read the last review comments again.
Quoted 9 lines
scripts/runtime.bash +6
-0+# error message, which gives the allowable MAX_SMP. +if smp=$($RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ + |& grep 'exceeds max CPUs'); then + smp=${smp##*(} + MAX_SMP=${smp:0:-1} +fiSignature · 1 line
2.39.1.456.gfc5497dd1b-goog
Re: [kvm-unit-tests PATCH v4 1/1] arm: Replace MAX_SMP probe loop in favor of reading directly
Quoted 5 lines · Andrew Jones
Quoted 1 line
+# error first. The awk program takes the last number from the QEMU
I point this awk reference out in the last review. I also stated we should do something else, which is not done in this version. Go read the last review comments again.
I apologize for not reading your last review more closely and checking my work. I read your word "comment" but thought you were only referring to the commit message since that's where you placed the text.
As for the something else, you mentioned wrapping the code in an $ARCH check but stated that should be another patch. I did not catch the followup where you suggested doing it now.
I will do that next version.
Quoted 6 lines · Colton Lewis
v4:
Remove last mention of awk and fix spelling mistakes in commit message.
Please provide each version's change summary with their links from latest to oldest.
Quoted 8 lines
Colton Lewis (1):
arm: ReplaceMAX_SMPprobe loop in favor of reading directlyscripts/runtime.bash | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)--
2.39.1.456.gfc5497dd1b-goog
For single patches you can omit the cover letter (unless there is a lot of information you want to provide and discuss) and just provide any non-commit information after the first three dashes '---' line in the patch.