From: Gabriel Krisman Bertazi <hidden> Date: 2021-09-16 04:10:35
André Almeida [off-list ref] writes:
quoted
quoted
+/**+ * 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.
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
From: Peter Zijlstra <peterz@infradead.org> Date: 2021-09-16 11:20:54
On Thu, Sep 16, 2021 at 12:10:25AM -0400, Gabriel Krisman Bertazi wrote:
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.
Seriously, people still make 32bit applications today? And for legacy
games, I would think the speed increase of modern CPUs would far offset
this little inefficiency.
On Thu, Sep 16, 2021 at 1:22 PM Peter Zijlstra [off-list ref] wrote:
On Thu, Sep 16, 2021 at 12:10:25AM -0400, Gabriel Krisman Bertazi wrote:
quoted
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.
Seriously, people still make 32bit applications today? And for legacy
games, I would think the speed increase of modern CPUs would far offset
this little inefficiency.
There are 32-bit Windows games apparently, because it's easier to build it
that way than having both 32-bit and 64-bit versions.
There may be native 32-bit games built for Linux from the same sources when
that is not written portably, not sure if that's a thing.
One important reason to use compat mode is for cost savings when you can
ship an embedded system with slightly less RAM by running 32-bit user space
on it. We even still see people running 32-bit kernels on Arm boxes that have
entry-level 64-bit chips, though I hope that those will migrate the
kernel to arm64
even when they ship 32-bit user space.
Similar logic applies to cloud instances or containers. Running a 32-bit
Alpine Linux in a container means you can often go to a lower memory
instance on the host compared to a full 64-bit distro.
Arnd
Similar logic applies to cloud instances or containers. Running a 32-bit
Alpine Linux in a container means you can often go to a lower memory
instance on the host compared to a full 64-bit distro.
I also found that running a 32 bit version of Chrome or FireFox keeps them
from taking up all the memory in your system ;-) The most they can use is
4 gigs.
-- Steve