linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/rcutorture: Make identify_qemu_vcpus() independant of local language
@ 2020-11-19  0:30 Frederic Weisbecker
  2020-11-19 21:59 ` Paul E. McKenney
  0 siblings, 1 reply; 3+ messages in thread
From: Frederic Weisbecker @ 2020-11-19  0:30 UTC (permalink / raw)
  To: Paul E . McKenney
  Cc: LKML, Frederic Weisbecker, Steven Rostedt, rcu,
	Mathieu Desnoyers, Lai Jiangshan, Josh Triplett

The implementation expects `lscpu` to have a "CPU: " line, for example:

	CPU(s):		8

But some local language settings may advocate for their own version:

	Processeur(s) :		8

As a result the function may return an empty string and rcutorture would
dump the following warning (still with the local taste):

	kvm-test-1-run.sh: ligne 138 : test:  : nombre entier attendu comme expression

Just use a command whose output every language agree with.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: rcu@vger.kernel.org
---
 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 82663495fb38..fef8b4b55c27 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -232,7 +232,7 @@ identify_qemu_args () {
 # Returns the number of virtual CPUs available to the aggregate of the
 # guest OSes.
 identify_qemu_vcpus () {
-	lscpu | grep '^CPU(s):' | sed -e 's/CPU(s)://' -e 's/[ 	]*//g'
+	getconf _NPROCESSORS_ONLN
 }
 
 # print_bug
-- 
2.25.1


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

* Re: [PATCH] tools/rcutorture: Make identify_qemu_vcpus() independant of local language
  2020-11-19  0:30 [PATCH] tools/rcutorture: Make identify_qemu_vcpus() independant of local language Frederic Weisbecker
@ 2020-11-19 21:59 ` Paul E. McKenney
  2020-11-19 23:03   ` Frederic Weisbecker
  0 siblings, 1 reply; 3+ messages in thread
From: Paul E. McKenney @ 2020-11-19 21:59 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: LKML, Steven Rostedt, rcu, Mathieu Desnoyers, Lai Jiangshan,
	Josh Triplett

On Thu, Nov 19, 2020 at 01:30:24AM +0100, Frederic Weisbecker wrote:
> The implementation expects `lscpu` to have a "CPU: " line, for example:
> 
> 	CPU(s):		8
> 
> But some local language settings may advocate for their own version:
> 
> 	Processeur(s) :		8
> 
> As a result the function may return an empty string and rcutorture would
> dump the following warning (still with the local taste):
> 
> 	kvm-test-1-run.sh: ligne 138 : test:  : nombre entier attendu comme expression
> 
> Just use a command whose output every language agree with.
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> Cc: Paul E. McKenney <paulmck@kernel.org>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> Cc: rcu@vger.kernel.org

Queued for review and testing, thank you!  As usual, I could not resist
the urge to edit a bit, so please let me know if I messed anything up.

If there are too many of these, it might be easier for kvm.sh to switch
itself to EN-US mode, but this change both simplified the code and helped
defend the purity of the French language, so steady as she goes!  ;-)

							Thanx, Paul

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

commit 655f941b96cbfc6f8869142ece092d8617425948
Author: Frederic Weisbecker <frederic@kernel.org>
Date:   Thu Nov 19 01:30:24 2020 +0100

    tools/rcutorture: Make identify_qemu_vcpus() independent of local language
    
    The rcutorture scripts' identify_qemu_vcpus() function expects `lscpu`
    to have a "CPU: " line, for example:
    
            CPU(s):         8
    
    But different local language settings can give different results:
    
            Processeur(s) :         8
    
    As a result, identify_qemu_vcpus() may return an empty string, resulting
    in the following warning (with the same local language settings):
    
            kvm-test-1-run.sh: ligne 138 : test:  : nombre entier attendu comme expression
    
    This commit therefore changes identify_qemu_vcpus() to use getconf,
    which produces local-language-independend output.
    
    Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
    Cc: Paul E. McKenney <paulmck@kernel.org>
    Cc: Josh Triplett <josh@joshtriplett.org>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Cc: Lai Jiangshan <jiangshanlai@gmail.com>
    Cc: rcu@vger.kernel.org

diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh
index 8266349..fef8b4b 100644
--- a/tools/testing/selftests/rcutorture/bin/functions.sh
+++ b/tools/testing/selftests/rcutorture/bin/functions.sh
@@ -232,7 +232,7 @@ identify_qemu_args () {
 # Returns the number of virtual CPUs available to the aggregate of the
 # guest OSes.
 identify_qemu_vcpus () {
-	lscpu | grep '^CPU(s):' | sed -e 's/CPU(s)://' -e 's/[ 	]*//g'
+	getconf _NPROCESSORS_ONLN
 }
 
 # print_bug

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

* Re: [PATCH] tools/rcutorture: Make identify_qemu_vcpus() independant of local language
  2020-11-19 21:59 ` Paul E. McKenney
@ 2020-11-19 23:03   ` Frederic Weisbecker
  0 siblings, 0 replies; 3+ messages in thread
From: Frederic Weisbecker @ 2020-11-19 23:03 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: LKML, Steven Rostedt, rcu, Mathieu Desnoyers, Lai Jiangshan,
	Josh Triplett

On Thu, Nov 19, 2020 at 01:59:03PM -0800, Paul E. McKenney wrote:
> On Thu, Nov 19, 2020 at 01:30:24AM +0100, Frederic Weisbecker wrote:
> > The implementation expects `lscpu` to have a "CPU: " line, for example:
> > 
> > 	CPU(s):		8
> > 
> > But some local language settings may advocate for their own version:
> > 
> > 	Processeur(s) :		8
> > 
> > As a result the function may return an empty string and rcutorture would
> > dump the following warning (still with the local taste):
> > 
> > 	kvm-test-1-run.sh: ligne 138 : test:  : nombre entier attendu comme expression
> > 
> > Just use a command whose output every language agree with.
> > 
> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > Cc: Paul E. McKenney <paulmck@kernel.org>
> > Cc: Josh Triplett <josh@joshtriplett.org>
> > Cc: Steven Rostedt <rostedt@goodmis.org>
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> > Cc: rcu@vger.kernel.org
> 
> Queued for review and testing, thank you!  As usual, I could not resist
> the urge to edit a bit, so please let me know if I messed anything up.
> 
> If there are too many of these, it might be easier for kvm.sh to switch
> itself to EN-US mode, but this change both simplified the code and helped
> defend the purity of the French language, so steady as she goes!  ;-)

We aligned the stars!

> commit 655f941b96cbfc6f8869142ece092d8617425948
> Author: Frederic Weisbecker <frederic@kernel.org>
> Date:   Thu Nov 19 01:30:24 2020 +0100
> 
>     tools/rcutorture: Make identify_qemu_vcpus() independent of local language
>     
>     The rcutorture scripts' identify_qemu_vcpus() function expects `lscpu`
>     to have a "CPU: " line, for example:
>     
>             CPU(s):         8
>     
>     But different local language settings can give different results:
>     
>             Processeur(s) :         8
>     
>     As a result, identify_qemu_vcpus() may return an empty string, resulting
>     in the following warning (with the same local language settings):
>     
>             kvm-test-1-run.sh: ligne 138 : test:  : nombre entier attendu comme expression
>     
>     This commit therefore changes identify_qemu_vcpus() to use getconf,
>     which produces local-language-independend output.
>     
>     Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
>     Cc: Paul E. McKenney <paulmck@kernel.org>
>     Cc: Josh Triplett <josh@joshtriplett.org>
>     Cc: Steven Rostedt <rostedt@goodmis.org>
>     Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>     Cc: Lai Jiangshan <jiangshanlai@gmail.com>
>     Cc: rcu@vger.kernel.org

Even better, Thanks!

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

end of thread, other threads:[~2020-11-19 23:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19  0:30 [PATCH] tools/rcutorture: Make identify_qemu_vcpus() independant of local language Frederic Weisbecker
2020-11-19 21:59 ` Paul E. McKenney
2020-11-19 23:03   ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).