lkml.org 
[lkml]   [2018]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] x86/percpu: Fix this_cpu_read()
On Thu, Oct 11, 2018 at 3:45 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> Eric reported that a sequence count loop using this_cpu_read() got
> optimized out. This is wrong, this_cpu_read() must imply READ_ONCE()
> because the interface is IRQ-safe, therefore an interrupt can have
> changed the per-cpu value.
>
> Fixes: 59eaef78bfea ("x86/tsc: Remodel cyc2ns to use seqcount_latch()")
> Reported-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>


Acked-by: Eric Dumazet <edumazet@google.com>

> ---
> arch/x86/include/asm/percpu.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -185,22 +185,22 @@ do { \
> typeof(var) pfo_ret__; \
> switch (sizeof(var)) { \
> case 1: \
> - asm(op "b "__percpu_arg(1)",%0" \
> + asm volatile(op "b "__percpu_arg(1)",%0"\
> : "=q" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 2: \
> - asm(op "w "__percpu_arg(1)",%0" \
> + asm volatile(op "w "__percpu_arg(1)",%0"\
> : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 4: \
> - asm(op "l "__percpu_arg(1)",%0" \
> + asm volatile(op "l "__percpu_arg(1)",%0"\
> : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
> case 8: \
> - asm(op "q "__percpu_arg(1)",%0" \
> + asm volatile(op "q "__percpu_arg(1)",%0"\
> : "=r" (pfo_ret__) \
> : "m" (var)); \
> break; \
>
>

\
 
 \ /
  Last update: 2018-10-11 17:04    [W:0.059 / U:9.344 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site