[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4b9a5824-7cb7-4dc6-91dd-536f4dad9771@igalia.com>
Date: Fri, 25 Oct 2024 18:23:33 -0300
From: André Almeida <andrealmeid@...lia.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: linux-kernel@...r.kernel.org, mingo@...hat.com, dvhart@...radead.org,
dave@...olabs.net, Andrew Morton <akpm@...ux-foundation.org>,
urezki@...il.com, hch@...radead.org, lstoakes@...il.com,
Arnd Bergmann <arnd@...db.de>, linux-api@...r.kernel.org,
linux-mm@...ck.org, linux-arch@...r.kernel.org, malteskarupke@....de,
cl@...ux.com, llong@...hat.com, tglx@...utronix.de
Subject: Re: [PATCH 2/6] futex: Implement FUTEX2_NUMA
Hey Peter,
Em 25/10/2024 06:03, Peter Zijlstra escreveu:
> Extend the futex2 interface to be numa aware.
>
> When FUTEX2_NUMA is specified for a futex, the user value is extended
> to two words (of the same size). The first is the user value we all
> know, the second one will be the node to place this futex on.
>
> struct futex_numa_32 {
> u32 val;
> u32 node;
> };
>
Maybe this should live at include/uapi/linux/futex.h.
> When node is set to ~0, WAIT will set it to the current node_id such
> that WAKE knows where to find it. If userspace corrupts the node value
> between WAIT and WAKE, the futex will not be found and no wakeup will
> happen.
>
> When FUTEX2_NUMA is not set, the node is simply an extention of the
> hash, such that traditional futexes are still interleaved over the
> nodes.
>
> This is done to avoid having to have a separate !numa hash-table.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Do you think some of those changes should be guarded with #ifdef
CONFIG_NUMA? Or is fine as it is? I see that most of NUMA_ values
defines to 1 anyway on !numa, but maybe the futex_init() and
futex_hash() would be a bit more simplified.
[...]
>
> +static int futex_get_value(u32 *val, u32 __user *from, unsigned int flags)
> +{
> + switch (futex_size(flags)) {
> + case 1: return __get_user(*val, (u8 __user *)from);
> + case 2: return __get_user(*val, (u16 __user *)from);
> + case 4: return __get_user(*val, (u32 __user *)from);
> + default: BUG();
> + }
> +}
> +
> +static int futex_put_value(u32 val, u32 __user *to, unsigned int flags)
> +{
> + switch (futex_size(flags)) {
> + case 1: return __put_user(val, (u8 __user *)to);
> + case 2: return __put_user(val, (u16 __user *)to);
> + case 4: return __put_user(val, (u32 __user *)to);
> + default: BUG();
> + }
> +}
> +
I found a bit confusing that this is here, shouldn't be at [PATCH 4/6]
futex: Enable FUTEX2_{8,16}?
Powered by blists - more mailing lists