[for,5.1,3/3] rseq/selftests: Adapt number of threads to the number of detected cpus
diff mbox series

Message ID 20190305194755.2602-4-mathieu.desnoyers@efficios.com
State New
Headers show
Series
  • Untitled series #87971
Related show

Commit Message

Mathieu Desnoyers March 5, 2019, 7:47 p.m. UTC
On smaller systems, running a test with 200 threads can take a long
time on machines with smaller number of CPUs.

Detect the number of online cpus at test runtime, and multiply that
by 6 to have 6 rseq threads per cpu preempting each other.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Watson <davejwatson@fb.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: linux-kselftest@vger.kernel.org
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Chris Lameter <cl@linux.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Paul Turner <pjt@google.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ben Maurer <bmaurer@fb.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
---
 tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Ingo Molnar April 19, 2019, 10:38 a.m. UTC | #1
* Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:

> On smaller systems, running a test with 200 threads can take a long
> time on machines with smaller number of CPUs.
> 
> Detect the number of online cpus at test runtime, and multiply that
> by 6 to have 6 rseq threads per cpu preempting each other.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Joel Fernandes <joelaf@google.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Dave Watson <davejwatson@fb.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Andi Kleen <andi@firstfloor.org>
> Cc: linux-kselftest@vger.kernel.org
> Cc: "H . Peter Anvin" <hpa@zytor.com>
> Cc: Chris Lameter <cl@linux.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
> Cc: Paul Turner <pjt@google.com>
> Cc: Boqun Feng <boqun.feng@gmail.com>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ben Maurer <bmaurer@fb.com>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> ---
>  tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/rseq/run_param_test.sh b/tools/testing/selftests/rseq/run_param_test.sh
> index 3acd6d75ff9f..e426304fd4a0 100755
> --- a/tools/testing/selftests/rseq/run_param_test.sh
> +++ b/tools/testing/selftests/rseq/run_param_test.sh
> @@ -1,6 +1,8 @@
>  #!/bin/bash
>  # SPDX-License-Identifier: GPL-2.0+ or MIT
>  
> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
> +
>  EXTRA_ARGS=${@}
>  
>  OLDIFS="$IFS"
> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>  
>  REPS=1000
>  SLOW_REPS=100
> +NR_THREADS=$((6*${NR_CPUS}))
>  
>  function do_tests()
>  {
>  	local i=0
>  	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>  		echo "Running test ${TEST_NAME[$i]}"
> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
>  		echo "Running compare-twice test ${TEST_NAME[$i]}"
> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
>  		let "i++"
>  	done
>  }

BTW., when trying to build the rseq self-tests I get this build failure:

  dagon:~/tip/tools/testing/selftests/rseq> make
  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -o /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_percpu_ops_test.c -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined reference to `.L8'
  /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined reference to `.L49'
  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined reference to `.L57'
  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to `.L49'
  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to `.L55'
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:22: /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1

Is this a known problem, or do I miss something from my build environment 
perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).

Thanks,

	Ingo
Mathieu Desnoyers April 19, 2019, 12:41 p.m. UTC | #2
----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:

> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
> 
>> On smaller systems, running a test with 200 threads can take a long
>> time on machines with smaller number of CPUs.
>> 
>> Detect the number of online cpus at test runtime, and multiply that
>> by 6 to have 6 rseq threads per cpu preempting each other.
>> 
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>> Cc: Shuah Khan <shuah@kernel.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Joel Fernandes <joelaf@google.com>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Dave Watson <davejwatson@fb.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: Andi Kleen <andi@firstfloor.org>
>> Cc: linux-kselftest@vger.kernel.org
>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>> Cc: Chris Lameter <cl@linux.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>> Cc: Paul Turner <pjt@google.com>
>> Cc: Boqun Feng <boqun.feng@gmail.com>
>> Cc: Josh Triplett <josh@joshtriplett.org>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Cc: Ben Maurer <bmaurer@fb.com>
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> ---
>>  tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>> b/tools/testing/selftests/rseq/run_param_test.sh
>> index 3acd6d75ff9f..e426304fd4a0 100755
>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>> @@ -1,6 +1,8 @@
>>  #!/bin/bash
>>  # SPDX-License-Identifier: GPL-2.0+ or MIT
>>  
>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>> +
>>  EXTRA_ARGS=${@}
>>  
>>  OLDIFS="$IFS"
>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>  
>>  REPS=1000
>>  SLOW_REPS=100
>> +NR_THREADS=$((6*${NR_CPUS}))
>>  
>>  function do_tests()
>>  {
>>  	local i=0
>>  	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>  		echo "Running test ${TEST_NAME[$i]}"
>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>> || exit 1
>>  		echo "Running compare-twice test ${TEST_NAME[$i]}"
>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>> exit 1
>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>> ${EXTRA_ARGS} || exit 1
>>  		let "i++"
>>  	done
>>  }
> 
> BTW., when trying to build the rseq self-tests I get this build failure:
> 
>  dagon:~/tip/tools/testing/selftests/rseq> make
>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>  -fPIC rseq.c -lpthread -o
>  /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>  -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>  basic_percpu_ops_test.c -lpthread -lrseq -o
>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>  reference to `.L8'
>  /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>  undefined reference to `.L49'
>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>  reference to `.L57'
>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>  `.L49'
>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>  `.L55'
>  collect2: error: ld returned 1 exit status
>  make: *** [Makefile:22:
>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
> 
> Is this a known problem, or do I miss something from my build environment
> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).

It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
(experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).

Thanks for reporting! I will investigate.

Mathieu


> 
> Thanks,
> 
> 	Ingo
Mathieu Desnoyers April 19, 2019, 12:55 p.m. UTC | #3
----- On Apr 19, 2019, at 8:41 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:

> ----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:
> 
>> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>> 
>>> On smaller systems, running a test with 200 threads can take a long
>>> time on machines with smaller number of CPUs.
>>> 
>>> Detect the number of online cpus at test runtime, and multiply that
>>> by 6 to have 6 rseq threads per cpu preempting each other.
>>> 
>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>> Cc: Shuah Khan <shuah@kernel.org>
>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>> Cc: Joel Fernandes <joelaf@google.com>
>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>> Cc: Dave Watson <davejwatson@fb.com>
>>> Cc: Will Deacon <will.deacon@arm.com>
>>> Cc: Andi Kleen <andi@firstfloor.org>
>>> Cc: linux-kselftest@vger.kernel.org
>>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>>> Cc: Chris Lameter <cl@linux.com>
>>> Cc: Russell King <linux@arm.linux.org.uk>
>>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>>> Cc: Paul Turner <pjt@google.com>
>>> Cc: Boqun Feng <boqun.feng@gmail.com>
>>> Cc: Josh Triplett <josh@joshtriplett.org>
>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>> Cc: Ben Maurer <bmaurer@fb.com>
>>> Cc: Andy Lutomirski <luto@amacapital.net>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>>> ---
>>>  tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>>> b/tools/testing/selftests/rseq/run_param_test.sh
>>> index 3acd6d75ff9f..e426304fd4a0 100755
>>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>>> @@ -1,6 +1,8 @@
>>>  #!/bin/bash
>>>  # SPDX-License-Identifier: GPL-2.0+ or MIT
>>>  
>>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>>> +
>>>  EXTRA_ARGS=${@}
>>>  
>>>  OLDIFS="$IFS"
>>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>>  
>>>  REPS=1000
>>>  SLOW_REPS=100
>>> +NR_THREADS=$((6*${NR_CPUS}))
>>>  
>>>  function do_tests()
>>>  {
>>>  	local i=0
>>>  	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>>  		echo "Running test ${TEST_NAME[$i]}"
>>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>>> || exit 1
>>>  		echo "Running compare-twice test ${TEST_NAME[$i]}"
>>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>>> exit 1
>>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>>> ${EXTRA_ARGS} || exit 1
>>>  		let "i++"
>>>  	done
>>>  }
>> 
>> BTW., when trying to build the rseq self-tests I get this build failure:
>> 
>>  dagon:~/tip/tools/testing/selftests/rseq> make
>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>>  -fPIC rseq.c -lpthread -o
>>  /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>>  -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>>  basic_percpu_ops_test.c -lpthread -lrseq -o
>>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>>  reference to `.L8'
>>  /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>>  undefined reference to `.L49'
>>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>>  reference to `.L57'
>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>>  `.L49'
>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>>  `.L55'
>>  collect2: error: ld returned 1 exit status
>>  make: *** [Makefile:22:
>>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
>> 
>> Is this a known problem, or do I miss something from my build environment
>> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).
> 
> It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
> but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
> (experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).
> 
> Thanks for reporting! I will investigate.

It looks like gcc-8 optimize away the target of asm goto labels when
there are more than one of them on x86-64. I'll try to come up with
a simpler reproducer.

Thanks,

Mathieu
Mathieu Desnoyers April 19, 2019, 1:42 p.m. UTC | #4
----- On Apr 19, 2019, at 8:55 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:

> ----- On Apr 19, 2019, at 8:41 AM, Mathieu Desnoyers
> mathieu.desnoyers@efficios.com wrote:
> 
>> ----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:
>> 
>>> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>>> 
>>>> On smaller systems, running a test with 200 threads can take a long
>>>> time on machines with smaller number of CPUs.
>>>> 
>>>> Detect the number of online cpus at test runtime, and multiply that
>>>> by 6 to have 6 rseq threads per cpu preempting each other.
>>>> 
>>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>>> Cc: Shuah Khan <shuah@kernel.org>
>>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>>> Cc: Joel Fernandes <joelaf@google.com>
>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>>> Cc: Dave Watson <davejwatson@fb.com>
>>>> Cc: Will Deacon <will.deacon@arm.com>
>>>> Cc: Andi Kleen <andi@firstfloor.org>
>>>> Cc: linux-kselftest@vger.kernel.org
>>>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>>>> Cc: Chris Lameter <cl@linux.com>
>>>> Cc: Russell King <linux@arm.linux.org.uk>
>>>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>>>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>>>> Cc: Paul Turner <pjt@google.com>
>>>> Cc: Boqun Feng <boqun.feng@gmail.com>
>>>> Cc: Josh Triplett <josh@joshtriplett.org>
>>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>>> Cc: Ben Maurer <bmaurer@fb.com>
>>>> Cc: Andy Lutomirski <luto@amacapital.net>
>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>>>> ---
>>>>  tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>>> 
>>>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>>>> b/tools/testing/selftests/rseq/run_param_test.sh
>>>> index 3acd6d75ff9f..e426304fd4a0 100755
>>>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>>>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>>>> @@ -1,6 +1,8 @@
>>>>  #!/bin/bash
>>>>  # SPDX-License-Identifier: GPL-2.0+ or MIT
>>>>  
>>>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>>>> +
>>>>  EXTRA_ARGS=${@}
>>>>  
>>>>  OLDIFS="$IFS"
>>>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>>>  
>>>>  REPS=1000
>>>>  SLOW_REPS=100
>>>> +NR_THREADS=$((6*${NR_CPUS}))
>>>>  
>>>>  function do_tests()
>>>>  {
>>>>  	local i=0
>>>>  	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>>>  		echo "Running test ${TEST_NAME[$i]}"
>>>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>>>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>>>> || exit 1
>>>>  		echo "Running compare-twice test ${TEST_NAME[$i]}"
>>>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>>>> exit 1
>>>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>>>> ${EXTRA_ARGS} || exit 1
>>>>  		let "i++"
>>>>  	done
>>>>  }
>>> 
>>> BTW., when trying to build the rseq self-tests I get this build failure:
>>> 
>>>  dagon:~/tip/tools/testing/selftests/rseq> make
>>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>>>  -fPIC rseq.c -lpthread -o
>>>  /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>>>  -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>>>  basic_percpu_ops_test.c -lpthread -lrseq -o
>>>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>>>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>>>  reference to `.L8'
>>>  /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>>>  undefined reference to `.L49'
>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>>>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>>>  reference to `.L57'
>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>>>  `.L49'
>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>>>  `.L55'
>>>  collect2: error: ld returned 1 exit status
>>>  make: *** [Makefile:22:
>>>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
>>> 
>>> Is this a known problem, or do I miss something from my build environment
>>> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).
>> 
>> It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
>> but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
>> (experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).
>> 
>> Thanks for reporting! I will investigate.
> 
> It looks like gcc-8 optimize away the target of asm goto labels when
> there are more than one of them on x86-64. I'll try to come up with
> a simpler reproducer.

It appears to be related to gcc-8 mishandling combination of
asm goto and thread-local storage input operands on x86-64.
Here is a simple reproducer:

__thread int var;
  
static int fct(void)
{
        asm goto (      "jmp %l[testlabel]\n\t"
                        : : [var] "m" (var) : : testlabel);
        return 0;
testlabel:
        return 1;
}

int main()
{
        return fct();
}

building with gcc-7 -O2 is fine. Building with gcc-8 -O0 is
fine too. Building with gcc-8 -O1 and -O2 fails with:

/tmp/ccuXTFfs.o: In function `main':
test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2'
collect2: error: ld returned 1 exit status

With gcc-7 -O2, the assembly of main has the .L2 label:

main:
.LFB1:
        .cfi_startproc
#APP
# 5 "test-asm-goto.c" 1
        jmp .L2

# 0 "" 2
#NO_APP
.L4:
.L3:
        xorl    %eax, %eax
        ret
.L2:
        movl    $1, %eax
        ret
        .cfi_endproc

However, with gcc-8 -O2, it's missing:

main:
.LFB1:
        .cfi_startproc
.L3:
#APP
# 5 "test-asm-goto.c" 1
        jmp .L2

# 0 "" 2
#NO_APP
        xorl    %eax, %eax
        ret
        .cfi_endproc

It looks like we have a compiler issue. :-/

Thanks,

Mathieu
Mathieu Desnoyers April 19, 2019, 1:48 p.m. UTC | #5
----- On Apr 19, 2019, at 9:42 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:

> ----- On Apr 19, 2019, at 8:55 AM, Mathieu Desnoyers
> mathieu.desnoyers@efficios.com wrote:
> 
>> ----- On Apr 19, 2019, at 8:41 AM, Mathieu Desnoyers
>> mathieu.desnoyers@efficios.com wrote:
>> 
>>> ----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:
>>> 
>>>> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>>>> 
>>>>> On smaller systems, running a test with 200 threads can take a long
>>>>> time on machines with smaller number of CPUs.
>>>>> 
>>>>> Detect the number of online cpus at test runtime, and multiply that
>>>>> by 6 to have 6 rseq threads per cpu preempting each other.
>>>>> 
>>>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>>>> Cc: Shuah Khan <shuah@kernel.org>
>>>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>>>> Cc: Joel Fernandes <joelaf@google.com>
>>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>>>> Cc: Dave Watson <davejwatson@fb.com>
>>>>> Cc: Will Deacon <will.deacon@arm.com>
>>>>> Cc: Andi Kleen <andi@firstfloor.org>
>>>>> Cc: linux-kselftest@vger.kernel.org
>>>>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>>>>> Cc: Chris Lameter <cl@linux.com>
>>>>> Cc: Russell King <linux@arm.linux.org.uk>
>>>>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>>>>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>>>>> Cc: Paul Turner <pjt@google.com>
>>>>> Cc: Boqun Feng <boqun.feng@gmail.com>
>>>>> Cc: Josh Triplett <josh@joshtriplett.org>
>>>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>>>> Cc: Ben Maurer <bmaurer@fb.com>
>>>>> Cc: Andy Lutomirski <luto@amacapital.net>
>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>>>>> ---
>>>>>  tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>>>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>>>> 
>>>>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>>>>> b/tools/testing/selftests/rseq/run_param_test.sh
>>>>> index 3acd6d75ff9f..e426304fd4a0 100755
>>>>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>>>>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>>>>> @@ -1,6 +1,8 @@
>>>>>  #!/bin/bash
>>>>>  # SPDX-License-Identifier: GPL-2.0+ or MIT
>>>>>  
>>>>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>>>>> +
>>>>>  EXTRA_ARGS=${@}
>>>>>  
>>>>>  OLDIFS="$IFS"
>>>>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>>>>  
>>>>>  REPS=1000
>>>>>  SLOW_REPS=100
>>>>> +NR_THREADS=$((6*${NR_CPUS}))
>>>>>  
>>>>>  function do_tests()
>>>>>  {
>>>>>  	local i=0
>>>>>  	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>>>>  		echo "Running test ${TEST_NAME[$i]}"
>>>>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>>>>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>>>>> || exit 1
>>>>>  		echo "Running compare-twice test ${TEST_NAME[$i]}"
>>>>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>>>>> exit 1
>>>>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>>>>> ${EXTRA_ARGS} || exit 1
>>>>>  		let "i++"
>>>>>  	done
>>>>>  }
>>>> 
>>>> BTW., when trying to build the rseq self-tests I get this build failure:
>>>> 
>>>>  dagon:~/tip/tools/testing/selftests/rseq> make
>>>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>>>>  -fPIC rseq.c -lpthread -o
>>>>  /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>>>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>>>>  -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>>>>  gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>>>>  basic_percpu_ops_test.c -lpthread -lrseq -o
>>>>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>>>>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>>>>  reference to `.L8'
>>>>  /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>>>>  undefined reference to `.L49'
>>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>>>>  /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>>>>  reference to `.L57'
>>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>>>>  `.L49'
>>>>  /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>>>>  `.L55'
>>>>  collect2: error: ld returned 1 exit status
>>>>  make: *** [Makefile:22:
>>>>  /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
>>>> 
>>>> Is this a known problem, or do I miss something from my build environment
>>>> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).
>>> 
>>> It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
>>> but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
>>> (experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).
>>> 
>>> Thanks for reporting! I will investigate.
>> 
>> It looks like gcc-8 optimize away the target of asm goto labels when
>> there are more than one of them on x86-64. I'll try to come up with
>> a simpler reproducer.
> 
> It appears to be related to gcc-8 mishandling combination of
> asm goto and thread-local storage input operands on x86-64.
> Here is a simple reproducer:
> 
> __thread int var;
>  
> static int fct(void)
> {
>        asm goto (      "jmp %l[testlabel]\n\t"
>                        : : [var] "m" (var) : : testlabel);
>        return 0;
> testlabel:

FWIW, if I add an empty

   asm volatile ("");

here after the label, gcc-8 -O2 builds "something" which is
a bogus assembler (an endless loop) :

main:
.LFB24:
        .cfi_startproc
.L2:
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
#APP
# 6 "test-asm-goto.c" 1
        jmp .L2

# 0 "" 2
#NO_APP
        movl    %fs:var@tpoff, %edx
        leaq    .LC0(%rip), %rsi
        movl    $1, %edi
        xorl    %eax, %eax
        call    __printf_chk@PLT
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

Thoughts ?

Thanks,

Mathieu

>        return 1;
> }
> 
> int main()
> {
>        return fct();
> }
> 
> building with gcc-7 -O2 is fine. Building with gcc-8 -O0 is
> fine too. Building with gcc-8 -O1 and -O2 fails with:
> 
> /tmp/ccuXTFfs.o: In function `main':
> test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2'
> collect2: error: ld returned 1 exit status
> 
> With gcc-7 -O2, the assembly of main has the .L2 label:
> 
> main:
> .LFB1:
>        .cfi_startproc
> #APP
> # 5 "test-asm-goto.c" 1
>        jmp .L2
> 
> # 0 "" 2
> #NO_APP
> .L4:
> .L3:
>        xorl    %eax, %eax
>        ret
> .L2:
>        movl    $1, %eax
>        ret
>        .cfi_endproc
> 
> However, with gcc-8 -O2, it's missing:
> 
> main:
> .LFB1:
>        .cfi_startproc
> .L3:
> #APP
> # 5 "test-asm-goto.c" 1
>        jmp .L2
> 
> # 0 "" 2
> #NO_APP
>        xorl    %eax, %eax
>        ret
>        .cfi_endproc
> 
> It looks like we have a compiler issue. :-/
> 
> Thanks,
> 
> Mathieu
> 
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
shuah April 19, 2019, 2:17 p.m. UTC | #6
On 4/19/19 7:48 AM, Mathieu Desnoyers wrote:
> ----- On Apr 19, 2019, at 9:42 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:
> 
>> ----- On Apr 19, 2019, at 8:55 AM, Mathieu Desnoyers
>> mathieu.desnoyers@efficios.com wrote:
>>
>>> ----- On Apr 19, 2019, at 8:41 AM, Mathieu Desnoyers
>>> mathieu.desnoyers@efficios.com wrote:
>>>
>>>> ----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:
>>>>
>>>>> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>>>>>
>>>>>> On smaller systems, running a test with 200 threads can take a long
>>>>>> time on machines with smaller number of CPUs.
>>>>>>
>>>>>> Detect the number of online cpus at test runtime, and multiply that
>>>>>> by 6 to have 6 rseq threads per cpu preempting each other.
>>>>>>
>>>>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>>>>> Cc: Shuah Khan <shuah@kernel.org>
>>>>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>>>>> Cc: Joel Fernandes <joelaf@google.com>
>>>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>>>>> Cc: Dave Watson <davejwatson@fb.com>
>>>>>> Cc: Will Deacon <will.deacon@arm.com>
>>>>>> Cc: Andi Kleen <andi@firstfloor.org>
>>>>>> Cc: linux-kselftest@vger.kernel.org
>>>>>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>>>>>> Cc: Chris Lameter <cl@linux.com>
>>>>>> Cc: Russell King <linux@arm.linux.org.uk>
>>>>>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>>>>>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>>>>>> Cc: Paul Turner <pjt@google.com>
>>>>>> Cc: Boqun Feng <boqun.feng@gmail.com>
>>>>>> Cc: Josh Triplett <josh@joshtriplett.org>
>>>>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>>>>> Cc: Ben Maurer <bmaurer@fb.com>
>>>>>> Cc: Andy Lutomirski <luto@amacapital.net>
>>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>>>>>> ---
>>>>>>   tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>>>>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>>>>>
>>>>>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>>>>>> b/tools/testing/selftests/rseq/run_param_test.sh
>>>>>> index 3acd6d75ff9f..e426304fd4a0 100755
>>>>>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>>>>>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>>>>>> @@ -1,6 +1,8 @@
>>>>>>   #!/bin/bash
>>>>>>   # SPDX-License-Identifier: GPL-2.0+ or MIT
>>>>>>   
>>>>>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>>>>>> +
>>>>>>   EXTRA_ARGS=${@}
>>>>>>   
>>>>>>   OLDIFS="$IFS"
>>>>>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>>>>>   
>>>>>>   REPS=1000
>>>>>>   SLOW_REPS=100
>>>>>> +NR_THREADS=$((6*${NR_CPUS}))
>>>>>>   
>>>>>>   function do_tests()
>>>>>>   {
>>>>>>   	local i=0
>>>>>>   	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>>>>>   		echo "Running test ${TEST_NAME[$i]}"
>>>>>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>>>>>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>>>>>> || exit 1
>>>>>>   		echo "Running compare-twice test ${TEST_NAME[$i]}"
>>>>>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>>>>>> exit 1
>>>>>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>>>>>> ${EXTRA_ARGS} || exit 1
>>>>>>   		let "i++"
>>>>>>   	done
>>>>>>   }
>>>>>
>>>>> BTW., when trying to build the rseq self-tests I get this build failure:
>>>>>
>>>>>   dagon:~/tip/tools/testing/selftests/rseq> make
>>>>>   gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>>>>>   -fPIC rseq.c -lpthread -o
>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>>>>>   gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>>>>>   -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>>>>>   gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>>>>>   basic_percpu_ops_test.c -lpthread -lrseq -o
>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>>>>>   reference to `.L8'
>>>>>   /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>>>>>   undefined reference to `.L49'
>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>>>>>   reference to `.L57'
>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>>>>>   `.L49'
>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>>>>>   `.L55'
>>>>>   collect2: error: ld returned 1 exit status
>>>>>   make: *** [Makefile:22:
>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
>>>>>
>>>>> Is this a known problem, or do I miss something from my build environment
>>>>> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).
>>>>
>>>> It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
>>>> but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
>>>> (experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).
>>>>
>>>> Thanks for reporting! I will investigate.
>>>
>>> It looks like gcc-8 optimize away the target of asm goto labels when
>>> there are more than one of them on x86-64. I'll try to come up with
>>> a simpler reproducer.
>>
>> It appears to be related to gcc-8 mishandling combination of
>> asm goto and thread-local storage input operands on x86-64.
>> Here is a simple reproducer:
>>
>> __thread int var;
>>   
>> static int fct(void)
>> {
>>         asm goto (      "jmp %l[testlabel]\n\t"
>>                         : : [var] "m" (var) : : testlabel);
>>         return 0;
>> testlabel:
> 
> FWIW, if I add an empty
> 
>     asm volatile ("");
> 
> here after the label, gcc-8 -O2 builds "something" which is
> a bogus assembler (an endless loop) :
> 
> main:
> .LFB24:
>          .cfi_startproc
> .L2:
>          subq    $8, %rsp
>          .cfi_def_cfa_offset 16
> #APP
> # 6 "test-asm-goto.c" 1
>          jmp .L2
> 
> # 0 "" 2
> #NO_APP
>          movl    %fs:var@tpoff, %edx
>          leaq    .LC0(%rip), %rsi
>          movl    $1, %edi
>          xorl    %eax, %eax
>          call    __printf_chk@PLT
>          xorl    %eax, %eax
>          addq    $8, %rsp
>          .cfi_def_cfa_offset 8
>          ret
>          .cfi_endproc
> 
> Thoughts ?
> 

Didn't see problems when I tested it before applying it to
linux-kselftest next.

I have gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

thanks,
-- Shuah
Mathieu Desnoyers April 19, 2019, 2:40 p.m. UTC | #7
----- On Apr 19, 2019, at 10:17 AM, shuah shuah@kernel.org wrote:

> On 4/19/19 7:48 AM, Mathieu Desnoyers wrote:
>> ----- On Apr 19, 2019, at 9:42 AM, Mathieu Desnoyers
>> mathieu.desnoyers@efficios.com wrote:
>> 
>>> ----- On Apr 19, 2019, at 8:55 AM, Mathieu Desnoyers
>>> mathieu.desnoyers@efficios.com wrote:
>>>
>>>> ----- On Apr 19, 2019, at 8:41 AM, Mathieu Desnoyers
>>>> mathieu.desnoyers@efficios.com wrote:
>>>>
>>>>> ----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:
>>>>>
>>>>>> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>>>>>>
>>>>>>> On smaller systems, running a test with 200 threads can take a long
>>>>>>> time on machines with smaller number of CPUs.
>>>>>>>
>>>>>>> Detect the number of online cpus at test runtime, and multiply that
>>>>>>> by 6 to have 6 rseq threads per cpu preempting each other.
>>>>>>>
>>>>>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>>>>>> Cc: Shuah Khan <shuah@kernel.org>
>>>>>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>>>>>> Cc: Joel Fernandes <joelaf@google.com>
>>>>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>>>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>>>>>> Cc: Dave Watson <davejwatson@fb.com>
>>>>>>> Cc: Will Deacon <will.deacon@arm.com>
>>>>>>> Cc: Andi Kleen <andi@firstfloor.org>
>>>>>>> Cc: linux-kselftest@vger.kernel.org
>>>>>>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>>>>>>> Cc: Chris Lameter <cl@linux.com>
>>>>>>> Cc: Russell King <linux@arm.linux.org.uk>
>>>>>>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>>>>>>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>>>>>>> Cc: Paul Turner <pjt@google.com>
>>>>>>> Cc: Boqun Feng <boqun.feng@gmail.com>
>>>>>>> Cc: Josh Triplett <josh@joshtriplett.org>
>>>>>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>>>>>> Cc: Ben Maurer <bmaurer@fb.com>
>>>>>>> Cc: Andy Lutomirski <luto@amacapital.net>
>>>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>>>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>>>>>>> ---
>>>>>>>   tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>>>>>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>> b/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>> index 3acd6d75ff9f..e426304fd4a0 100755
>>>>>>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>> @@ -1,6 +1,8 @@
>>>>>>>   #!/bin/bash
>>>>>>>   # SPDX-License-Identifier: GPL-2.0+ or MIT
>>>>>>>   
>>>>>>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>>>>>>> +
>>>>>>>   EXTRA_ARGS=${@}
>>>>>>>   
>>>>>>>   OLDIFS="$IFS"
>>>>>>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>>>>>>   
>>>>>>>   REPS=1000
>>>>>>>   SLOW_REPS=100
>>>>>>> +NR_THREADS=$((6*${NR_CPUS}))
>>>>>>>   
>>>>>>>   function do_tests()
>>>>>>>   {
>>>>>>>   	local i=0
>>>>>>>   	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>>>>>>   		echo "Running test ${TEST_NAME[$i]}"
>>>>>>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>>>>>>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>>>>>>> || exit 1
>>>>>>>   		echo "Running compare-twice test ${TEST_NAME[$i]}"
>>>>>>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>>>>>>> exit 1
>>>>>>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>>>>>>> ${EXTRA_ARGS} || exit 1
>>>>>>>   		let "i++"
>>>>>>>   	done
>>>>>>>   }
>>>>>>
>>>>>> BTW., when trying to build the rseq self-tests I get this build failure:
>>>>>>
>>>>>>   dagon:~/tip/tools/testing/selftests/rseq> make
>>>>>>   gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>>>>>>   -fPIC rseq.c -lpthread -o
>>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>>>>>>   gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>>>>>>   -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>>>>>>   gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>>>>>>   basic_percpu_ops_test.c -lpthread -lrseq -o
>>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>>>>>>   reference to `.L8'
>>>>>>   /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>>>>>>   undefined reference to `.L49'
>>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>>>>>>   reference to `.L57'
>>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>>>>>>   `.L49'
>>>>>>   /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>>>>>>   `.L55'
>>>>>>   collect2: error: ld returned 1 exit status
>>>>>>   make: *** [Makefile:22:
>>>>>>   /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
>>>>>>
>>>>>> Is this a known problem, or do I miss something from my build environment
>>>>>> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).
>>>>>
>>>>> It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
>>>>> but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
>>>>> (experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).
>>>>>
>>>>> Thanks for reporting! I will investigate.
>>>>
>>>> It looks like gcc-8 optimize away the target of asm goto labels when
>>>> there are more than one of them on x86-64. I'll try to come up with
>>>> a simpler reproducer.
>>>
>>> It appears to be related to gcc-8 mishandling combination of
>>> asm goto and thread-local storage input operands on x86-64.
>>> Here is a simple reproducer:
>>>
>>> __thread int var;
>>>   
>>> static int fct(void)
>>> {
>>>         asm goto (      "jmp %l[testlabel]\n\t"
>>>                         : : [var] "m" (var) : : testlabel);
>>>         return 0;
>>> testlabel:
>> 
>> FWIW, if I add an empty
>> 
>>     asm volatile ("");
>> 
>> here after the label, gcc-8 -O2 builds "something" which is
>> a bogus assembler (an endless loop) :
>> 
>> main:
>> .LFB24:
>>          .cfi_startproc
>> .L2:
>>          subq    $8, %rsp
>>          .cfi_def_cfa_offset 16
>> #APP
>> # 6 "test-asm-goto.c" 1
>>          jmp .L2
>> 
>> # 0 "" 2
>> #NO_APP
>>          movl    %fs:var@tpoff, %edx
>>          leaq    .LC0(%rip), %rsi
>>          movl    $1, %edi
>>          xorl    %eax, %eax
>>          call    __printf_chk@PLT
>>          xorl    %eax, %eax
>>          addq    $8, %rsp
>>          .cfi_def_cfa_offset 8
>>          ret
>>          .cfi_endproc
>> 
>> Thoughts ?
>> 
> 
> Didn't see problems when I tested it before applying it to
> linux-kselftest next.
> 
> I have gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

It really appears to be an optimization bug in gcc-8. Considering that
bogus compilers are released in the wild, we can hardly justify using
the compiler feature that triggers the bogus behavior, even if it gets
fixed in the future.

I've prepared a patch that changes the way the __rseq_abi fields are
passed to the inline asm. I pass the address of the __rseq_abi TLS
as a register input operand rather than each individual field as "m"
operand.

I will submit it in a separate thread.

By the way, it affects both x86-32 (building with gcc-8 -m32) and x86-64.

Thanks,

Mathieu
shuah April 19, 2019, 6:57 p.m. UTC | #8
On 4/19/19 8:40 AM, Mathieu Desnoyers wrote:
> ----- On Apr 19, 2019, at 10:17 AM, shuah shuah@kernel.org wrote:
> 
>> On 4/19/19 7:48 AM, Mathieu Desnoyers wrote:
>>> ----- On Apr 19, 2019, at 9:42 AM, Mathieu Desnoyers
>>> mathieu.desnoyers@efficios.com wrote:
>>>
>>>> ----- On Apr 19, 2019, at 8:55 AM, Mathieu Desnoyers
>>>> mathieu.desnoyers@efficios.com wrote:
>>>>
>>>>> ----- On Apr 19, 2019, at 8:41 AM, Mathieu Desnoyers
>>>>> mathieu.desnoyers@efficios.com wrote:
>>>>>
>>>>>> ----- On Apr 19, 2019, at 6:38 AM, Ingo Molnar mingo@kernel.org wrote:
>>>>>>
>>>>>>> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>>>>>>>
>>>>>>>> On smaller systems, running a test with 200 threads can take a long
>>>>>>>> time on machines with smaller number of CPUs.
>>>>>>>>
>>>>>>>> Detect the number of online cpus at test runtime, and multiply that
>>>>>>>> by 6 to have 6 rseq threads per cpu preempting each other.
>>>>>>>>
>>>>>>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>>>>>>> Cc: Shuah Khan <shuah@kernel.org>
>>>>>>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>>>>>>> Cc: Joel Fernandes <joelaf@google.com>
>>>>>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>>>>>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>>>>>>>> Cc: Dave Watson <davejwatson@fb.com>
>>>>>>>> Cc: Will Deacon <will.deacon@arm.com>
>>>>>>>> Cc: Andi Kleen <andi@firstfloor.org>
>>>>>>>> Cc: linux-kselftest@vger.kernel.org
>>>>>>>> Cc: "H . Peter Anvin" <hpa@zytor.com>
>>>>>>>> Cc: Chris Lameter <cl@linux.com>
>>>>>>>> Cc: Russell King <linux@arm.linux.org.uk>
>>>>>>>> Cc: Michael Kerrisk <mtk.manpages@gmail.com>
>>>>>>>> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
>>>>>>>> Cc: Paul Turner <pjt@google.com>
>>>>>>>> Cc: Boqun Feng <boqun.feng@gmail.com>
>>>>>>>> Cc: Josh Triplett <josh@joshtriplett.org>
>>>>>>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>>>>>>> Cc: Ben Maurer <bmaurer@fb.com>
>>>>>>>> Cc: Andy Lutomirski <luto@amacapital.net>
>>>>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>>>>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>>>>>>>> ---
>>>>>>>>    tools/testing/selftests/rseq/run_param_test.sh | 7 +++++--
>>>>>>>>    1 file changed, 5 insertions(+), 2 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>>> b/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>>> index 3acd6d75ff9f..e426304fd4a0 100755
>>>>>>>> --- a/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>>> +++ b/tools/testing/selftests/rseq/run_param_test.sh
>>>>>>>> @@ -1,6 +1,8 @@
>>>>>>>>    #!/bin/bash
>>>>>>>>    # SPDX-License-Identifier: GPL-2.0+ or MIT
>>>>>>>>    
>>>>>>>> +NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
>>>>>>>> +
>>>>>>>>    EXTRA_ARGS=${@}
>>>>>>>>    
>>>>>>>>    OLDIFS="$IFS"
>>>>>>>> @@ -28,15 +30,16 @@ IFS="$OLDIFS"
>>>>>>>>    
>>>>>>>>    REPS=1000
>>>>>>>>    SLOW_REPS=100
>>>>>>>> +NR_THREADS=$((6*${NR_CPUS}))
>>>>>>>>    
>>>>>>>>    function do_tests()
>>>>>>>>    {
>>>>>>>>    	local i=0
>>>>>>>>    	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
>>>>>>>>    		echo "Running test ${TEST_NAME[$i]}"
>>>>>>>> -		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
>>>>>>>> +		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS}
>>>>>>>> || exit 1
>>>>>>>>    		echo "Running compare-twice test ${TEST_NAME[$i]}"
>>>>>>>> -		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} ||
>>>>>>>> exit 1
>>>>>>>> +		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@}
>>>>>>>> ${EXTRA_ARGS} || exit 1
>>>>>>>>    		let "i++"
>>>>>>>>    	done
>>>>>>>>    }
>>>>>>>
>>>>>>> BTW., when trying to build the rseq self-tests I get this build failure:
>>>>>>>
>>>>>>>    dagon:~/tip/tools/testing/selftests/rseq> make
>>>>>>>    gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared
>>>>>>>    -fPIC rseq.c -lpthread -o
>>>>>>>    /home/mingo/tip/tools/testing/selftests/rseq/librseq.so
>>>>>>>    gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c
>>>>>>>    -lpthread -lrseq -o /home/mingo/tip/tools/testing/selftests/rseq/basic_test
>>>>>>>    gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./
>>>>>>>    basic_percpu_ops_test.c -lpthread -lrseq -o
>>>>>>>    /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test
>>>>>>>    /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpeqv_storev':
>>>>>>>    /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84: undefined
>>>>>>>    reference to `.L8'
>>>>>>>    /usr/bin/ld: /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:84:
>>>>>>>    undefined reference to `.L49'
>>>>>>>    /usr/bin/ld: /tmp/ccuHTWnZ.o: in function `rseq_cmpnev_storeoffp_load':
>>>>>>>    /home/mingo/tip/tools/testing/selftests/rseq/./rseq-x86.h:141: undefined
>>>>>>>    reference to `.L57'
>>>>>>>    /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x8): undefined reference to `.L8'
>>>>>>>    /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x14): undefined reference to
>>>>>>>    `.L49'
>>>>>>>    /usr/bin/ld: /tmp/ccuHTWnZ.o:(__rseq_failure+0x20): undefined reference to
>>>>>>>    `.L55'
>>>>>>>    collect2: error: ld returned 1 exit status
>>>>>>>    make: *** [Makefile:22:
>>>>>>>    /home/mingo/tip/tools/testing/selftests/rseq/basic_percpu_ops_test] Error 1
>>>>>>>
>>>>>>> Is this a known problem, or do I miss something from my build environment
>>>>>>> perhaps? Vanilla 64-bit Ubuntu 18.10 (Cosmic).
>>>>>>
>>>>>> It works fine with gcc-7 (gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3))
>>>>>> but indeed I get the same failure with gcc-8 (gcc version 8.0.1 20180414
>>>>>> (experimental) [trunk revision 259383] (Ubuntu 8-20180414-1ubuntu2)).
>>>>>>
>>>>>> Thanks for reporting! I will investigate.
>>>>>
>>>>> It looks like gcc-8 optimize away the target of asm goto labels when
>>>>> there are more than one of them on x86-64. I'll try to come up with
>>>>> a simpler reproducer.
>>>>
>>>> It appears to be related to gcc-8 mishandling combination of
>>>> asm goto and thread-local storage input operands on x86-64.
>>>> Here is a simple reproducer:
>>>>
>>>> __thread int var;
>>>>    
>>>> static int fct(void)
>>>> {
>>>>          asm goto (      "jmp %l[testlabel]\n\t"
>>>>                          : : [var] "m" (var) : : testlabel);
>>>>          return 0;
>>>> testlabel:
>>>
>>> FWIW, if I add an empty
>>>
>>>      asm volatile ("");
>>>
>>> here after the label, gcc-8 -O2 builds "something" which is
>>> a bogus assembler (an endless loop) :
>>>
>>> main:
>>> .LFB24:
>>>           .cfi_startproc
>>> .L2:
>>>           subq    $8, %rsp
>>>           .cfi_def_cfa_offset 16
>>> #APP
>>> # 6 "test-asm-goto.c" 1
>>>           jmp .L2
>>>
>>> # 0 "" 2
>>> #NO_APP
>>>           movl    %fs:var@tpoff, %edx
>>>           leaq    .LC0(%rip), %rsi
>>>           movl    $1, %edi
>>>           xorl    %eax, %eax
>>>           call    __printf_chk@PLT
>>>           xorl    %eax, %eax
>>>           addq    $8, %rsp
>>>           .cfi_def_cfa_offset 8
>>>           ret
>>>           .cfi_endproc
>>>
>>> Thoughts ?
>>>
>>
>> Didn't see problems when I tested it before applying it to
>> linux-kselftest next.
>>
>> I have gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
> 
> It really appears to be an optimization bug in gcc-8. Considering that
> bogus compilers are released in the wild, we can hardly justify using
> the compiler feature that triggers the bogus behavior, even if it gets
> fixed in the future.
> 
> I've prepared a patch that changes the way the __rseq_abi fields are
> passed to the inline asm. I pass the address of the __rseq_abi TLS
> as a register input operand rather than each individual field as "m"
> operand.
> 
> I will submit it in a separate thread.
> 
> By the way, it affects both x86-32 (building with gcc-8 -m32) and x86-64.
> 

Should I drop this patch that is currently in linux-kseltest next? Just
confirming if your new patch is supposed to be applied on top of this
one or not?

thanks,
-- Shuah
Mathieu Desnoyers April 19, 2019, 8:59 p.m. UTC | #9
----- On Apr 19, 2019, at 2:57 PM, shuah shuah@kernel.org wrote:
[...]
> Should I drop this patch that is currently in linux-kseltest next? Just
> confirming if your new patch is supposed to be applied on top of this
> one or not?

We should keep this patch in linux-kselftest next. The fix applies on top
of it.

Thanks,

Mathieu
shuah April 19, 2019, 9:03 p.m. UTC | #10
On 4/19/19 2:59 PM, Mathieu Desnoyers wrote:
> ----- On Apr 19, 2019, at 2:57 PM, shuah shuah@kernel.org wrote:
> [...]
>> Should I drop this patch that is currently in linux-kseltest next? Just
>> confirming if your new patch is supposed to be applied on top of this
>> one or not?
> 
> We should keep this patch in linux-kselftest next. The fix applies on top
> of it.
> 

Will do. Thanks for a quick response.

-- Shuah

Patch
diff mbox series

diff --git a/tools/testing/selftests/rseq/run_param_test.sh b/tools/testing/selftests/rseq/run_param_test.sh
index 3acd6d75ff9f..e426304fd4a0 100755
--- a/tools/testing/selftests/rseq/run_param_test.sh
+++ b/tools/testing/selftests/rseq/run_param_test.sh
@@ -1,6 +1,8 @@ 
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+ or MIT
 
+NR_CPUS=`grep '^processor' /proc/cpuinfo | wc -l`
+
 EXTRA_ARGS=${@}
 
 OLDIFS="$IFS"
@@ -28,15 +30,16 @@  IFS="$OLDIFS"
 
 REPS=1000
 SLOW_REPS=100
+NR_THREADS=$((6*${NR_CPUS}))
 
 function do_tests()
 {
 	local i=0
 	while [ "$i" -lt "${#TEST_LIST[@]}" ]; do
 		echo "Running test ${TEST_NAME[$i]}"
-		./param_test ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
+		./param_test ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
 		echo "Running compare-twice test ${TEST_NAME[$i]}"
-		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} ${@} ${EXTRA_ARGS} || exit 1
+		./param_test_compare_twice ${TEST_LIST[$i]} -r ${REPS} -t ${NR_THREADS} ${@} ${EXTRA_ARGS} || exit 1
 		let "i++"
 	done
 }