lkml.org 
[lkml]   [2021]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] uapi: futex: Add a futex syscall
On Tue, Oct 26, 2021 at 3:33 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Mon, Oct 25, 2021 at 6:33 PM André Almeida <andrealmeid@collabora.com> wrote:
> > Às 02:54 de 21/10/21, Alistair Francis escreveu:
> > > From: Alistair Francis <alistair.francis@wdc.com>
>
> > > +#if defined(__NR_futex)
> > > + if (sizeof(*timeout) == sizeof(struct __kernel_old_timespec))
> > > + return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3);
> > > +
> > > + if (timeout && timeout->tv_sec == (long)timeout->tv_sec) {
> > > + struct __kernel_old_timespec ts32;
> > > +
> > > + ts32.tv_sec = (__kernel_long_t) timeout->tv_sec;> + ts32.tv_nsec = (__kernel_long_t) timeout->tv_nsec;
> > > +
> > > + return syscall(__NR_futex, uaddr, op, val, &ts32, uaddr2, val3);
> > > + } else if (!timeout) {
> > > + return syscall(__NR_futex, uaddr, op, val, NULL, uaddr2, val3);
> > > + }
> > > +#endif
> >
> > If I read this part right, you will always use ts32 for __NR_futex. I
> > know that it can be misleading, but __NR_futex uses ts64 in 64-bit
> > archs, so they shouldn't be converted to ts32 in those cases.
>
> __kernel_old_timespec is the correct type for sys_futex() on all
> architectures.
>
> Maybe name the local variable 'ts' or 'ts_old' instead of 'ts32' then?
>
> > > +{
> > > +#if defined(__NR_futex_time64)
> > > + int ret = syscall(__NR_futex_time64, uaddr, op, val, nr_requeue, uaddr2, val3);
> > > +
> > > + if (ret == 0 || errno != ENOSYS)
> > > + return ret;
> > > +#endif
> > > +
> > > +#if defined(__NR_futex)
> > > + return syscall(__NR_futex, uaddr, op, val, nr_requeue, uaddr2, val3);
> > > +#endif
> > > +
> > > + errno = ENOSYS;
> > > + return -1;
> > > +}
> > > +
> > > +#endif /* _UAPI_LINUX_FUTEX_SYSCALL_H */
> > >
> >
> > Sorry if this question was already asked but I didn't find it in the
> > thread: Should we go with wrappers for the most common op? Like:
> >
> > __kernel_futex_wait(volatile uint32_t *uaddr, uint32_t val, struct
> > timespec *timeout)
> >
> > __kernel_futex_wake(volatile uint32_t *uaddr, uint32_t nr_wake)
>
> I had suggested having just a single function definition here, but having one
> per argument type seems reasonable as well. Having one definition
> per futex_op value would also be possible, but in that case I suppose
> we need all 13 of them, not just two.

Sorry I have taken so long to look at this again. I have addressed
your other comments.

I don't have a strong preference here. I do like that by having a
generic __kernel_futex_syscall_timeout() it should be easier to
convert existing uses of SYSCALL() to the new function (the requeue is
it's own thing anyway).

Alistair

>
> Arnd

\
 
 \ /
  Last update: 2021-11-23 06:46    [W:0.071 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site