Re: [PATCH] locking/atomic: sh: Use generic_cmpxchg_local for arch_cmpxchg_local()

From: John Paul Adrian Glaubitz
Date: Wed Oct 25 2023 - 06:32:53 EST


On Wed, 2023-10-25 at 11:30 +0100, Mark Rutland wrote:
> On Wed, Oct 25, 2023 at 08:42:55AM +0900, Masami Hiramatsu wrote:
> > On Tue, 24 Oct 2023 16:08:12 +0100
> > Mark Rutland <mark.rutland@xxxxxxx> wrote:
> >
> > > On Tue, Oct 24, 2023 at 11:52:54PM +0900, Masami Hiramatsu (Google) wrote:
> > > > From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> > > >
> > > > Use generic_cmpxchg_local() for arch_cmpxchg_local() implementation
> > > > in SH architecture because it does not implement arch_cmpxchg_local().
> > >
> > > I do not think this is correct.
> > >
> > > The implementation in <asm-generic/cmpxchg-local.h> is UP-only (and it only
> > > disables interrupts), whereas arch/sh can be built SMP. We should probably add
> > > some guards into <asm-generic/cmpxchg-local.h> for that as we have in
> > > <asm-generic/cmpxchg.h>.
> >
> > Isn't cmpxchg_local for the data which only needs to ensure to do cmpxchg
> > on local CPU?
> > So I think it doesn't care about the other CPUs (IOW, it should not touched by
> > other CPUs), so it only considers UP case. E.g. on x86, arch_cmpxchg_local() is
> > defined as raw "cmpxchg" without lock prefix.
> >
> > #define __cmpxchg_local(ptr, old, new, size) \
> > __raw_cmpxchg((ptr), (old), (new), (size), "")
> >
>
> Yes, you're right; sorry for the noise.
>
> For your original patch:
>
> Acked-by: Mark Rutland <mark.rutland@xxxxxxx>
>

Geert, what's your opinion on this?

Adrian

--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913