Skip to content

selftests/futex: Fix flaky futex_wait and futex_waitv tests

Mathieu Desnoyers linux-kselftest lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest4 patches 0 repliesNew

Changes in v2 from the cover letter

================

- v1 was patch 2 alone. It retried the wake for up to 5s, and gave the waiter a timeout of 10s. Both bounds were timing assumptions too. In v2, the main thread retries until the waiter has returned from futex_wait(), and the waiter waits without a timeout.
- New patches 1, 3 and 4.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4selftests/futex: Let futex_waitv() take no timeouttools/testing/selftests/futex/include/futex2test.h+9 -50 replies
2/4selftests/futex: Retry the wake in futex_wait instead of sleepingtools/testing/selftests/futex/functional/futex_wait.c+38 -190 replies
3/4selftests/futex: Retry the wake in futex_waitv instead of sleepingtools/testing/selftests/futex/functional/futex_waitv.c+35 -150 replies
4/4selftests/futex: Remove the shared memory segments of the futex teststools/testing/selftests/futex/functional/futex_wait.c tools/testing/selftests/futex/functional/futex_waitv.c+4 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] selftests/futex: Fix flaky futex_wait and futex_waitv tests

Hi Thomas, Peter,

The futex_wait and futex_waitv selftests assume that a waiter thread blocks within 10ms, and that the main thread wakes it in time. Under load, both assumptions fail. With the built-in locktorture, the tests failed in 0.5% to 1% of the runs in 8-CPU VMs. Repeated runs of futex_waitv also run out of System V shared memory segments.

These four patches fix both problems:

1 Let the futex_waitv() helper take no timeout.
2 Retry the wake in futex_wait until the waiter has returned, instead
of sleeping a fixed time.
3 Do the same in futex_waitv, and join its waiter.
4 Remove the shared memory segments that the tests create.

How this was developed
======================

An LLM coding assistant wrote these patches and their messages, under my direction and review.

Changes since v1
================

- v1 was patch 2 alone. It retried the wake for up to 5s, and gave the waiter a timeout of 10s. Both bounds were timing assumptions too. In v2, the main thread retries until the waiter has returned from futex_wait(), and the waiter waits without a timeout.
- New patches 1, 3 and 4.

Based on v7.4-rc1, 6628e7d4c6b2.

v1: https://lore.kernel.org/all/[email protected]/

Mathieu Desnoyers (4):
selftests/futex: Let futex_waitv() take no timeout selftests/futex: Retry the wake in futex_wait instead of sleeping selftests/futex: Retry the wake in futex_waitv instead of sleeping selftests/futex: Remove the shared memory segments of the futex tests

 .../selftests/futex/functional/futex_wait.c   | 59 +++++++++++++------
 .../selftests/futex/functional/futex_waitv.c  | 52 +++++++++++-----
 .../selftests/futex/include/futex2test.h      | 14 +++--
 3 files changed, 86 insertions(+), 39 deletions(-)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.47.3