Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2014614imm; Thu, 11 Oct 2018 03:48:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV62cAkLtrLE4cA/CQXC/sinGMjbbrtSYRNuuUyCQq8eMkW7C8pb/+c7UHqwILjaZr1SeI324 X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr1005037pld.289.1539254925579; Thu, 11 Oct 2018 03:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539254925; cv=none; d=google.com; s=arc-20160816; b=qqsQj7AGSDRks2XLhcXwOhnWl8cCqMuXVmB0GNskN8jrvKg+BXxPMQNurN/5hDiXo8 sqg5cKWsaJo1QPir+Oc7JXFMpgHdeLYvmHBwAdsWocxe+vhs/2e7I1iE4vnMf3VsR5mp H9wvM4k6z9fHRsby5E3EYt1gSjudPVmZ184dc1bvJ3WpaEl1KigXwll5T0qYyu0P/lyt CrgQkDFVtynf4mfiuPMiwm6PMQ7fCRahpX8bnzQJCeyFeRjV48fH1i88nBT/aU0nPnF5 53vCY7wUl786JrZ1cdd5JCmBDlFKN/MNob9YNPMugH1Jx5jm99V3IGL8alONpxXkynNx tKlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=VgIGGstyElEILIG84w7jr3aH+N4IDrf6UVb8Eu3D5RU=; b=zsqcQu0iHZqjn6imiSGqfi5HWhsE5g4SmnDm1pjwQ540GPF74DUj2zn4RI0Ja56Oao 89w5ji1ZD8SAtKKf+svZXPxG2t1pIyNB1e+v5NWTNVrvTxJH2PTgaazbx5g4IO0H5pSL b11dOwpPihf9mKJ3jx+TwSngmEAAJmqlWcZ4GlUM4HFux8n2yPJrSig9VNJg9xk0eXbu a0AQ5dX9to2MhhXR5mPteJiEBALBb+Am9QA8etFYrbxXHv5/cUurSDuu5ex90q6sHsan WM9kaL9ys9Vqa/Bm/iWzdLLX6lTOUsprc5Iq+BoV4MAYrrxZeppZ15D1fXz3jb+Dnttn UJeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iGLTiLDa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7-v6si27126406pll.209.2018.10.11.03.48.31; Thu, 11 Oct 2018 03:48:45 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=iGLTiLDa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbeJKSL5 (ORCPT + 99 others); Thu, 11 Oct 2018 14:11:57 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52364 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbeJKSL5 (ORCPT ); Thu, 11 Oct 2018 14:11:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VgIGGstyElEILIG84w7jr3aH+N4IDrf6UVb8Eu3D5RU=; b=iGLTiLDaKilU1IIKv3jZumoQI2 bDwFq+GXq0eSumenYbVv65vnKS0tOMxtqkHfkJax6un09aCuK9y/3gKLiuvvZEQTxjGYc/TEnsmQw dilZc1i+AYzeXmezQJpnoyGbno9FAJOr0F59MADCdUWeVqCs/b40y51sSipd9CAEWtRFYfLUZzm10 9qFvyh6EfmJ9qfS/puSoGzVwPAKhs88fJYutODnj1ySxGPiBBLG4kGpaxVhU+NWNQENbmep3Ndo7v fm2/cge2HeGqMXkOqSBGF94h8g3QlbgJf4VEgH/FHplF8s6CHqZ/+Cb/OoRqn7I3mvrOJBtbKDdS/ 6r9ObrLg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAYSr-0002ve-LL; Thu, 11 Oct 2018 10:45:09 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 949142027E194; Thu, 11 Oct 2018 12:45:07 +0200 (CEST) Message-ID: <20181011104019.748208519@infradead.org> User-Agent: quilt/0.65 Date: Thu, 11 Oct 2018 12:38:27 +0200 From: Peter Zijlstra To: mingo@kernel.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, edumazet@google.com, eric.dumazet@gmail.com, bp@alien8.de, peterz@infradead.org Subject: [PATCH 2/2] x86/percpu: Fix this_cpu_read() References: <20181011103825.023036082@infradead.org> MIME-Version: 1.0 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 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) --- 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; \