[PATCH] asm-generic: atomic64: handle ARCH_ATOMIC builds (was "Re: [PATCH v3 1/2] locking/atomics: Fixup GENERIC_ATOMIC64 conflict") with atomic-arch-fallback.h

From: Mark Rutland
Date: Thu Apr 22 2021 - 06:59:53 EST


Hi Guo,

On Wed, Apr 21, 2021 at 12:53:45PM +0000, guoren@xxxxxxxxxx wrote:
> From: Guo Ren <guoren@xxxxxxxxxxxxxxxxx>
>
> Current GENERIC_ATOMIC64 in atomic-arch-fallback.h is broken. When a 32-bit
> arch use atomic-arch-fallback.h will cause compile error.
>
> In file included from include/linux/atomic.h:81,
> from include/linux/rcupdate.h:25,
> from include/linux/rculist.h:11,
> from include/linux/pid.h:5,
> from include/linux/sched.h:14,
> from arch/riscv/kernel/asm-offsets.c:10:
> include/linux/atomic-arch-fallback.h: In function 'arch_atomic64_inc':
> >> include/linux/atomic-arch-fallback.h:1447:2: error: implicit declaration of function 'arch_atomic64_add'; did you mean 'arch_atomic_add'? [-Werror=implicit-function-declaration]
> 1447 | arch_atomic64_add(1, v);
> | ^~~~~~~~~~~~~~~~~
> | arch_atomic_add

This is expected; GENERIC_ATOMIC64 doesn't implement arch_atomic64_*(),
and thus violates the expectations of the fallback code.

To make GENERIC_ATOMIC64 compatible with ARCH_ATOMIC, the
GENERIC_ATOMIC64 implementation *must* provide arch_atomic64_*()
functions.

> The atomic-arch-fallback.h & atomic-fallback.h &
> atomic-instrumented.h are generated by gen-atomic-fallback.sh &
> gen-atomic-instrumented.sh, so just take care the bash files.
>
> Remove the dependency of atomic-*-fallback.h in atomic64.h.

Please don't duplicate the fallbacks; this'll make it harder to move
other over and eventually remove the non-ARCH_ATOMIC implementations.

Does the patch below make things work for you, or have I missed
something?

I've given this a basic build test on an arm config using
GENERIC_ATOMIC64 (but not ARCH_ATOMIC).

Thanks,
Mark.
---->8----