RE: 'simple' futex interface [Was: [PATCH v3 1/4] futex: Implement mechanism to wait on any of several futexes]

From: David Laight
Date: Fri Mar 06 2020 - 11:58:01 EST


From: Peter Zijlstra
> Sent: 05 March 2020 18:52
+> On Thu, Mar 05, 2020 at 01:14:17PM -0300, Andrà Almeida wrote:
>
> > > sys_futex_wait(void *uaddr, u64 val, unsigned long flags, ktime_t *timo);
> > > struct futex_wait {
> > > void *uaddr;
> > > u64 val;
> > > u64 flags;
> > > };
> > > sys_futex_waitv(struct futex_wait *waiters, unsigned int nr_waiters,
> > > u64 flags, ktime_t *timo);
> > > sys_futex_wake(void *uaddr, unsigned int nr, u64 flags);
> > > sys_futex_cmp_requeue(void *uaddr1, void *uaddr2, unsigned int nr_wake,
> > > unsigned int nr_requeue, u64 cmpval, unsigned long flags);
> > >
> > > And that makes 7 arguments for cmp_requeue, which can't be. Maybe we if
> > > combine nr_wake and nr_requeue in one as 2 u16... ?
> > >
> > > And then we need to go detector if the platform supports it or not..
> > >
> >
> > Thanks everyone for the feedback around our mechanism. Are the
> > performance benefits of implementing a syscall to wait on a single futex
> > significant enough to maintain it instead of just using
> > `sys_futex_waitv()` with `nr_waiters = 1`? If we join both cases in a
> > single interface, we may even add a new member for NUMA hint in `struct
> > futex_wait`.
>
> My consideration was that avoiding the get_user/copy_from_user might
> become measurable on !PTI systems with SMAP.
>
> But someone would have to build it and measure it before we can be sure
> of course.

An extra copy_from_user is likely to be noticable.
It certainly makes recvmsg() slower than recv().
Especially if the hardended usercopy crap gets involved.

David


-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)