Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, dvhart@infradead.org,
	dave@stgolabs.net, andrealmeid@igalia.com, shuah@kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] selftests/futex: Retry the wake in futex_wait instead of sleeping
Date: Mon, 30 Nov 2026 21:54:38 +0100	[thread overview]
Message-ID: <878q2aqbu9.ffs@fw13> (raw)
In-Reply-To: <7636700d-1aed-4e6f-adc6-720b1aa98501@efficios.com>

On Sun, Nov 08 2026 at 09:34, Mathieu Desnoyers wrote:
> On 2026-11-08 09:23, Mathieu Desnoyers wrote:
>> Each futex_wait test starts a waiter thread, which calls futex_wait()
>> with a 30ms timeout. The main thread sleeps 10ms, then expects
>> futex_wake() to wake one waiter. So the test assumes that the waiter
>> reaches futex_wait() within 10ms, and that the main thread runs again
>> within 30ms.
>> 
>> A busy machine breaks both. The built-in locktorture at times holds a
>> spinlock for 100ms with preemption off. With it, private_futex failed in
>> about 0.5% of the runs in 8-CPU VMs, on v7.4-rc1.
>> Timestamps showed two cases. The waiter started up to 75ms late, after
>> the wake. Or the main thread woke up to 105ms late, after the waiter
>> had timed out.
>> 
>> Fix this by retrying futex_wake() every millisecond until it wakes the
>> waiter, for up to 5s. Give the waiter a timeout of 10s, so that it
>> outlasts the retries. The tests then wait for the waiter, instead of
>> assuming when it runs.
>> 
>> With this patch, private_futex passed 6000 runs of 6000 in the same VMs,
>> and the three tests 2000 runs of 2000.
> Self-nack. That's flaky as well. A bounded retry can still fail. This
> needs a proper synchronization flag. Will respin a v2.

See:

6c4a1b972643 ("selftests/futex: Provide thread creation and synchronization helpers")
23dd3f884926 ("selftests/futex: Use thread synchronization helpers instead of usleep()")

      reply	other threads:[~2026-11-30 20:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08 14:23 [PATCH] selftests/futex: Retry the wake in futex_wait instead of sleeping Mathieu Desnoyers
2026-11-08 14:34 ` Mathieu Desnoyers
2026-11-30 20:54   ` Thomas Gleixner [this message]

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=878q2aqbu9.ffs@fw13 \
    --to=tglx@kernel.org \
    --cc=andrealmeid@igalia.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=shuah@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