Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2953068imu; Mon, 19 Nov 2018 08:33:01 -0800 (PST) X-Google-Smtp-Source: AJdET5crj2+3gIPFPDzZamYRR0K4P+wSua4wsW9uPUrLqHYAMwfHrIDcemos9zcXWXVRxlnB1YTl X-Received: by 2002:a17:902:b60a:: with SMTP id b10mr21738037pls.303.1542645181122; Mon, 19 Nov 2018 08:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645181; cv=none; d=google.com; s=arc-20160816; b=kEksQlYUELYz7bx6EpFnPhfmvZOSla5bmaT+gsWb3Ia2L1v7rC4NF1ZwNDz2HcABxh eMar9fNu7uZmbALRyMrno2ZC/nlN4VzjJjyy7ov7G5fwavprTshl2WPB1BrEurzA9t61 I3QP5M9sRadkcKNT/bSIGvJ+aaNJG6sh27CqyrhJ8LzalFq1fMGl4rEgrRlFKJOrm852 trA7PrXF3RAtQE5JEgX5wioeTfu7BaSnl0YixZp43qf/czSLHC/uFsQ3tCsKuqywbFY0 bMgrUsbHmMER5QVEQSW5NJ1Q74FXkyQPWbrcVSuzYe1lesBrKcy3YAq3eBHkxGhPa+u2 JUhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U1ldD/mn2uyI3yelJi2RltAe97tm9qmxFgkKBP5uMtk=; b=gxwwO6g+clGMm1YrhVC8lzFgByIUZLcFW0sZOGkgs4tAi7u9az1i6M1JzSc/2Fcxrl FDkb0jeLcdaijILEXFYS0WM5PU5O5PXpRRqbofFUJ+SEjU8/ytDlk7LGjIgWR9Vhv1C7 C0gVrYjc08gIV9jO1KfMU0wIJt5tZdpQDD5CrsyoXL/jE0BVFJkULP4A8Ow9UsAZU0Ee EPeJhkHgQB4EgsqcwZb7zW0GqhzbbhQyrv6CkwqGT1l+BmritxDnTVUi0qE6cibC3mcV iteLfIcB9TF4Aq9tb1LqbAg4IExU9axczCs+FvJJ4tup2UxP67U12YHc5NdSF5NtHIgW TZrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dFsbo+CI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h80-v6si40708910pfj.112.2018.11.19.08.32.45; Mon, 19 Nov 2018 08:33:01 -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=dFsbo+CI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730452AbeKTCzj (ORCPT + 99 others); Mon, 19 Nov 2018 21:55:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:53436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730385AbeKTCzi (ORCPT ); Mon, 19 Nov 2018 21:55:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 80F6F20831; Mon, 19 Nov 2018 16:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645091; bh=KvSG6EsnRWa88t0kIRx8wcWlMSdpIBeGtaND74h6P1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFsbo+CIosW91L+dV2CH3uyBXA5ZMPV7qdwujcuJbluz8gf+etl84xmYv0rV//WWL TU6q8S4s7AvQamzdWMCB4A3D1ZGnNJsLWrB+A//iqrFGfWsRjNa9WGfw8/syDTD/7V r2o5PK+Xho3YQvUsYVY2nCJVHqMSOuSRXiYVNhUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Breno Leitao , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 033/205] powerpc/selftests: Wait all threads to join Date: Mon, 19 Nov 2018 17:25:40 +0100 Message-Id: <20181119162623.391128031@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/powerpc/tm/tm-tmspr.c | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) --- 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;