Skip to contentSkip to conversation

torture: Correctly fetch CPUs for kvm-build.sh with all native language

PATCH In review Frederic Weisbecker 3 participants 11 messages Apr 1, 2021 – Apr 5, 2021

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

PATCH 1/1 torture: Correctly fetch CPUs for kvm-build.sh with all native language

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

---
 tools/testing/selftests/rcutorture/bin/kvm-build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index 55f4fc102624..5ad973dca820 100755
@@ -42,7 +42,7 @@ then
 fi
 
 # Tell "make" to use double the number of real CPUs on the build system.
-ncpus="`lscpu | grep '^CPU(' | awk '{ print $2 }'`"
+ncpus="`getconf _NPROCESSORS_ONLN`"
 make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
 retval=$?
 if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

Thanx, Paul

------------------------------------------------------------------------

commit cf519a9b736cf7dcd47920065e4de8c1855b5532

Author: Frederic Weisbecker <[email protected]>
Date:   Thu Apr 1 15:26:02 2021 +0200

torture: Correctly fetch number of CPUs for non-English languages

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

This commit therefore uses the human-language-independent approach available via the getconf command, both in kvm-build.sh and in kvm-remote.sh.

tools/testing/selftests/rcutorture/bin/kvm-build.sh +1 -1
index 55f4fc1..5ad973d 100755
@@ -42,7 +42,7 @@ then
 fi
 
 # Tell "make" to use double the number of real CPUs on the build system.
-ncpus="`lscpu | grep '^CPU(' | awk '{ print $2 }'`"
+ncpus="`getconf _NPROCESSORS_ONLN`"
 make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
 retval=$?
 if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
tools/testing/selftests/rcutorture/bin/kvm-remote.sh +1 -1
index 0adaf26..92dd1a3 100755
@@ -136,7 +136,7 @@ chmod +x $T/bin/kvm-remote-*.sh
 # Check first to avoid the need for cleanup for system-name typos
 for i in $systems
 do
-	ncpus="`ssh $i lscpu | grep '^CPU(' | awk '{ print $2 }'`"
+	ncpus="`ssh $i getconf _NPROCESSORS_ONLN 2> /dev/null`"
 	echo $i: $ncpus CPUs " " `date` | tee -a "$oldrun/remote-log"
 	ret=$?
 	if test "$ret" -ne 0
#2 lore raw
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

Quoted 8 lines

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

I thought they wouldn't bother translating that, but they did...

NUMA node0 CPU(s): 0-7

becomes:

Nœud NUMA 0 de processeur(s) : 0-7

Not sure about the best way to fix it.

Thanks.

maintainer
#3 lore raw
Quoted 25 lines · Frederic Weisbecker
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

Quoted 8 lines

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

I thought they wouldn't bother translating that, but they did...

Quoted 7 lines

NUMA node0 CPU(s): 0-7

becomes:

Nœud NUMA 0 de processeur(s) : 0-7

Not sure about the best way to fix it.

The rude and crude fix is for the scripts to force the local language to English. ;-)

Thanx, Paul

#4 lore raw
Quoted 28 lines · Paul E. McKenney
Quoted 27 lines · Frederic Weisbecker
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

Quoted 8 lines

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

I thought they wouldn't bother translating that, but they did...

NUMA node0 CPU(s): 0-7

Quoted 8 lines
Quoted 5 lines

becomes:

Nœud NUMA 0 de processeur(s) : 0-7

Not sure about the best way to fix it.

The rude and crude fix is for the scripts to force the local language to English. ;-)

I don't have a better answer :o)

maintainer
#5 lore raw
Quoted 31 lines · Frederic Weisbecker
Quoted 30 lines · Paul E. McKenney
Quoted 29 lines · Frederic Weisbecker
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

Quoted 8 lines

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

I thought they wouldn't bother translating that, but they did...

NUMA node0 CPU(s): 0-7

becomes:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Nœud NUMA 0 de processeur(s) : 0-7

Not sure about the best way to fix it.

The rude and crude fix is for the scripts to force the local language to English. ;-)

I don't have a better answer :o)

If you set the environment variable LANG to en_US.UTF-8, does that make things work for you? Huh. Setting it to fr_FR.UTF-8 does not shift lscpu out of English for me, so I am guessing "no".

Help?

Thanx, Paul

#6 lore raw
Quoted 36 lines · Paul E. McKenney
Quoted 35 lines · Frederic Weisbecker
Quoted 34 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

Quoted 8 lines

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

I thought they wouldn't bother translating that, but they did...

NUMA node0 CPU(s): 0-7

becomes:

Nœud NUMA 0 de processeur(s) : 0-7

Not sure about the best way to fix it.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

The rude and crude fix is for the scripts to force the local language to English. ;-)

I don't have a better answer :o)

If you set the environment variable LANG to en_US.UTF-8, does that make things work for you? Huh. Setting it to fr_FR.UTF-8 does not shift lscpu out of English for me, so I am guessing "no".

Maybe that language isn't installed in your system. I would expect en_US.UTF-8 to be supported pretty much everywhere though. At least it works for me with: "LANG=en_US.UTF-8 lscpu".

Thanks.

Quoted 4 lines

Help?

Thanx, Paul

maintainer
#7 lore raw
Quoted 46 lines · Frederic Weisbecker
Quoted 36 lines · Paul E. McKenney
Quoted 35 lines · Frederic Weisbecker
Quoted 34 lines · Paul E. McKenney
Quoted 32 lines · Frederic Weisbecker
Quoted 13 lines · Paul E. McKenney
Quoted 9 lines · Frederic Weisbecker

Grepping for "CPU" on lscpu output isn't always successful, depending on the local language setting. As a result, the build can be aborted early with:

"make: the '-j' option requires a positive integer argument"

Prefer a more generic solution.

Good catch, applied, thank you!

Quoted 8 lines

There is a similar construct in kvm-remote.sh, so I added a similar fix to your patch.

But what about this in functions.sh?

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

I am guessing that "node0" is human-language-independent, but is "NUMA"?

I thought they wouldn't bother translating that, but they did...

NUMA node0 CPU(s): 0-7

becomes:

Nœud NUMA 0 de processeur(s) : 0-7

Not sure about the best way to fix it.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

The rude and crude fix is for the scripts to force the local language to English. ;-)

I don't have a better answer :o)

If you set the environment variable LANG to en_US.UTF-8, does that make things work for you? Huh. Setting it to fr_FR.UTF-8 does not shift lscpu out of English for me, so I am guessing "no".

Quoted 5 lines

Maybe that language isn't installed in your system. I would expect en_US.UTF-8 to be supported pretty much everywhere though. At least it works for me with: "LANG=en_US.UTF-8 lscpu".

Thanks.

How about like this? I put this only in kvm.sh for the moment, but if these keep cropping up I will just hit all the scripts. ;-)

Thanx, Paul

------------------------------------------------------------------------

commit 4ca332016ed81c15ebb3b744dbfc462281c544b8

Author: Paul E. McKenney <[email protected]>
Date:   Thu Apr 1 15:26:56 2021 -0700

torture: Set kvm.sh language to English

Some of the code invoked directly and indirectly from kvm.sh parses the output of commands. This parsing assumes English, which can cause failures if the user has set some other language. In a few cases, there are language-independent commands available, but this is not always the case. Therefore, as an alternative to polyglot parsing, this commit sets the LANG environment variable to en_US.UTF-8.

tools/testing/selftests/rcutorture/bin/kvm.sh +3 -0
index fab3bd9..390bb97 100755
@@ -20,6 +20,9 @@ mkdir $T
 
 cd `dirname $scriptname`/../../../../../
 
+# This script knows only English.
+LANG=en_US.UTF-8; export LANG
+
 dur=$((30*60))
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
#8 lore raw
Quoted 3 lines · Paul E. McKenney

On Thu, Apr 01, 2021 at 11:08:02PM +0200, Frederic Weisbecker wrote:
How about like this? I put this only in kvm.sh for the moment, but if these keep cropping up I will just hit all the scripts. ;-)

Sure, works for me!

Thanks.

Quoted 35 lines

Thanx, Paul

------------------------------------------------------------------------

commit 4ca332016ed81c15ebb3b744dbfc462281c544b8

Author: Paul E. McKenney <[email protected]>
Date:   Thu Apr 1 15:26:56 2021 -0700

torture: Set kvm.sh language to English

Some of the code invoked directly and indirectly from kvm.sh parses the output of commands. This parsing assumes English, which can cause failures if the user has set some other language. In a few cases, there are language-independent commands available, but this is not always the case. Therefore, as an alternative to polyglot parsing, this commit sets the LANG environment variable to en_US.UTF-8.

tools/testing/selftests/rcutorture/bin/kvm.sh +3 -0
index fab3bd9..390bb97 100755
@@ -20,6 +20,9 @@ mkdir $T
 
 cd `dirname $scriptname`/../../../../../
 
+# This script knows only English.
+LANG=en_US.UTF-8; export LANG
+
 dur=$((30*60))
 dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
#9 lore raw
In reply to Paul E. McKenney

tools/testing/selftests/rcutorture/bin/kvm.sh mkdir $T · line 24

Quoted 2 lines · Paul E. McKenney
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
+# This script knows only English.
+LANG=en_US.UTF-8; export LANG

This, too, will only work if en_US.UTF-8 is installed . Check with "locale -a" if it is. Also, Perl will complain loudly if the language is not installed (try: "LANG=en_US.UTF-9 perl"), a nice way to test if LANG works as expected.

So, wouldn't LANG=C be a more conservative fallback here?

</bikeshed>

Christian.

Signature · 3 lines
BOFH excuse #58:

high pressure system failure
maintainer
#10 lore raw
Quoted 10 lines · Christian Kujau

tools/testing/selftests/rcutorture/bin/kvm.sh mkdir $T · line 24

Quoted 2 lines · Paul E. McKenney
tools/testing/selftests/rcutorture/bin/kvm.sh +2 -0
+# This script knows only English.
+LANG=en_US.UTF-8; export LANG

This, too, will only work if en_US.UTF-8 is installed . Check with "locale -a" if it is. Also, Perl will complain loudly if the language is not installed (try: "LANG=en_US.UTF-9 perl"), a nice way to test if LANG works as expected.

So, wouldn't LANG=C be a more conservative fallback here?

If it works for Frederic, I am good with it. And yes, we do need to have a least-common-denominator solution.

Quoted 1 line

</bikeshed>

Plaid!!! We must paint the bikeshed plaid! ;-)

Thanx, Paul