# Re: \[PATCH 1/2\] futex: ensure futex\_atomic\_cmpxchg\_inatomic() is present

- From: Max Filippov \<jcmvbkbc@gmail.com\>
- Date: 2021-10-26 12:29:59 
- List: linux-arch
- Page: https://ratatoskr.run/linux-arch/2021/10/1554319
- Thread: https://ratatoskr.run/linux-mips/2021/10/1554166/t.md

```text
On Tue, Oct 26, 2021 at 3:04 AM Arnd Bergmann [ref] wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> The boot-time detection of futex_atomic_cmpxchg_inatomic()
> has a bug on some 32-bit arm builds, and Thomas Gleixner
> suggested that setting CONFIG_HAVE_FUTEX_CMPXCHG would
> avoid the problem, as it is always present anyway.
>
> Looking into which other architectures could do the same
> showed that almost all architectures have it, the exceptions
> being:
>
>  - some old 32-bit MIPS uniprocessor cores without ll/sc
>  - one xtensa variant with no SMP
>  - 32-bit SPARC when built for SMP
>
> Fix MIPS And Xtensa by rearranging the generic code to let it be used
> as a fallback.
>
> For SPARC, the SMP definition just ends up turning off futex anyway,
> so this can be done at Kconfig time instead. Note that sparc32
> glibc requires the CASA instruction for its mutexes anyway,
> which is only available when running on SPARCv9 or LEON CPUs,
> but needs to be implemented in the sparc32 kernel for those.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/mips/include/asm/futex.h   | 29 ++++++++++++++++++-----------
>  arch/xtensa/include/asm/futex.h |  8 ++++++--
>  include/asm-generic/futex.h     | 31 +++++++++++--------------------
>  init/Kconfig                    |  1 +
>  4 files changed, 36 insertions(+), 33 deletions(-)

For xtensa:
Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max
```
