[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220222120718.17141-2-pmenzel@molgen.mpg.de>
Date: Tue, 22 Feb 2022 13:07:17 +0100
From: Paul Menzel <pmenzel@...gen.mpg.de>
To: "Paul E. McKenney" <paulmck@...nel.org>,
Josh Triplett <josh@...htriplett.org>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Shuah Khan <shuah@...nel.org>
Cc: Paul Menzel <pmenzel@...gen.mpg.de>,
Zhouyi Zhou <zhouzhouyi@...il.com>, rcu@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] torture: Make thread detection more robust by using lspcu
For consecutive numbers *lscpu* 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 | sed -n -e '/^NUMA node0/s/^[^,]*,\([0-9]*\),.*$/\1/p'
$
(Before the last patch, the whole line was returned.)
$ lscpu | grep '^NUMA node0' | sed -e 's/^[^,-]*(,|\-)\([0-9]*\),.*$/\1/'
NUMA node0 CPU(s): 0-79
*lscpu* shows the number of threads per core, so use that value directly.
$ 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
Note, the replaced heuristic is also incorrect for that case, where the
threads per core are disabled.
$ lscpu | sed -n -e '/^NUMA node0/s/^[^,]*,\([0-9]*\),.*$/\1/p'
8
Signed-off-by: Paul Menzel <pmenzel@...gen.mpg.de>
---
tools/testing/selftests/rcutorture/bin/functions.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh
index 5cff520955e6..66d0414d8e4b 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -301,7 +301,7 @@ specify_qemu_cpus () {
echo $2 -smp $3
;;
qemu-system-ppc64)
- nt="`lscpu | sed -n -e '/^NUMA node0/s/^[^,]*,\([0-9]*\),.*$/\1/p'`"
+ nt="`lscpu | sed -n 's/^Thread(s) per core:\s*//p'`"
echo $2 -smp cores=`expr \( $3 + $nt - 1 \) / $nt`,threads=$nt
;;
esac
--
2.35.1
Powered by blists - more mailing lists