[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250203144101.GL7145@noisy.programming.kicks-ass.net>
Date: Mon, 3 Feb 2025 15:41:01 +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 03/15] futex: Add basic infrastructure for local task
local hash.
On Mon, Feb 03, 2025 at 02:59:23PM +0100, Sebastian Andrzej Siewior wrote:
> struct futex_hash_bucket *futex_hash(union futex_key *key)
> {
> - u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
> - key->both.offset);
> + struct futex_hash_bucket *fhb;
> + u32 hash;
>
> + fhb = current->mm->futex_hash_bucket;
> + if (fhb && futex_key_is_private(key)) {
> + u32 hash_mask = current->mm->futex_hash_mask;
> +
> + hash = jhash2((u32 *)key,
> + offsetof(typeof(*key), both.offset) / 4,
> + key->both.offset);
> + return &fhb[hash & hash_mask];
> + }
> + hash = jhash2((u32 *)key,
> + offsetof(typeof(*key), both.offset) / 4,
> + key->both.offset);
> return &futex_queues[hash & (futex_hashsize - 1)];
> }
Having read this later patch, I would still prefer this to look like:
struct futex_hash_bucker *futex_hash(union futex_key *key)
{
struct futex_hash_bucket *fhb = current->mm->futex_hash_bucket;
u32 hash;
if (futex_key_is_private) {
// shorter jhash invocation;
} else {
hash = jhash2((u32 *)key,
offsetof(typeof(*key), both.offset) / 4,
key->both.offset);
}
if (fhb)
return fhb[hash & current->mm->futex_hash_mask];
return &futex_queues[hash & (futex_hashsize - 1)];
}
Because the shorter hash invocation only cares about being private, not
about having fhb.
Notably, I'm also still thikning about all that pending FUTEX2_NUMA
stuff.
Powered by blists - more mailing lists