[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250204110533.GV7145@noisy.programming.kicks-ass.net>
Date: Tue, 4 Feb 2025 12:05:33 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: linux-kernel@...r.kernel.org,
André Almeida <andrealmeid@...lia.com>,
Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>, Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Valentin Schneider <vschneid@...hat.com>,
Waiman Long <longman@...hat.com>
Subject: Re: [PATCH v8 12/15] futex: Allow to re-allocate the private local
hash.
On Mon, Feb 03, 2025 at 02:59:32PM +0100, Sebastian Andrzej Siewior wrote:
> @@ -159,11 +281,25 @@ struct futex_hash_bucket *futex_hash(union futex_key *key)
>
> bool futex_put_private_hash(struct futex_private_hash *hb_p)
> {
> - return false;
> + bool released;
> +
> + guard(preempt)();
> + released = rcuref_put_rcusafe(&hb_p->users);
> + if (released)
> + WRITE_ONCE(hb_p->released, true);
> + return released;
> }
>
> void futex_hash_put(struct futex_hash_bucket *hb)
> {
> + struct futex_private_hash *hb_p;
> +
> + if (hb->hb_slot == 0)
> + return;
> + hb_p = container_of(hb, struct futex_private_hash,
> + queues[hb->hb_slot - 1]);
> +
> + futex_put_private_hash(hb_p);
> }
>
> /**
> @@ -175,6 +311,14 @@ void futex_hash_put(struct futex_hash_bucket *hb)
> */
> void futex_hash_get(struct futex_hash_bucket *hb)
> {
> + struct futex_private_hash *hb_p;
> +
> + if (hb->hb_slot == 0)
> + return;
> + hb_p = container_of(hb, struct futex_private_hash,
> + queues[hb->hb_slot - 1]);
> +
> + WARN_ON_ONCE(!rcuref_get(&hb_p->users));
> }
> --- a/kernel/futex/futex.h
> +++ b/kernel/futex/futex.h
> @@ -115,6 +115,7 @@ static inline bool should_fail_futex(bool fshared)
> */
> struct futex_hash_bucket {
> atomic_t waiters;
> + unsigned int hb_slot;
> spinlock_t lock;
> struct plist_head chain;
> } ____cacheline_aligned_in_smp;
*groan*
Just sticking a pointer in was too complicated?
void futex_hash_put(struct futex_hash_bucket *hb)
{
struct futex_private_hash *ph = hb->private;
if (!ph)
return;
futex_put_private_hash(ph);
}
Powered by blists - more mailing lists