linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fixes for selftest tm-unavailable
@ 2018-03-05 20:48 Gustavo Romero
  2018-03-05 20:48 ` [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled Gustavo Romero
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Romero @ 2018-03-05 20:48 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: gromero, mpe, cyrilbur

The recent fix by mpe for tm-trap [1] (thanks for fixing it! really
sorry for the late reply, I got dragged away by the darn thingy)
caught my attention to the fact that tm-unavailable needs a similar
fix. Also before that on Feb. Cyril Bur proposed another small fix for
the same selftest [2]. Since Cyril's change is not merged yet I
decided to take Cyril's fix into account as well. Finally, I also
noted that tm-unavailable is not using the test harness, thus I
added it to tm-unavailable.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=192b2e742c06af399e8eecb4a17265
[2] https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-February/169111.html

Gustavo Romero (1):
  selftests/powerpc: Skip tm-unavailable if TM is not enabled

 .../testing/selftests/powerpc/tm/tm-unavailable.c  | 24 ++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

-- 
2.7.4

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

* [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled
  2018-03-05 20:48 [PATCH] Fixes for selftest tm-unavailable Gustavo Romero
@ 2018-03-05 20:48 ` Gustavo Romero
  2018-03-05 23:49   ` Cyril Bur
  2018-03-14  9:28   ` Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Gustavo Romero @ 2018-03-05 20:48 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: gromero, mpe, cyrilbur

Some processor revisions do not support transactional memory, and
additionally kernel support can be disabled. In either case the
tm-unavailable test should be skipped, otherwise it will fail with
a SIGILL.

That commit also sets this selftest to be called through the test
harness as it's done for other TM selftests.

Finally, it avoids using "ping" as a thread name since it's
ambiguous and can be confusing when shown, for instance,
in a kernel backtrace log.

Fixes: 77fad8bfb1d2 ("selftests/powerpc: Check FP/VEC on exception in TM")
Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
---
 .../testing/selftests/powerpc/tm/tm-unavailable.c  | 24 ++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/powerpc/tm/tm-unavailable.c b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
index e6a0fad..156c8e7 100644
--- a/tools/testing/selftests/powerpc/tm/tm-unavailable.c
+++ b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
@@ -80,7 +80,7 @@ bool is_failure(uint64_t condition_reg)
 	return ((condition_reg >> 28) & 0xa) == 0xa;
 }
 
-void *ping(void *input)
+void *tm_una_ping(void *input)
 {
 
 	/*
@@ -280,7 +280,7 @@ void *ping(void *input)
 }
 
 /* Thread to force context switch */
-void *pong(void *not_used)
+void *tm_una_pong(void *not_used)
 {
 	/* Wait thread get its name "pong". */
 	if (DEBUG)
@@ -311,11 +311,11 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
 	do {
 		int rc;
 
-		/* Bind 'ping' to CPU 0, as specified in 'attr'. */
-		rc = pthread_create(&t0, attr, ping, (void *) &flags);
+		/* Bind to CPU 0, as specified in 'attr'. */
+		rc = pthread_create(&t0, attr, tm_una_ping, (void *) &flags);
 		if (rc)
 			pr_err(rc, "pthread_create()");
-		rc = pthread_setname_np(t0, "ping");
+		rc = pthread_setname_np(t0, "tm_una_ping");
 		if (rc)
 			pr_warn(rc, "pthread_setname_np");
 		rc = pthread_join(t0, &ret_value);
@@ -333,13 +333,15 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
 	}
 }
 
-int main(int argc, char **argv)
+int tm_unavailable_test(void)
 {
 	int rc, exception; /* FP = 0, VEC = 1, VSX = 2 */
 	pthread_t t1;
 	pthread_attr_t attr;
 	cpu_set_t cpuset;
 
+	SKIP_IF(!have_htm());
+
 	/* Set only CPU 0 in the mask. Both threads will be bound to CPU 0. */
 	CPU_ZERO(&cpuset);
 	CPU_SET(0, &cpuset);
@@ -354,12 +356,12 @@ int main(int argc, char **argv)
 	if (rc)
 		pr_err(rc, "pthread_attr_setaffinity_np()");
 
-	rc = pthread_create(&t1, &attr /* Bind 'pong' to CPU 0 */, pong, NULL);
+	rc = pthread_create(&t1, &attr /* Bind to CPU 0 */, tm_una_pong, NULL);
 	if (rc)
 		pr_err(rc, "pthread_create()");
 
 	/* Name it for systemtap convenience */
-	rc = pthread_setname_np(t1, "pong");
+	rc = pthread_setname_np(t1, "tm_una_pong");
 	if (rc)
 		pr_warn(rc, "pthread_create()");
 
@@ -394,3 +396,9 @@ int main(int argc, char **argv)
 		exit(0);
 	}
 }
+
+int main(int argc, char **argv)
+{
+	test_harness_set_timeout(220);
+	return test_harness(tm_unavailable_test, "tm_unavailable_test");
+}
-- 
2.7.4

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

* Re: [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled
  2018-03-05 20:48 ` [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled Gustavo Romero
@ 2018-03-05 23:49   ` Cyril Bur
  2018-03-06 20:24     ` Gustavo Romero
  2018-03-14  9:28   ` Michael Ellerman
  1 sibling, 1 reply; 5+ messages in thread
From: Cyril Bur @ 2018-03-05 23:49 UTC (permalink / raw)
  To: Gustavo Romero, linuxppc-dev

On Mon, 2018-03-05 at 15:48 -0500, Gustavo Romero wrote:
> Some processor revisions do not support transactional memory, and
> additionally kernel support can be disabled. In either case the
> tm-unavailable test should be skipped, otherwise it will fail with
> a SIGILL.
> 
> That commit also sets this selftest to be called through the test
> harness as it's done for other TM selftests.
> 
> Finally, it avoids using "ping" as a thread name since it's
> ambiguous and can be confusing when shown, for instance,
> in a kernel backtrace log.
> 

I spent more time than I care to admit looking at backtraces wondering
how "ping" got in the mix ;).


> Fixes: 77fad8bfb1d2 ("selftests/powerpc: Check FP/VEC on exception in TM")
> Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>

Reviewed-by: Cyril Bur <cyrilbur@gmail.com>

> ---
>  .../testing/selftests/powerpc/tm/tm-unavailable.c  | 24 ++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/powerpc/tm/tm-unavailable.c b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
> index e6a0fad..156c8e7 100644
> --- a/tools/testing/selftests/powerpc/tm/tm-unavailable.c
> +++ b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
> @@ -80,7 +80,7 @@ bool is_failure(uint64_t condition_reg)
>  	return ((condition_reg >> 28) & 0xa) == 0xa;
>  }
>  
> -void *ping(void *input)
> +void *tm_una_ping(void *input)
>  {
>  
>  	/*
> @@ -280,7 +280,7 @@ void *ping(void *input)
>  }
>  
>  /* Thread to force context switch */
> -void *pong(void *not_used)
> +void *tm_una_pong(void *not_used)
>  {
>  	/* Wait thread get its name "pong". */
>  	if (DEBUG)
> @@ -311,11 +311,11 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
>  	do {
>  		int rc;
>  
> -		/* Bind 'ping' to CPU 0, as specified in 'attr'. */
> -		rc = pthread_create(&t0, attr, ping, (void *) &flags);
> +		/* Bind to CPU 0, as specified in 'attr'. */
> +		rc = pthread_create(&t0, attr, tm_una_ping, (void *) &flags);
>  		if (rc)
>  			pr_err(rc, "pthread_create()");
> -		rc = pthread_setname_np(t0, "ping");
> +		rc = pthread_setname_np(t0, "tm_una_ping");
>  		if (rc)
>  			pr_warn(rc, "pthread_setname_np");
>  		rc = pthread_join(t0, &ret_value);
> @@ -333,13 +333,15 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
>  	}
>  }
>  
> -int main(int argc, char **argv)
> +int tm_unavailable_test(void)
>  {
>  	int rc, exception; /* FP = 0, VEC = 1, VSX = 2 */
>  	pthread_t t1;
>  	pthread_attr_t attr;
>  	cpu_set_t cpuset;
>  
> +	SKIP_IF(!have_htm());
> +
>  	/* Set only CPU 0 in the mask. Both threads will be bound to CPU 0. */
>  	CPU_ZERO(&cpuset);
>  	CPU_SET(0, &cpuset);
> @@ -354,12 +356,12 @@ int main(int argc, char **argv)
>  	if (rc)
>  		pr_err(rc, "pthread_attr_setaffinity_np()");
>  
> -	rc = pthread_create(&t1, &attr /* Bind 'pong' to CPU 0 */, pong, NULL);
> +	rc = pthread_create(&t1, &attr /* Bind to CPU 0 */, tm_una_pong, NULL);
>  	if (rc)
>  		pr_err(rc, "pthread_create()");
>  
>  	/* Name it for systemtap convenience */
> -	rc = pthread_setname_np(t1, "pong");
> +	rc = pthread_setname_np(t1, "tm_una_pong");
>  	if (rc)
>  		pr_warn(rc, "pthread_create()");
>  
> @@ -394,3 +396,9 @@ int main(int argc, char **argv)
>  		exit(0);
>  	}
>  }
> +
> +int main(int argc, char **argv)
> +{
> +	test_harness_set_timeout(220);
> +	return test_harness(tm_unavailable_test, "tm_unavailable_test");
> +}

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

* Re: [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled
  2018-03-05 23:49   ` Cyril Bur
@ 2018-03-06 20:24     ` Gustavo Romero
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo Romero @ 2018-03-06 20:24 UTC (permalink / raw)
  To: Cyril Bur, linuxppc-dev

Hi Cyril,

On 03/05/2018 08:49 PM, Cyril Bur wrote:
> On Mon, 2018-03-05 at 15:48 -0500, Gustavo Romero wrote:
>> Some processor revisions do not support transactional memory, and
>> additionally kernel support can be disabled. In either case the
>> tm-unavailable test should be skipped, otherwise it will fail with
>> a SIGILL.
>>
>> That commit also sets this selftest to be called through the test
>> harness as it's done for other TM selftests.
>>
>> Finally, it avoids using "ping" as a thread name since it's
>> ambiguous and can be confusing when shown, for instance,
>> in a kernel backtrace log.
>>
> 
> I spent more time than I care to admit looking at backtraces wondering
> how "ping" got in the mix ;).

heh sorry about that... :)


>> Fixes: 77fad8bfb1d2 ("selftests/powerpc: Check FP/VEC on exception in TM")
>> Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
> 
> Reviewed-by: Cyril Bur <cyrilbur@gmail.com>

Thanks for reviewing it.


Cheers,
Gustavo

>> ---
>>  .../testing/selftests/powerpc/tm/tm-unavailable.c  | 24 ++++++++++++++--------
>>  1 file changed, 16 insertions(+), 8 deletions(-)
>>
>> diff --git a/tools/testing/selftests/powerpc/tm/tm-unavailable.c b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
>> index e6a0fad..156c8e7 100644
>> --- a/tools/testing/selftests/powerpc/tm/tm-unavailable.c
>> +++ b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
>> @@ -80,7 +80,7 @@ bool is_failure(uint64_t condition_reg)
>>  	return ((condition_reg >> 28) & 0xa) == 0xa;
>>  }
>>  
>> -void *ping(void *input)
>> +void *tm_una_ping(void *input)
>>  {
>>  
>>  	/*
>> @@ -280,7 +280,7 @@ void *ping(void *input)
>>  }
>>  
>>  /* Thread to force context switch */
>> -void *pong(void *not_used)
>> +void *tm_una_pong(void *not_used)
>>  {
>>  	/* Wait thread get its name "pong". */
>>  	if (DEBUG)
>> @@ -311,11 +311,11 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
>>  	do {
>>  		int rc;
>>  
>> -		/* Bind 'ping' to CPU 0, as specified in 'attr'. */
>> -		rc = pthread_create(&t0, attr, ping, (void *) &flags);
>> +		/* Bind to CPU 0, as specified in 'attr'. */
>> +		rc = pthread_create(&t0, attr, tm_una_ping, (void *) &flags);
>>  		if (rc)
>>  			pr_err(rc, "pthread_create()");
>> -		rc = pthread_setname_np(t0, "ping");
>> +		rc = pthread_setname_np(t0, "tm_una_ping");
>>  		if (rc)
>>  			pr_warn(rc, "pthread_setname_np");
>>  		rc = pthread_join(t0, &ret_value);
>> @@ -333,13 +333,15 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
>>  	}
>>  }
>>  
>> -int main(int argc, char **argv)
>> +int tm_unavailable_test(void)
>>  {
>>  	int rc, exception; /* FP = 0, VEC = 1, VSX = 2 */
>>  	pthread_t t1;
>>  	pthread_attr_t attr;
>>  	cpu_set_t cpuset;
>>  
>> +	SKIP_IF(!have_htm());
>> +
>>  	/* Set only CPU 0 in the mask. Both threads will be bound to CPU 0. */
>>  	CPU_ZERO(&cpuset);
>>  	CPU_SET(0, &cpuset);
>> @@ -354,12 +356,12 @@ int main(int argc, char **argv)
>>  	if (rc)
>>  		pr_err(rc, "pthread_attr_setaffinity_np()");
>>  
>> -	rc = pthread_create(&t1, &attr /* Bind 'pong' to CPU 0 */, pong, NULL);
>> +	rc = pthread_create(&t1, &attr /* Bind to CPU 0 */, tm_una_pong, NULL);
>>  	if (rc)
>>  		pr_err(rc, "pthread_create()");
>>  
>>  	/* Name it for systemtap convenience */
>> -	rc = pthread_setname_np(t1, "pong");
>> +	rc = pthread_setname_np(t1, "tm_una_pong");
>>  	if (rc)
>>  		pr_warn(rc, "pthread_create()");
>>  
>> @@ -394,3 +396,9 @@ int main(int argc, char **argv)
>>  		exit(0);
>>  	}
>>  }
>> +
>> +int main(int argc, char **argv)
>> +{
>> +	test_harness_set_timeout(220);
>> +	return test_harness(tm_unavailable_test, "tm_unavailable_test");
>> +}
> 

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

* Re: selftests/powerpc: Skip tm-unavailable if TM is not enabled
  2018-03-05 20:48 ` [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled Gustavo Romero
  2018-03-05 23:49   ` Cyril Bur
@ 2018-03-14  9:28   ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2018-03-14  9:28 UTC (permalink / raw)
  To: Gustavo Romero, linuxppc-dev; +Cc: cyrilbur, gromero

On Mon, 2018-03-05 at 20:48:55 UTC, Gustavo Romero wrote:
> Some processor revisions do not support transactional memory, and
> additionally kernel support can be disabled. In either case the
> tm-unavailable test should be skipped, otherwise it will fail with
> a SIGILL.
> 
> That commit also sets this selftest to be called through the test
> harness as it's done for other TM selftests.
> 
> Finally, it avoids using "ping" as a thread name since it's
> ambiguous and can be confusing when shown, for instance,
> in a kernel backtrace log.
> 
> Fixes: 77fad8bfb1d2 ("selftests/powerpc: Check FP/VEC on exception in TM")
> Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>
> Reviewed-by: Cyril Bur <cyrilbur@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b395e55b49ecd56ea28dc629f4ca4c

cheers

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

end of thread, other threads:[~2018-03-14  9:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-05 20:48 [PATCH] Fixes for selftest tm-unavailable Gustavo Romero
2018-03-05 20:48 ` [PATCH] selftests/powerpc: Skip tm-unavailable if TM is not enabled Gustavo Romero
2018-03-05 23:49   ` Cyril Bur
2018-03-06 20:24     ` Gustavo Romero
2018-03-14  9:28   ` Michael Ellerman

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).