Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1592207imd; Sun, 4 Nov 2018 06:00:04 -0800 (PST) X-Google-Smtp-Source: AJdET5ekpCuP+TLfuduCibSdq8iKtWyGH57ePXkKj4vIvujPTcsTlKQX9yWMDk/drmR1BvmW+zpw X-Received: by 2002:a63:8742:: with SMTP id i63mr14969892pge.298.1541340004628; Sun, 04 Nov 2018 06:00:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340004; cv=none; d=google.com; s=arc-20160816; b=Yt6IWRl8Nd92LcRJUr34bB5HG/NgyGXL0nIbDo24umxsRRzylKzkwAqzqbWnOCrX0o HaRvphOs6taUxON/AXvpgFTLob18WIpG9bu3Rv5UHsxVYXAYBK7NJnUtRZC47BXhZNA1 g1KmSr9ZfEH7n+amohppANE+DqCHJ8bmUc7SkJqSuaAqhse8UBWlttrdFgnWf1V1DfAW OS64t8KMS45o8X9ExyOqdR0M3peF6WKC/q4TZ6YpTQwKVrS4f44//Dm9trUZaLvaXuMw Cpxg6OkBAqkMvJ1ZjvEje1nslLsO/x/AupWQG+xNg8yM1ltjoB8i4/i4iMgzrWF/iB1K 76KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=/l/FZxRFnEwwcN+VXeJ+sN8zHN66xgvwd2BgpbbSn/I=; b=qWGz96hb8w6ACS0TqILK5MUL4S4XFxw2jafH97km3HBkc2NQQcmrRHAEE3OKdBorzC BgrqAQEjI7CUH8LHjAqOQRIGXt3wlK1frPXBzsVMUnWmtcnZH2uh17CqNeo4Yz3ffzOm 6PYn93zmF+A8ewRpuQ0iwzoq16CYIavQzAzq3+JyH6nSQRbhnrNOELWfq+vnjO8rVR3B C6+Z74jtPjwAZttDyjN8Naup7VC2j2BO6fD5Xq2QuoO/ufI28kAZxOG7wCY4IfoMsCHk N4hbfPeDEQct5+D/7Bpdp9G8FTNjlojtWQbVYPU39zKy6fKjdKqQ/yTsCCF9050jOXkd ZXrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HUYAhNgl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si17046897plg.300.2018.11.04.05.59.50; Sun, 04 Nov 2018 06:00:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HUYAhNgl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbeKDXI7 (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:48226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731387AbeKDXI5 (ORCPT ); Sun, 4 Nov 2018 18:08:57 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 58EA220870; Sun, 4 Nov 2018 13:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339632; bh=6wcQqKmpTN/0KAslgC8sMtn+EH0X3bqFgwJSJ4Ikd5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HUYAhNglK+V0ac4i30anpUq0HRcHs6ecuhceqTASJfKrXpKTFXwb1IL+CXdTAAL77 hZtuCgsazZBVWPf0uyzUWd2nBO8xz4PHe8Z/FcRPN5/fhb4/0gbpUDVZdBvakgYYtZ VIC0W2M+ayktb1WsES3a22GkGSQwTm1i9JQAgfdU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Breno Leitao , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.14 27/30] powerpc/selftests: Wait all threads to join Date: Sun, 4 Nov 2018 08:53:22 -0500 Message-Id: <20181104135325.88524-27-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Breno Leitao [ Upstream commit 693b31b2fc1636f0aa7af53136d3b49f6ad9ff39 ] Test tm-tmspr might exit before all threads stop executing, because it just waits for the very last thread to join before proceeding/exiting. This patch makes sure that all threads that were created will join before proceeding/exiting. This patch also guarantees that the amount of threads being created is equal to thread_num. Signed-off-by: Breno Leitao Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- tools/testing/selftests/powerpc/tm/tm-tmspr.c | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/powerpc/tm/tm-tmspr.c b/tools/testing/selftests/powerpc/tm/tm-tmspr.c index 2bda81c7bf23..df1d7d4b1c89 100644 --- a/tools/testing/selftests/powerpc/tm/tm-tmspr.c +++ b/tools/testing/selftests/powerpc/tm/tm-tmspr.c @@ -98,7 +98,7 @@ void texasr(void *in) int test_tmspr() { - pthread_t thread; + pthread_t *thread; int thread_num; unsigned long i; @@ -107,21 +107,28 @@ int test_tmspr() /* To cause some context switching */ thread_num = 10 * sysconf(_SC_NPROCESSORS_ONLN); + thread = malloc(thread_num * sizeof(pthread_t)); + if (thread == NULL) + return EXIT_FAILURE; + /* Test TFIAR and TFHAR */ - for (i = 0 ; i < thread_num ; i += 2){ - if (pthread_create(&thread, NULL, (void*)tfiar_tfhar, (void *)i)) + for (i = 0; i < thread_num; i += 2) { + if (pthread_create(&thread[i], NULL, (void *)tfiar_tfhar, + (void *)i)) return EXIT_FAILURE; } - if (pthread_join(thread, NULL) != 0) - return EXIT_FAILURE; - /* Test TEXASR */ - for (i = 0 ; i < thread_num ; i++){ - if (pthread_create(&thread, NULL, (void*)texasr, (void *)i)) + for (i = 1; i < thread_num; i += 2) { + if (pthread_create(&thread[i], NULL, (void *)texasr, (void *)i)) return EXIT_FAILURE; } - if (pthread_join(thread, NULL) != 0) - return EXIT_FAILURE; + + for (i = 0; i < thread_num; i++) { + if (pthread_join(thread[i], NULL) != 0) + return EXIT_FAILURE; + } + + free(thread); if (passed) return 0; -- 2.17.1