lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Feb 2019 15:43:08 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     torvalds@...ux-foundation.org, mingo@...nel.org, bp@...en8.de,
        tglx@...utronix.de, luto@...nel.org, namit@...are.com
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH 6/5] x86/percpu: Optimize raw_cpu_xchg()

On Wed, Feb 27, 2019 at 11:24:45AM +0100, Peter Zijlstra wrote:
> 
> And because it's one of _those_ days, I forgot to include one patch...
> 
> ---
> Subject: x86/percpu: Optimize raw_cpu_xchg()
> From: Peter Zijlstra <peterz@...radead.org>
> Date: Wed Feb 27 11:09:56 CET 2019
> 
> Since raw_cpu_xchg() doesn't need to be IRQ-safe, like
> this_cpu_xchg(), we can use a simple load-store instead of the cmpxchg
> loop.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
>  arch/x86/include/asm/percpu.h |   18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -407,9 +407,21 @@ do {									\
>  #define raw_cpu_or_1(pcp, val)		percpu_to_op(, "or", (pcp), val)
>  #define raw_cpu_or_2(pcp, val)		percpu_to_op(, "or", (pcp), val)
>  #define raw_cpu_or_4(pcp, val)		percpu_to_op(, "or", (pcp), val)
> -#define raw_cpu_xchg_1(pcp, val)	percpu_xchg_op(, pcp, val)
> -#define raw_cpu_xchg_2(pcp, val)	percpu_xchg_op(, pcp, val)
> -#define raw_cpu_xchg_4(pcp, val)	percpu_xchg_op(, pcp, val)
> +
> +/*
> + * raw_cpu_xchg() can use a load-store since it is not required to be
> + * IRQ-safe.
> + */
> +#define raw_percpu_xchg_op(var, nval)					\
> +({									\
> +	typeof(var) pxo_ret__ = raw_cpu_read(var);			\
> +	raw_cpu_write(var, (nval));					\
> +	pxo_ret__;							\
> +})
> +
> +#define raw_cpu_xchg_1(pcp, val)	raw_percpu_xchg_op(pcp, val)
> +#define raw_cpu_xchg_2(pcp, val)	raw_percpu_xchg_op(pcp, val)
> +#define raw_cpu_xchg_4(pcp, val)	raw_percpu_xchg_op(pcp, val)
>  
>  #define this_cpu_read_1(pcp)		percpu_from_op(volatile, "mov", pcp)
>  #define this_cpu_read_2(pcp)		percpu_from_op(volatile, "mov", pcp)

And yes, I just added raw_cpu_xchg_8... *sigh*

Powered by blists - more mailing lists