Re: [PATCH] treewide: get rid of HAVE_FUTEX_CMPXCHG

From: Max Filippov
Date: Fri Jan 25 2019 - 13:29:50 EST


Hi Geert,

> > --- a/arch/m68k/Kconfig
> > +++ b/arch/m68k/Kconfig
> > @@ -20,7 +20,6 @@ config M68K
> > select GENERIC_STRNLEN_USER if MMU
> > select ARCH_WANT_IPC_PARSE_VERSION
> > select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE
> > - select HAVE_FUTEX_CMPXCHG if MMU && FUTEX
>
> I guess it didn't really matter for !MMU?

I see that m68k uses generic futex.h, which doesn't depend on
MMU vs noMMU.

> > --- a/include/asm-generic/futex.h
> > +++ b/include/asm-generic/futex.h
> > @@ -136,6 +136,8 @@ arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr)
> > return ret;
> > }
> >
> > +#define arch_have_futex_cmpxchg() (0)
>
> This is for the SMP=y case only, right?

Yes, that's where generic implementation always returns -ENOSYS

> > --- a/kernel/futex.c
> > +++ b/kernel/futex.c
> > @@ -174,7 +174,11 @@
> > * double_lock_hb() and double_unlock_hb(), respectively.
> > */
> >
> > -#ifdef CONFIG_HAVE_FUTEX_CMPXCHG
> > +/*
> > + * Architectures should define this macro if futex_atomic_cmpxchg_inatomic()
> > + * may not be always working.
> > + */
> > +#ifdef arch_have_futex_cmpxchg
>
> Shouldn't this be #ifndef now...

Oops, thank you.
I thought I've build-tested both cases, but I obviously haven't...

> > @@ -3880,7 +3864,9 @@ static int __init futex_init(void)
> > futex_hashsize, futex_hashsize);
> > futex_hashsize = 1UL << futex_shift;
> >
> > - futex_detect_cmpxchg();
> > +#ifdef arch_have_futex_cmpxchg
> > + futex_cmpxchg_enabled = arch_have_futex_cmpxchg();
>
> ... else you're assigning to the constant:
>
> error: lvalue required as left operand of assignment

Will send v2...

--
Thanks.
-- Max