linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: membarrier: fix test by checking supported commands
@ 2018-07-30 16:05 Rafael David Tinoco
  2018-07-30 16:13 ` Mathieu Desnoyers
  2018-07-30 23:32 ` Shuah Khan
  0 siblings, 2 replies; 14+ messages in thread
From: Rafael David Tinoco @ 2018-07-30 16:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-kselftest, gregkh, rafael.tinoco, mathieu.desnoyers, mingo,
	peterz, tglx, shuah

Makes membarrier_test compatible with older kernels (LTS) by checking if
the membarrier features exist before running the tests.

Link: https://bugs.linaro.org/show_bug.cgi?id=3771
Signed-off-by: Rafael David Tinoco <rafael.tinoco@linaro.org>
Cc: <stable@vger.kernel.org> #v4.17
---
 .../selftests/membarrier/membarrier_test.c    | 69 +++++++++++--------
 1 file changed, 41 insertions(+), 28 deletions(-)

diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c
index 6793f8ecc8e7..b96caa096e2f 100644
--- a/tools/testing/selftests/membarrier/membarrier_test.c
+++ b/tools/testing/selftests/membarrier/membarrier_test.c
@@ -225,7 +225,14 @@ static int test_membarrier_global_expedited_success(void)
 
 static int test_membarrier(void)
 {
-	int status;
+	int supported, status;
+
+	supported = sys_membarrier(MEMBARRIER_CMD_QUERY, 0);
+	if (supported < 0) {
+		ksft_test_result_fail(
+			"sys_membarrier() failed to query supported cmds\n");
+		return supported;
+	}
 
 	status = test_membarrier_cmd_fail();
 	if (status)
@@ -236,21 +243,22 @@ static int test_membarrier(void)
 	status = test_membarrier_global_success();
 	if (status)
 		return status;
-	status = test_membarrier_private_expedited_fail();
-	if (status)
-		return status;
-	status = test_membarrier_register_private_expedited_success();
-	if (status)
-		return status;
-	status = test_membarrier_private_expedited_success();
-	if (status)
-		return status;
-	status = sys_membarrier(MEMBARRIER_CMD_QUERY, 0);
-	if (status < 0) {
-		ksft_test_result_fail("sys_membarrier() failed\n");
-		return status;
+
+	/* commit 22e4ebb975822833b083533035233d128b30e98f added this feature */
+	if (supported & MEMBARRIER_CMD_PRIVATE_EXPEDITED) {
+		status = test_membarrier_private_expedited_fail();
+		if (status)
+			return status;
+		status = test_membarrier_register_private_expedited_success();
+		if (status)
+			return status;
+		status = test_membarrier_private_expedited_success();
+		if (status)
+			return status;
 	}
-	if (status & MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE) {
+
+	/* commit 70216e18e519a54a2f13569e8caff99a092a92d6 added this feature */
+	if (supported & MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE) {
 		status = test_membarrier_private_expedited_sync_core_fail();
 		if (status)
 			return status;
@@ -261,19 +269,24 @@ static int test_membarrier(void)
 		if (status)
 			return status;
 	}
-	/*
-	 * It is valid to send a global membarrier from a non-registered
-	 * process.
-	 */
-	status = test_membarrier_global_expedited_success();
-	if (status)
-		return status;
-	status = test_membarrier_register_global_expedited_success();
-	if (status)
-		return status;
-	status = test_membarrier_global_expedited_success();
-	if (status)
-		return status;
+
+	/* commit c5f58bd58f432be5d92df33c5458e0bcbee3aadf added this feature */
+	if (supported & MEMBARRIER_CMD_GLOBAL_EXPEDITED) {
+		/*
+		 * It is valid to send a global membarrier from a non-registered
+		 * process.
+		 */
+		status = test_membarrier_global_expedited_success();
+		if (status)
+			return status;
+		status = test_membarrier_register_global_expedited_success();
+		if (status)
+			return status;
+		status = test_membarrier_global_expedited_success();
+		if (status)
+			return status;
+	}
+
 	return 0;
 }
 
-- 
2.18.0


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

end of thread, other threads:[~2018-11-18 20:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 16:05 [PATCH] selftests: membarrier: fix test by checking supported commands Rafael David Tinoco
2018-07-30 16:13 ` Mathieu Desnoyers
2018-07-30 23:32 ` Shuah Khan
2018-07-31  3:15   ` Rafael David Tinoco
2018-08-08 14:09     ` Rafael David Tinoco
2018-08-09 20:21   ` [PATCH v2] " Rafael David Tinoco
2018-08-27 22:52     ` Shuah Khan
2018-09-03  2:12       ` [PATCH v3] membarrier_test: work in progress Rafael David Tinoco
2018-09-21 22:48         ` Shuah Khan
2018-09-03 19:04       ` [PATCH v4] selftests: membarrier: reorganized test for LTS supportability Rafael David Tinoco
2018-09-03 19:11         ` Rafael David Tinoco
2018-09-21 22:53         ` Shuah Khan
2018-11-09 15:49           ` [PATCH v5] selftests: membarrier: re-organize test Rafael David Tinoco
2018-11-18 20:44             ` Rafael David Tinoco

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