Re: [PATCH v8 00/15] futex: Add support task local hash maps.
From: Peter Zijlstra
Date: Thu Feb 20 2025 - 10:14:19 EST
On Wed, Feb 05, 2025 at 01:20:26PM +0100, Sebastian Andrzej Siewior wrote:
> So the beauty of it is that you enforce a ref drop on hb once it gets
> out of scope. So you can't use it by chance once the ref is dropped.
>
> But this does not help in futex_lock_pi() where you have the drop the
> reference before __rt_mutex_start_proxy_lock() (or at least before
> rt_mutex_wait_proxy_lock()) but still have it you go for the no_block
> shortcut. At which point even the lock is still owned.
>
> While it makes the other cases nicer, the futex_lock_pi() function was
> the only one where I was thinking about setting hb to NULL to avoid
> accidental usage later on.
Sorry for the delay.. got distracted :/
I think we can simply put:
futex_hash_put(no_free_ptr(hb));
right where we drop hb->lock in futex_lock_pi().
I've split up the patch a little and stuck them here:
https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=futex/scope