torture: Make thread detection more robust by using lspcu
authorPaul Menzel <pmenzel@molgen.mpg.de>
Tue, 22 Feb 2022 12:07:16 +0000 (13:07 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 24 Feb 2022 20:48:51 +0000 (12:48 -0800)
commit9f0daba62e958c31326c7a9eae33651e3a3cc6b4
treef707e7f639e3a9b31785660d91df399f3a61158e
parent6a6520c89dfeb667ddc69c1f482d5ea9bbd30e8c
torture: Make thread detection more robust by using lspcu

For consecutive numbers the lscpu command collapses the output and just
shows the range with start and end. The processors are numbered that
way on POWER8.

    $ sudo ppc64_cpu --smt=8
    $ lscpu | grep '^NUMA node'
    NUMA node(s):                    2
    NUMA node0 CPU(s):               0-79
    NUMA node8 CPU(s):               80-159

This causes the heuristic to detect the number threads per core, looking
for the number after the first comma, to fail, and QEMU aborts because of
invalid arguments.

    $ lscpu | grep '^NUMA node0' | sed -e 's/^[^,-]*(,|\-)\([0-9]*\),.*$/\1/'
    NUMA node0 CPU(s):               0-79

But the lscpu command shows the number of threads per core:

    $ sudo ppc64_cpu --smt=8
    $ lscpu | grep 'Thread(s) per core'
    Thread(s) per core:              8
    $ sudo ppc64_cpu --smt=off
    $ lscpu | grep 'Thread(s) per core'
    Thread(s) per core:              1

This commit therefore directly uses that value.

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/rcutorture/bin/functions.sh