From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, mingo@redhat.com,
dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com,
Andrew Morton <akpm@linux-foundation.org>,
urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com,
Arnd Bergmann <arnd@arndb.de>,
linux-api@vger.kernel.org, linux-mm@kvack.org,
linux-arch@vger.kernel.org, malteskarupke@web.de
Subject: Re: [PATCH v2 11/14] futex: Implement FUTEX2_NUMA
Date: Tue, 8 Aug 2023 10:54:06 +0200 [thread overview]
Message-ID: <20230808085406.GU212435@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <87fs4utv6f.ffs@tglx>
On Mon, Aug 07, 2023 at 11:11:04PM +0200, Thomas Gleixner wrote:
> On Mon, Aug 07 2023 at 14:18, Peter Zijlstra wrote:
> > /**
> > * futex_hash - Return the hash bucket in the global hash
> > * @key: Pointer to the futex key for which the hash is calculated
> > @@ -114,10 +137,29 @@ late_initcall(fail_futex_debugfs);
> > */
> > struct futex_hash_bucket *futex_hash(union futex_key *key)
> > {
> > - u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
> > + u32 hash = jhash2((u32 *)key,
> > + offsetof(typeof(*key), both.offset) / sizeof(u32),
> > key->both.offset);
> > + int node = key->both.node;
> > +
> > + if (node == -1) {
>
> NUMA_NO_NODE please all over the place.
Ah, so our (futex2) ABI states this needs to be -1, but in theory
someone could come along and change the kernel internal NUMA_NO_NODE to
something else.
That is, I explicitly chose not to use it. I can of course, because as
of now these values do match.
> > + /*
> > + * In case of !FLAGS_NUMA, use some unused hash bits to pick a
> > + * node -- this ensures regular futexes are interleaved across
> > + * the nodes and avoids having to allocate multiple
> > + * hash-tables.
> > + *
> > + * NOTE: this isn't perfectly uniform, but it is fast and
> > + * handles sparse node masks.
> > + */
> > + node = (hash >> futex_hashshift) % nr_node_ids;
> > + if (!node_possible(node)) {
> > + node = find_next_bit_wrap(node_possible_map.bits,
> > + nr_node_ids, node);
> > + }
>
> Smart.
Thanks :-)
> >
> > +static inline unsigned int futex_size(unsigned int flags)
> > +{
> > + return 1 << (flags & FLAGS_SIZE_MASK);
> > +}
> > +
> > static inline bool futex_flags_valid(unsigned int flags)
>
> If you reorder these two functions in the patch which introduces them,
> this diff gets readable :)
Durr, I knew I was forgetting something, will do.
next prev parent reply other threads:[~2023-08-08 8:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 12:18 [PATCH v2 00/14] futex: More futex2 bits Peter Zijlstra
2023-08-07 12:18 ` [PATCH v2 01/14] futex: Clarify FUTEX2 flags Peter Zijlstra
2023-08-07 23:51 ` André Almeida
2023-08-07 12:18 ` [PATCH v2 02/14] futex: Extend the " Peter Zijlstra
2023-08-07 18:56 ` Thomas Gleixner
2023-08-08 0:02 ` André Almeida
2023-08-07 12:18 ` [PATCH v2 03/14] futex: Flag conversion Peter Zijlstra
2023-08-07 18:58 ` Thomas Gleixner
2023-08-08 0:52 ` André Almeida
2023-08-07 12:18 ` [PATCH v2 04/14] futex: Validate futex value against futex size Peter Zijlstra
2023-08-07 12:18 ` [PATCH v2 05/14] futex: Add sys_futex_wake() Peter Zijlstra
2023-08-07 19:00 ` Thomas Gleixner
2023-08-09 22:25 ` André Almeida
2023-08-10 12:13 ` Peter Zijlstra
2023-08-10 17:01 ` André Almeida
2023-08-07 12:18 ` [PATCH v2 06/14] futex: Add sys_futex_wait() Peter Zijlstra
2023-08-07 12:18 ` [PATCH v2 07/14] futex: Propagate flags into get_futex_key() Peter Zijlstra
2023-08-07 12:18 ` [PATCH v2 08/14] futex: Add flags2 argument to futex_requeue() Peter Zijlstra
2023-08-07 19:01 ` Thomas Gleixner
2023-08-07 12:18 ` [PATCH v2 09/14] futex: Add sys_futex_requeue() Peter Zijlstra
2023-08-07 19:05 ` Thomas Gleixner
2023-08-07 12:18 ` [PATCH v2 10/14] mm: Add vmalloc_huge_node() Peter Zijlstra
2023-08-07 12:18 ` [PATCH v2 11/14] futex: Implement FUTEX2_NUMA Peter Zijlstra
2023-08-07 21:11 ` Thomas Gleixner
2023-08-08 8:54 ` Peter Zijlstra [this message]
2023-08-08 9:12 ` Thomas Gleixner
2023-08-07 12:18 ` [PATCH v2 12/14] futex: Propagate flags into futex_get_value_locked() Peter Zijlstra
2023-08-07 21:12 ` Thomas Gleixner
2023-08-07 12:18 ` [PATCH v2 13/14] futex: Enable FUTEX2_{8,16} Peter Zijlstra
2023-08-07 21:15 ` Thomas Gleixner
2023-08-07 12:18 ` [PATCH v2 14/14] futex,selftests: Extend the futex selftests Peter Zijlstra
2023-08-08 20:32 ` [PATCH v2 00/14] futex: More futex2 bits Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230808085406.GU212435@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@igalia.com \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=hch@infradead.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=malteskarupke@web.de \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=urezki@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox