All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v5] arm: Replace MAX_SMP probe loop in favor of reading directly
@ 2023-02-07 23:32 Colton Lewis
  2023-02-14 18:43 ` Andrew Jones
  2023-02-14 20:18 ` Andrew Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Colton Lewis @ 2023-02-07 23:32 UTC (permalink / raw)
  To: thuth, pbonzini, nrb, andrew.jones, imbrenda, marcorr,
	alexandru.elisei, oliver.upton
  Cc: kvm, kvmarm, Colton Lewis

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.

Signed-off-by: Colton Lewis <coltonlewis@google.com>
---
 scripts/runtime.bash | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

v5: Remove the last awk reference and guard the probing code with a
check that ARCH = arm or arm64.

v4: https://lore.kernel.org/kvm/20230201172110.1970980-1-coltonlewis@google.com/

v3: https://lore.kernel.org/kvm/20230130195700.729498-1-coltonlewis@google.com/

v2: https://lore.kernel.org/kvm/20230111215422.2153645-1-coltonlewis@google.com/

v1: https://lore.kernel.org/kvm/20221219185250.631503-1-coltonlewis@google.com/

diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index f8794e9a..fb64e855 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -188,12 +188,11 @@ 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, so this check is only run for ARM and ARM64. The
+# parameter expansion takes the last number from the QEMU error
+# message, which gives the allowable MAX_SMP.
+if [ "${ARCH%64}" = arm ] && smp=$($RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
+      |& grep 'exceeds max CPUs'); then
+	smp=${smp##*(}
+	MAX_SMP=${smp:0:-1}
+fi
--
2.39.1.519.gcb327c4b5f-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH v5] arm: Replace MAX_SMP probe loop in favor of reading directly
  2023-02-07 23:32 [kvm-unit-tests PATCH v5] arm: Replace MAX_SMP probe loop in favor of reading directly Colton Lewis
@ 2023-02-14 18:43 ` Andrew Jones
  2023-02-14 20:18 ` Andrew Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2023-02-14 18:43 UTC (permalink / raw)
  To: Colton Lewis
  Cc: thuth, pbonzini, nrb, imbrenda, marcorr, alexandru.elisei,
	oliver.upton, kvm, kvmarm

On Tue, Feb 07, 2023 at 11:32:56PM +0000, Colton Lewis wrote:
> 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.
> 
> Signed-off-by: Colton Lewis <coltonlewis@google.com>
> ---
>  scripts/runtime.bash | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> v5: Remove the last awk reference and guard the probing code with a
> check that ARCH = arm or arm64.
> 
> v4: https://lore.kernel.org/kvm/20230201172110.1970980-1-coltonlewis@google.com/
> 
> v3: https://lore.kernel.org/kvm/20230130195700.729498-1-coltonlewis@google.com/
> 
> v2: https://lore.kernel.org/kvm/20230111215422.2153645-1-coltonlewis@google.com/
> 
> v1: https://lore.kernel.org/kvm/20221219185250.631503-1-coltonlewis@google.com/
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index f8794e9a..fb64e855 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -188,12 +188,11 @@ 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, so this check is only run for ARM and ARM64. The
> +# parameter expansion takes the last number from the QEMU error
> +# message, which gives the allowable MAX_SMP.
> +if [ "${ARCH%64}" = arm ] && smp=$($RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \

I'd rather be more explicit. I'll change this to

if [[ $ARCH == 'arm' || $ARCH == 'arm64' ]] && smp=...

and merge it.

Thanks,
drew

> +      |& grep 'exceeds max CPUs'); then
> +	smp=${smp##*(}
> +	MAX_SMP=${smp:0:-1}
> +fi
> --
> 2.39.1.519.gcb327c4b5f-goog

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH v5] arm: Replace MAX_SMP probe loop in favor of reading directly
  2023-02-07 23:32 [kvm-unit-tests PATCH v5] arm: Replace MAX_SMP probe loop in favor of reading directly Colton Lewis
  2023-02-14 18:43 ` Andrew Jones
@ 2023-02-14 20:18 ` Andrew Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2023-02-14 20:18 UTC (permalink / raw)
  To: Colton Lewis
  Cc: thuth, pbonzini, nrb, imbrenda, marcorr, alexandru.elisei,
	oliver.upton, kvm, kvmarm

On Tue, Feb 07, 2023 at 11:32:56PM +0000, Colton Lewis wrote:
> 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.
> 
> Signed-off-by: Colton Lewis <coltonlewis@google.com>
> ---
>  scripts/runtime.bash | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> v5: Remove the last awk reference and guard the probing code with a
> check that ARCH = arm or arm64.
> 
> v4: https://lore.kernel.org/kvm/20230201172110.1970980-1-coltonlewis@google.com/
> 
> v3: https://lore.kernel.org/kvm/20230130195700.729498-1-coltonlewis@google.com/
> 
> v2: https://lore.kernel.org/kvm/20230111215422.2153645-1-coltonlewis@google.com/
> 
> v1: https://lore.kernel.org/kvm/20221219185250.631503-1-coltonlewis@google.com/
> 
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index f8794e9a..fb64e855 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -188,12 +188,11 @@ 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, so this check is only run for ARM and ARM64. The
> +# parameter expansion takes the last number from the QEMU error
> +# message, which gives the allowable MAX_SMP.
> +if [ "${ARCH%64}" = arm ] && smp=$($RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \
> +      |& grep 'exceeds max CPUs'); then
> +	smp=${smp##*(}
> +	MAX_SMP=${smp:0:-1}
> +fi
> --
> 2.39.1.519.gcb327c4b5f-goog

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-14 20:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 23:32 [kvm-unit-tests PATCH v5] arm: Replace MAX_SMP probe loop in favor of reading directly Colton Lewis
2023-02-14 18:43 ` Andrew Jones
2023-02-14 20:18 ` Andrew Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.