Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2459940imm; Thu, 11 Oct 2018 10:33:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV61hs02CJMhj6C8Nntl+fp+OxYRrgc+gDp93527dNPqQDn3CiTvan1sR+qneFxpO/aKPqFd1 X-Received: by 2002:a63:480e:: with SMTP id v14-v6mr2216008pga.308.1539279226274; Thu, 11 Oct 2018 10:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539279226; cv=none; d=google.com; s=arc-20160816; b=FvE78MDS/MVxmFOK6hFsP30XkUCkE5ud9KsaobTSpU9PQA3lxPVDY+lY0ty2kSwh0o /cnmOYgUGovHP40AP727toAhx2pFnIF1oukM+maFY/jKGpVosaqFrExvo0xNuZmdcTLk GVWL4ZDIjIpQfE0qIBzll+FnIJZoCohECWPBA+R1wBhyzrcrW5UjkWzXs3aRKFJ0+leT q5994tJV2AbHCSPatA8AV/Y2CNauJaUEJ/SS0i99dPzYUNWtSGQWSgWg1QAOLjSSnF6V V6NOy2vfRAkVXTVTQ2KuF7MT5mBVPt2phSD/Cjn+360YC0emtY5w85Bmp5ly22W0GKES bEwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=H/naWTO9CxdQZFOUKhonf+vvaQc+Kk2l6u9PJleafIc=; b=pazO9/2be1Qp1eqHmrgNumMhQy+nS7JerN+m+SfoZnh4wOpWyZ1xjlVEvAwoMsmx+9 UdwKrQGAEA3SK6MqMq/jNas+q10OmXkm+/eOdK+Mmqg78rvQ3Ol1FRnD2MBRWZxSl45k LZ1gOwCq8UMBf8VqsyNl8VehySqP+WYyGsieeYZ5KHlrCbjjnRSTqgflVOiHQVNzwJKc X5R9eFvPfElLRuP9bjEnApG901V5Arq9FG1OI2PUUEGW91YpF8ZruSEIrnYUWLh2VQ33 I0Vjwh6wr9+JUlprvujkJhjlnHiyAHr1onDQgSgxJgw0AkPeXEiGdmxCpZ4yiKpCQn5F YAxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bIXGqRqW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si10846440pgd.528.2018.10.11.10.33.31; Thu, 11 Oct 2018 10:33:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bIXGqRqW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbeJKWaf (ORCPT + 99 others); Thu, 11 Oct 2018 18:30:35 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:38970 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbeJKWae (ORCPT ); Thu, 11 Oct 2018 18:30:34 -0400 Received: by mail-it1-f196.google.com with SMTP id w200-v6so13607109itc.4 for ; Thu, 11 Oct 2018 08:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H/naWTO9CxdQZFOUKhonf+vvaQc+Kk2l6u9PJleafIc=; b=bIXGqRqWCR390AsBDOCm/n203ueETsQv8ljH42z4AdpWiVv9E1I2j5yHWZTSiOi+yn 37aiTc7P4zIMpcAfQp0xi3IBQvu/4upkwywY5dydqbnC8xD3A0SbvQhxKceMirE4UD6D y7PVkjv3/oyZlwjRb1kJlafzC/mIDBqinxRpTfzVtK63NpTtSPixrP8kqpk/yRtku4TK 4ldYz1wSsl3JbAbivCBI8U1SWWW/YeszX6vpJpVuOTBCbkDiBcxUJv9tBptg9fMg8IYi eJMU5mQ9PVq6I+E2YA1JDZEf4ejo4fITbFysM0xI80bP6IMNAK7u9N6AHEfL0F+tu7l0 CaYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H/naWTO9CxdQZFOUKhonf+vvaQc+Kk2l6u9PJleafIc=; b=C26fqxRwUdUJyXfgSgJw/00R7pgXnXLURfciHlfY0i6ArMOKATnRIT9yKqCwWxoTGC KiwPvWkuVt920HdjYP4V03GktClLWKH1nsFp9aWoGL/x+Fr803WK3TZ/i+OwvXVETGM2 2U++71d6FdKWqiHygUk4GExu6G6Bvn+NkanrTq6IyaoPjIDLnWQ0Qz7pS2P364vkqQS3 TAXFeZzkO1JoNbJnxwqwYNtB/USrSBacztoOgHU3YR7A6uRQnH4V3nRMdAj9I03z+/XU d6U7IG/WYRb/BOOnu4Y8TXrVT25uXI7XwJPvEw0lnAuwiC+X9vlkuAqAB2q2h5ZftFu2 GvUg== X-Gm-Message-State: ABuFfojtrNpyLIMzCzzcy7lCUPuADZUUbCyl6zebs+yyj/jWYMrQNu9b AZogbs9qVciEFve0BE+NCGfqCRDdmJfXzbmKKutxTg== X-Received: by 2002:a24:f803:: with SMTP id a3-v6mr1596175ith.178.1539270180852; Thu, 11 Oct 2018 08:03:00 -0700 (PDT) MIME-Version: 1.0 References: <20181011103825.023036082@infradead.org> <20181011104019.748208519@infradead.org> In-Reply-To: <20181011104019.748208519@infradead.org> From: Eric Dumazet Date: Thu, 11 Oct 2018 08:02:48 -0700 Message-ID: Subject: Re: [PATCH 2/2] x86/percpu: Fix this_cpu_read() To: Peter Zijlstra Cc: Ingo Molnar , Thomas Gleixner , LKML , "H. Peter Anvin" , Eric Dumazet , Borislav Petkov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 11, 2018 at 3:45 AM Peter Zijlstra 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 > Signed-off-by: Peter Zijlstra (Intel) Acked-by: Eric Dumazet > --- > 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; \ > >