[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8735q5dutq.fsf@collabora.com>
Date: Thu, 16 Sep 2021 00:10:25 -0400
From: Gabriel Krisman Bertazi <krisman@...labora.com>
To: André Almeida <andrealmeid@...labora.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Darren Hart <dvhart@...radead.org>,
linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
kernel@...labora.com, linux-api@...r.kernel.org,
libc-alpha@...rceware.org, mtk.manpages@...il.com,
Davidlohr Bueso <dave@...olabs.net>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v3 2/6] futex2: Implement vectorized wait
André Almeida <andrealmeid@...labora.com> writes:
>>> +/**
>>> + * struct futex_waitv - A waiter for vectorized wait
>>> + * @val: Expected value at uaddr
>>> + * @uaddr: User address to wait on
>>> + * @flags: Flags for this waiter
>>> + * @__reserved: Reserved member to preserve data alignment. Should be 0.
>>> + */
>>> +struct futex_waitv {
>>> + __u64 val;
>>> + __u64 uaddr;
>>> + __u32 flags;
>>> + __u32 __reserved;
>>> +};
>>
>> why force uaddr to be __u64, even for 32-bit? uaddr could be a (void*) for
>> all we care, no? Also, by adding a reserved field, you are wasting 32
>> bits even on 32-bit architectures.
>>
>
> We do that to make the structure layout compatible with both entry
> points, remove the need for special cast and duplicated code, as
> suggested by Thomas and Arnd:
>
> https://lore.kernel.org/lkml/87v94310gm.ffs@tglx/
>
> https://lore.kernel.org/lkml/CAK8P3a0MO1qJLRkCH8KrZ3+=L66KOsMRmcbrUvYdMoKykdKoyQ@mail.gmail.com/
I find this weird. I'm not even juts talking about compat, but even on
native 32-bit. But also, 32 applications on 64, which is a big use
case for games.
The structure is mandating a 64 bit uaddr field and has an unnecessary
pad. You are wasting 20% of the space, which is gonna be elements of a
vector coming from user space. Worst case, you are doing copy_from_user
of an extra 1k bytes in the critical path of futex_waitv for no good
reason.
Also, if I understand correctly, Arnd suggestion, at least, was to have
two parser functions and a single syscall entry point, that would do the
translation:
if (in_compat_syscall())
futex_parse_waitv_compat(futexv, waiters, nr_futexes);
else
futex_parse_waitv(futexv, waiters, nr_futexes);
--
Gabriel Krisman Bertazi
Powered by blists - more mailing lists