From: Rafael David Tinoco <rafael.tinoco@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org, stable@vger.kernel.org,
shuah@kernel.org, tglx@linutronix.de,
mathieu.desnoyers@efficios.com, mingo@kernel.org,
peterz@infradead.org, rafael.tinoco@linaro.org,
gregkh@linuxfoundation.org
Subject: [PATCH v2] selftests: membarrier: fix test by checking supported commands
Date: Thu, 9 Aug 2018 17:21:57 -0300 [thread overview]
Message-ID: <20180809202157.21148-1-rafael.tinoco@linaro.org> (raw)
In-Reply-To: <9edf8459-aea1-c59e-5d73-112e986777e1@kernel.org>
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 | 71 +++++++++++--------
1 file changed, 40 insertions(+), 31 deletions(-)
diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c
index 6793f8ecc8e7..4dc263824bda 100644
--- a/tools/testing/selftests/membarrier/membarrier_test.c
+++ b/tools/testing/selftests/membarrier/membarrier_test.c
@@ -223,7 +223,7 @@ static int test_membarrier_global_expedited_success(void)
return 0;
}
-static int test_membarrier(void)
+static int test_membarrier(int supported)
{
int status;
@@ -236,21 +236,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,23 +262,28 @@ 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;
}
-static int test_membarrier_query(void)
+static int test_membarrier_query(int *supported)
{
int flags = 0, ret;
@@ -297,16 +303,19 @@ static int test_membarrier_query(void)
ksft_exit_skip(
"sys_membarrier unsupported: CMD_GLOBAL not found.\n");
+ *supported = ret;
ksft_test_result_pass("sys_membarrier available\n");
return 0;
}
int main(int argc, char **argv)
{
+ int supported;
+
ksft_print_header();
- test_membarrier_query();
- test_membarrier();
+ test_membarrier_query(&supported);
+ test_membarrier(supported);
return ksft_exit_pass();
}
--
2.18.0
next prev parent reply other threads:[~2018-08-09 20:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Rafael David Tinoco [this message]
2018-08-27 22:52 ` [PATCH v2] " 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
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=20180809202157.21148-1-rafael.tinoco@linaro.org \
--to=rafael.tinoco@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 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).