selftests/futex: Order calls to futex_lock_pi
authorNysal Jan K.A <nysal@linux.ibm.com>
Mon, 14 Aug 2023 08:09:27 +0000 (13:39 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:42:29 +0000 (09:42 +0200)
commit7d31730c5d81d229e3c4b6a1d7ca2f441a24880c
treea2d097ab92ce21a5cdbc22f7bdb4b8fb47cd99c0
parent048d1a8b9da8d4d36ae4b092342740f08bb7346a
selftests/futex: Order calls to futex_lock_pi

[ Upstream commit fbf4dec702774286db409815ffb077711a96b824 ]

Observed occassional failures in the futex_wait_timeout test:

ok 1 futex_wait relative succeeds
ok 2 futex_wait_bitset realtime succeeds
ok 3 futex_wait_bitset monotonic succeeds
ok 4 futex_wait_requeue_pi realtime succeeds
ok 5 futex_wait_requeue_pi monotonic succeeds
not ok 6 futex_lock_pi realtime returned 0
......

The test expects the child thread to complete some steps before
the parent thread gets to run. There is an implicit expectation
of the order of invocation of futex_lock_pi between the child thread
and the parent thread. Make this order explicit. If the order is
not met, the futex_lock_pi call in the parent thread succeeds and
will not timeout.

Fixes: f4addd54b161 ("selftests: futex: Expand timeout test")
Signed-off-by: Nysal Jan K.A <nysal@linux.ibm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/futex/functional/futex_wait_timeout.c