selftests/futex: Adapt the private hash test to RCU related changes
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 10 Jul 2025 11:00:06 +0000 (13:00 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 11 Jul 2025 14:02:00 +0000 (16:02 +0200)
commita255b78d14324f8a4a49f88e983b9f00818d1194
treea8b47e5fb180d4b8523d2220a990e8d093a278e0
parentd7b8f8e20813f0179d8ef519541a3527e7661d3a
selftests/futex: Adapt the private hash test to RCU related changes

The auto scaling on create creation used to automatically assign the new
hash because there was the private hash was unused and could be replaced
right away.

This is already racy because if the private hash is in use by a thread
then the visibile resize will be delayed. With the upcoming change to
wait for a RCU grace period before the hash can be assigned, the test
will always fail.

If the reported number of hash buckets is not updated after an
auto scaling event, block on an acquired lock with a timeout. The timeout
is the delay to wait towards a grace period and locking and a locked
pthread_mutex_t ensure that glibc calls into kernel using futex
operation which will assign new private hash if available.
This will retry every 100ms up to 2 seconds in total.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250710110011.384614-2-bigeasy@linutronix.de
tools/testing/selftests/futex/functional/futex_priv_hash.c