All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Romero <gromero@linux.vnet.ibm.com>
To: Cyril Bur <cyrilbur@gmail.com>, linuxppc-dev@lists.ozlabs.org
Cc: leitao@debian.org
Subject: Re: [PATCH 1/2] selftests/powerpc: Check for pthread errors in tm-unavailable
Date: Tue, 21 Nov 2017 10:56:08 -0200	[thread overview]
Message-ID: <5A142268.1030303@linux.vnet.ibm.com> (raw)
In-Reply-To: <20171121071720.24619-1-cyrilbur@gmail.com>

Hi Cyril,

Thanks for adding the checks!

On 21-11-2017 05:17, Cyril Bur wrote:
> Signed-off-by: Cyril Bur <cyrilbur@gmail.com>

Signed-off-by: Gustavo Romero <gromero@linux.vnet.ibm.com>

Cheers,
Gustavo

> ---
>  .../testing/selftests/powerpc/tm/tm-unavailable.c  | 43 +++++++++++++++++-----
>  1 file changed, 34 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/powerpc/tm/tm-unavailable.c b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
> index 96c37f84ce54..e6a0fad2bfd0 100644
> --- a/tools/testing/selftests/powerpc/tm/tm-unavailable.c
> +++ b/tools/testing/selftests/powerpc/tm/tm-unavailable.c
> @@ -15,6 +15,7 @@
>   */
> 
>  #define _GNU_SOURCE
> +#include <error.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <unistd.h>
> @@ -33,6 +34,11 @@
>  #define VSX_UNA_EXCEPTION	2
> 
>  #define NUM_EXCEPTIONS		3
> +#define err_at_line(status, errnum, format, ...) \
> +	error_at_line(status, errnum,  __FILE__, __LINE__, format ##__VA_ARGS__)
> +
> +#define pr_warn(code, format, ...) err_at_line(0, code, format, ##__VA_ARGS__)
> +#define pr_err(code, format, ...) err_at_line(1, code, format, ##__VA_ARGS__)
> 
>  struct Flags {
>  	int touch_fp;
> @@ -303,10 +309,19 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
>  	 * checking if the failure cause is the one we expect.
>  	 */
>  	do {
> +		int rc;
> +
>  		/* Bind 'ping' to CPU 0, as specified in 'attr'. */
> -		pthread_create(&t0, attr, ping, (void *) &flags);
> -		pthread_setname_np(t0, "ping");
> -		pthread_join(t0, &ret_value);
> +		rc = pthread_create(&t0, attr, ping, (void *) &flags);
> +		if (rc)
> +			pr_err(rc, "pthread_create()");
> +		rc = pthread_setname_np(t0, "ping");
> +		if (rc)
> +			pr_warn(rc, "pthread_setname_np");
> +		rc = pthread_join(t0, &ret_value);
> +		if (rc)
> +			pr_err(rc, "pthread_join");
> +
>  		retries--;
>  	} while (ret_value != NULL && retries);
> 
> @@ -320,7 +335,7 @@ void test_fp_vec(int fp, int vec, pthread_attr_t *attr)
> 
>  int main(int argc, char **argv)
>  {
> -	int exception; /* FP = 0, VEC = 1, VSX = 2 */
> +	int rc, exception; /* FP = 0, VEC = 1, VSX = 2 */
>  	pthread_t t1;
>  	pthread_attr_t attr;
>  	cpu_set_t cpuset;
> @@ -330,13 +345,23 @@ int main(int argc, char **argv)
>  	CPU_SET(0, &cpuset);
> 
>  	/* Init pthread attribute. */
> -	pthread_attr_init(&attr);
> +	rc = pthread_attr_init(&attr);
> +	if (rc)
> +		pr_err(rc, "pthread_attr_init()");
> 
>  	/* Set CPU 0 mask into the pthread attribute. */
> -	pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
> -
> -	pthread_create(&t1, &attr /* Bind 'pong' to CPU 0 */, pong, NULL);
> -	pthread_setname_np(t1, "pong"); /* Name it for systemtap convenience */
> +	rc = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
> +	if (rc)
> +		pr_err(rc, "pthread_attr_setaffinity_np()");
> +
> +	rc = pthread_create(&t1, &attr /* Bind 'pong' to CPU 0 */, pong, NULL);
> +	if (rc)
> +		pr_err(rc, "pthread_create()");
> +
> +	/* Name it for systemtap convenience */
> +	rc = pthread_setname_np(t1, "pong");
> +	if (rc)
> +		pr_warn(rc, "pthread_create()");
> 
>  	flags.result = 0;
> 

  parent reply	other threads:[~2017-11-21 12:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21  7:17 [PATCH 1/2] selftests/powerpc: Check for pthread errors in tm-unavailable Cyril Bur
2017-11-21  7:17 ` [PATCH 2/2] selftests/powerpc: Calculate spin time " Cyril Bur
2017-11-21 13:31   ` Gustavo Romero
2017-11-21 23:41     ` Cyril Bur
2017-12-11  2:02       ` Michael Ellerman
2017-12-11  3:40         ` Cyril Bur
2017-11-21 12:56 ` Gustavo Romero [this message]
2017-12-12 11:39 ` [1/2] selftests/powerpc: Check for pthread errors " Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5A142268.1030303@linux.vnet.ibm.com \
    --to=gromero@linux.vnet.ibm.com \
    --cc=cyrilbur@gmail.com \
    --cc=leitao@debian.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.