on 5/18/2026, 10:15:21 AM, gemini/gemini-3.1-pro-preview wrote:
> > diff --git a/tools/testing/selftests/futex/functional/futex_requeue.c
> > b/tools/testing/selftests/futex/functional/futex_requeue.c
> > index dcf0d5f2f3122..246404b73ad86 100644
> > --- a/tools/testing/selftests/futex/functional/futex_requeue.c
> > +++ b/tools/testing/selftests/futex/functional/futex_requeue.c
> [ ... ]
> > @@ -62,12 +70,22 @@ TEST(requeue_multiple)
> > * 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));
> > + ASSERT_EQ(0, futex_thread_create(&waiter[i], waiterfn, NULL));
> >
> > - usleep(WAKE_WAIT_US);
> > + for (i = 0; i < 10; i++) {
> > + ret = futex_wait_for_thread(&waiter[i],
> > WAIT_THREAD_CREATE_TIMEOUT_USECS / 10);
> > + if (ret < 0) {
> Could this error handling reintroduce the race condition?
> futex_wait_for_thread() returns -ETIMEDOUT if the thread does not enter the
> futex sleep state within the specified timeout, and -EIO if the /proc entry
> cannot be read.
> Because this condition catches both errors indiscriminately, a slightly
> delayed thread that returns -ETIMEDOUT will be treated as if /proc is
> unavailable.
Personally, I don't think it's necessary to handle these two states separately
at this time. When a timeout occurs, the delay is at least 500ms + 50ms. If the
processing requirements still can't be met at this point, then this test item
should fail.
> + /* /proc not available, give all threads time to enter
> futex wait */
> + usleep(WAIT_THREAD_CREATE_TIMEOUT_USECS);
> + break;
> If the loop is broken here, the code skips verifying the wait state for any
> remaining threads.
> If those remaining threads take longer than 500ms to reach futex_wait(),
> the main thread will prematurely execute futex_cmp_requeue() and cause the
> test to fail.
> Should the check specifically verify if ret is -EIO before breaking the
> loop and falling back to usleep?
The reason is the same as above. I believe that waiting for 500ms is long enough
for the child threads to enter the test state.
> > + }
> > + }
> >
> > EXPECT_EQ(10, futex_cmp_requeue(f1, 0, &f2, 3, 7, 0));
> > EXPECT_EQ(7, futex_wake(&f2, INT_MAX, 0));