From: Wake Liu <wakel@google.com>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org
Cc: "Peter Zijlstra" <peterz@infradead.org>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Carlos Llamas" <cmllamas@google.com>,
linux-kernel@vger.kernel.org, wakel@google.com
Subject: [PATCH 1/7] selftests/futex: Migrate futex_requeue to harness
Date: Mon, 1 Jun 2026 06:51:20 +0000 [thread overview]
Message-ID: <20260601065126.3623867-2-wakel@google.com> (raw)
In-Reply-To: <20260601065126.3623867-1-wakel@google.com>
Migrate futex_requeue test to the kselftest harness framework,
removing mixed legacy ksft_* API usages and ensuring proper thread joining.
Signed-off-by: Wake Liu <wakel@google.com>
---
.../futex/functional/futex_requeue.c | 32 +++++++++++++------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/futex/functional/futex_requeue.c b/tools/testing/selftests/futex/functional/futex_requeue.c
index dcf0d5f2f312..76f0eb6756f8 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue.c
@@ -7,6 +7,7 @@
#include <pthread.h>
#include <limits.h>
+#include <string.h>
#include "futextest.h"
#include "kselftest_harness.h"
@@ -18,13 +19,18 @@ volatile futex_t *f1;
void *waiterfn(void *arg)
{
+ struct __test_metadata *_metadata = (struct __test_metadata *)arg;
struct timespec to;
+ int res;
to.tv_sec = 0;
to.tv_nsec = timeout_ns;
- if (futex_wait(f1, *f1, &to, 0))
- printf("waiter failed errno %d\n", errno);
+ res = futex_wait(f1, *f1, &to, 0);
+ if (res) {
+ EXPECT_EQ(res, 0)
+ TH_LOG("waiter failed errno %d: %s", errno, strerror(errno));
+ }
return NULL;
}
@@ -40,12 +46,15 @@ TEST(requeue_single)
/*
* Requeue a waiter from f1 to f2, and wake f2.
*/
- ASSERT_EQ(0, pthread_create(&waiter[0], NULL, waiterfn, NULL));
+ ASSERT_EQ(pthread_create(&waiter[0], NULL, waiterfn, _metadata), 0)
+ TH_LOG("pthread_create failed");
usleep(WAKE_WAIT_US);
- EXPECT_EQ(1, futex_cmp_requeue(f1, 0, &f2, 0, 1, 0));
- EXPECT_EQ(1, futex_wake(&f2, 1, 0));
+ EXPECT_EQ(futex_cmp_requeue(f1, 0, &f2, 0, 1, 0), 1);
+ EXPECT_EQ(futex_wake(&f2, 1, 0), 1);
+
+ pthread_join(waiter[0], NULL);
}
TEST(requeue_multiple)
@@ -61,13 +70,18 @@ TEST(requeue_multiple)
* Create 10 waiters at f1. At futex_requeue, wake 3 and requeue 7.
* At futex_wake, wake INT_MAX (should be exactly 7).
*/
- for (i = 0; i < 10; i++)
- ASSERT_EQ(0, pthread_create(&waiter[i], NULL, waiterfn, NULL));
+ for (i = 0; i < 10; i++) {
+ ASSERT_EQ(pthread_create(&waiter[i], NULL, waiterfn, _metadata), 0)
+ TH_LOG("pthread_create failed for waiter %d", i);
+ }
usleep(WAKE_WAIT_US);
- EXPECT_EQ(10, futex_cmp_requeue(f1, 0, &f2, 3, 7, 0));
- EXPECT_EQ(7, futex_wake(&f2, INT_MAX, 0));
+ EXPECT_EQ(futex_cmp_requeue(f1, 0, &f2, 3, 7, 0), 10);
+ EXPECT_EQ(futex_wake(&f2, INT_MAX, 0), 7);
+
+ for (i = 0; i < 10; i++)
+ pthread_join(waiter[i], NULL);
}
TEST_HARNESS_MAIN
--
2.54.0.823.g6e5bcc1fc9-goog
next prev parent reply other threads:[~2026-06-01 6:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 6:51 [PATCH 0/7] selftests/futex: Migrate requeue, NUMA and robust list tests " Wake Liu
2026-06-01 6:51 ` Wake Liu [this message]
2026-07-05 19:54 ` [tip: locking/futex] selftests/futex: Migrate futex_requeue " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 2/7] selftests/futex: Migrate futex_requeue_pi " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 3/7] selftests/futex: Migrate futex_requeue_pi_mismatched_ops " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 4/7] selftests/futex: Migrate futex_requeue_pi_signal_restart " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 5/7] selftests/futex: Migrate futex_numa_mpol " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 6/7] selftests/futex: Migrate futex_priv_hash " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 6:51 ` [PATCH 7/7] selftests/futex: Migrate robust_list " Wake Liu
2026-07-05 19:54 ` [tip: locking/futex] " tip-bot2 for Wake Liu
2026-06-01 8:24 ` [PATCH 0/7] selftests/futex: Migrate requeue, NUMA and robust list tests " Peter Zijlstra
2026-06-03 6:17 ` Wake Liu
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=20260601065126.3623867-2-wakel@google.com \
--to=wakel@google.com \
--cc=andrealmeid@igalia.com \
--cc=cmllamas@google.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
/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
Powered by JetHome