Re: [PATCH v2] arch,locking: Ciao arch_mutex_cpu_relax()

From: Geert Uytterhoeven
Date: Tue Aug 05 2014 - 09:04:45 EST


Hi David,

On Mon, Jun 30, 2014 at 12:09 AM, Davidlohr Bueso <davidlohr@xxxxxx> wrote:
> From: Davidlohr Bueso <davidlohr@xxxxxx>
>
> The arch_mutex_cpu_relax() function, introduced by 34b133f, is
> hacky and ugly. It was added a few years ago to address the fact
> that common cpu_relax() calls include yielding on s390, and thus
> impact the optimistic spinning functionality of mutexes. Nowadays
> we use this function well beyond mutexes: rwsem, qrwlock, mcs and
> lockref. Since the macro that defines the call is in the mutex header,
> any users must include mutex.h and the naming is misleading as well.
>
> This patch (i) renames the call to cpu_relax_lowlatency ("relax, but
> only if you can do it with very low latency") and (ii) defines it in
> each arch's asm/processor.h local header, just like for regular cpu_relax
> functions. On all archs, except s390, cpu_relax_lowlatency is simply cpu_relax,
> and thus we can take it out of mutex.h. While this can seem redundant,
> I believe it is a good choice as it allows us to move out arch specific
> logic from generic locking primitives and enables future(?) archs to
> transparently define it, similarly to System Z.
>
> Please note that these changes are only tested on x86-64.
>
> Signed-off-by: Davidlohr Bueso <davidlohr@xxxxxx>
> ---
> Changes from v1: Rename arch_cpu_relax to cpu_relax_lowlatency,
> based on the purpose of the function, as suggested by Linus.
>
> arch/alpha/include/asm/processor.h | 1 +
> arch/arc/include/asm/processor.h | 2 ++
> arch/arm/include/asm/processor.h | 2 ++
> arch/arm64/include/asm/processor.h | 1 +
> arch/avr32/include/asm/processor.h | 1 +
> arch/blackfin/include/asm/processor.h | 2 +-
> arch/c6x/include/asm/processor.h | 1 +
> arch/cris/include/asm/processor.h | 1 +
> arch/hexagon/include/asm/processor.h | 1 +
> arch/ia64/include/asm/processor.h | 1 +
> arch/m32r/include/asm/processor.h | 1 +
> arch/m68k/include/asm/processor.h | 1 +
> arch/metag/include/asm/processor.h | 1 +
> arch/mips/include/asm/processor.h | 1 +
> arch/mn10300/include/asm/processor.h | 2 ++
> arch/openrisc/include/asm/processor.h | 1 +
> arch/parisc/include/asm/processor.h | 1 +
> arch/powerpc/include/asm/processor.h | 2 ++
> arch/s390/include/asm/processor.h | 2 +-
> arch/score/include/asm/processor.h | 1 +
> arch/sh/include/asm/processor.h | 1 +
> arch/sparc/include/asm/processor_32.h | 2 ++
> arch/sparc/include/asm/processor_64.h | 1 +
> arch/tile/include/asm/processor.h | 2 ++
> arch/unicore32/include/asm/processor.h | 1 +
> arch/x86/include/asm/processor.h | 2 ++
> arch/xtensa/include/asm/processor.h | 1 +
> include/linux/mutex.h | 4 ----
> kernel/locking/mcs_spinlock.c | 8 +++-----
> kernel/locking/mcs_spinlock.h | 4 ++--
> kernel/locking/mutex.c | 4 ++--
> kernel/locking/qrwlock.c | 9 ++++-----
> kernel/locking/rwsem-xadd.c | 4 ++--
> lib/lockref.c | 3 +--
> 34 files changed, 48 insertions(+), 24 deletions(-)

It looks like you forgot to update frv? It's been failing on -next since a
few days:

kernel/locking/mcs_spinlock.h:87:2: error: implicit declaration of
function 'cpu_relax_lowlatency'
[-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
kernel/locking/mcs_spinlock.h:87:2: error: implicit declaration of
function 'cpu_relax_lowlatency'
[-Werror=implicit-function-declaration]
make[3]: *** [kernel/locking/mcs_spinlock.o] Error 1
cc1: some warnings being treated as errors
make[3]: *** [kernel/locking/mutex.o] Error 1

http://kisskb.ellerman.id.au/kisskb/buildresult/11616307/

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/