From patchwork Tue Apr 23 10:55:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 1089318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44pL3K6q1Pz9sNy; Tue, 23 Apr 2019 20:56:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hIt5q-0000tW-7E; Tue, 23 Apr 2019 10:56:06 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hIt5o-0000se-4V for kernel-team@lists.ubuntu.com; Tue, 23 Apr 2019 10:56:04 +0000 Received: from mail-pf1-f199.google.com ([209.85.210.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hIt5n-00038G-Kz for kernel-team@lists.ubuntu.com; Tue, 23 Apr 2019 10:56:03 +0000 Received: by mail-pf1-f199.google.com with SMTP id g1so9511240pfo.2 for ; Tue, 23 Apr 2019 03:56:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=dx9qX+NK1hoA4sb/fMGlzMcPPGZ4dNz8bv7Hwj1cutE=; b=RpVZscDzqhfwFbiTCZ+we7gfaf/E6kCSRL+5g15b22XFYfLRQzyy8mXzmu/vataO1I Cqickt6gQjyKZmU8eNT3874sQi+7Iq0TKncda2In6WQWgrtrFgtVMQ/3uy/S0mjQYgXc Y9iinl4XxLBXuoxpw4HZfyb0Qy5q4Qd7eCFCCBwdWSBJgHhKOoBWvrgFAp9l864If5Tv 6MYbd189v5sWgD3BvbBpj2F+nt9CM47lhnub+soq2GC9+6oiXZmAcWI8XOcIEZSouKC8 K7YqW96fjPBKfAzPecn9QlO6hfypmCLt6/mUa/lrPeJvOPPA0I1JNhPyZ9A3gICnciH0 Uumg== X-Gm-Message-State: APjAAAXnFK6e4ycBL/1aMlZwpUyf9ci/U5sfDW2mo39Dg8BLdDEpu8Bx UzKcOMNqzj1YL8VimhnhXF+bXp6M/1++k/PMWgJEQqBRZHEfz8AXpQTQxab9EPL2zm5QlzJH6RZ FBoasoZWUdOuYxfiqLcZ8rQ6pH767T89K+V+vDoLK X-Received: by 2002:a63:4c45:: with SMTP id m5mr15737821pgl.78.1556016962088; Tue, 23 Apr 2019 03:56:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFe0sZZjldslf2ecsxPzYwKqzhjnv6yhSaEvtSIY+REGQHquTEeXpQtLM54mXD0+p4ei8W0A== X-Received: by 2002:a63:4c45:: with SMTP id m5mr15737809pgl.78.1556016961874; Tue, 23 Apr 2019 03:56:01 -0700 (PDT) Received: from Leggiero.taipei.internal (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id o5sm41877473pfa.135.2019.04.23.03.56.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 03:56:01 -0700 (PDT) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [B][SRU][PATCH 1/2] selftests/powerpc: Check for pthread errors in tm-unavailable Date: Tue, 23 Apr 2019 18:55:53 +0800 Message-Id: <20190423105554.21281-2-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190423105554.21281-1-po-hsu.lin@canonical.com> References: <20190423105554.21281-1-po-hsu.lin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Cyril Bur BugLink: https://bugs.launchpad.net/bugs/1813129 Signed-off-by: Cyril Bur Signed-off-by: Gustavo Romero Signed-off-by: Michael Ellerman (cherry picked from commit 5783ee6ec3d3323a04cc69764d57cac7bf026332) Signed-off-by: Po-Hsu Lin --- .../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 96c37f8..e6a0fad 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 #include #include #include @@ -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;