Re: [PATCH v5 09/14] futex: Allow to re-allocate the private hash bucket.
From: Sebastian Andrzej Siewior
Date: Tue Dec 17 2024 - 10:04:15 EST
On 2024-12-16 00:00:13 [+0100], To linux-kernel@xxxxxxxxxxxxxxx wrote:
> @@ -154,6 +303,17 @@ struct futex_hash_bucket *futex_hash(union futex_key *key)
>
> void futex_hash_put(struct futex_hash_bucket *hb)
> {
> + struct futex_hash_bucket_private *hb_p;
> +
> + if (hb->hb_slot == 0)
> + return;
> + hb_p = container_of(hb, struct futex_hash_bucket_private,
> + queues[hb->hb_slot - 1]);
> +
> + if (!rcuref_put(&hb_p->users))
> + return;
> +
> + futex_assign_new_hb(NULL);
I have reworked two things:
- I have to remove futex_assign_new_hb() here and let the next
rcuref_get() perform the assignment instead. The reason is that the
caller can change its task state (futex_wait_queue()) and blocking on
the mutex will reset it. Instead of delaying it after the schedule()
it looks simpler to delay it to the next rcuref_get() where it has to
be handled anyway.
- The logic in __futex_assign_new_hb() didn't deal properly with delayed
assigns.
> }
Sebastian