Re: [RFC PATCH 3/3] futex: Use the task local hashmap.

From: Sebastian Andrzej Siewior
Date: Mon Oct 28 2024 - 06:24:57 EST


On 2024-10-28 11:22:53 [+0100], Peter Zijlstra wrote:
> > struct futex_hash_bucket *futex_hash(union futex_key *key)
> > {
> > + struct futex_hash_table *fht;
> > u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
> > key->both.offset);
> >
> > + fht = current->futex_hash_table;
> > + if (fht && (key->both.offset & (FUT_OFF_INODE | FUT_OFF_MMSHARED)) == 0)
> > + return &fht->queues[hash & (fht->slots - 1)];
>
> Perhaps add a helper like:
>
> static inline bool futex_key_is_private(struct futex_key *key)
> {
> /*
> * Relies on get_futex_key() to set either bit for shared
> * futexes -- see comment with union futex_key.
> */
> return !(key->both.offset & (FUT_OFF_INODE | FUT_OFF_MMSHARED));
> }

Oki.

Sebastian