Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2131873yba; Fri, 17 May 2019 11:00:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCqGDoO4L7tnx9i6KBkQq4qqFNEL8sByCmYvy/mYyzO9OIrNOV6GI+8zvdcJv+GXdYSBub X-Received: by 2002:aa7:880f:: with SMTP id c15mr64632153pfo.100.1558116048028; Fri, 17 May 2019 11:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558116048; cv=none; d=google.com; s=arc-20160816; b=Kvxy4BKoAXI1aPjqypjhalWnE4r6rLs5WuToaEEEbWK/JKdUk2mHurr5Qii+TffSil ANDLWBa9rlXwMuDB86OUCrJsPiBgkQaMcM3w4OPS5GEA4tc2UCsll5IoNe07+p/7dYYX cq6bX8eWftnnZxMZvi0O+rjHaKB7UncLK7FyiqKcW28fH2tOfqzX8pjAyzzg1zg+61YP UzfpTFbI7FlRMU/YUlnF5FAtAn3VT7EtPu+9Owz0D6G446fEp1xsYb2ZQ9yeliS6mx/9 bEjR1/79MlKKHm1SGsuyJKDmGe91S+nw0aKSO2+hI1fsrPi15UX/GrTOdpqKf69wNSdi sMNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=HjnJT2XdDYKQIIRI0wRs7dq5hVXPjCbb+2fdzHD9I4I=; b=qeNdqU4I8VuoA68yb2530MZqXExzuexO7pdTYyRSL3ykRW88Di8N4hjhK6d4kuEDBJ QKes/xZ3lnAEx1IFAWRZlcaeCtdJUtfBKDs+Fx3b1P6UJsToUmHEPu2DcNBTYbq1dBFy VGTPjbY3wEo2Ne5pfCVfJXwb0Idsf0rWSG8kIYt68+imhTRV8NBy5KIJy67Cnvy1SDml 5xqrDThSvovVb+tbmWwAGZXuybzBDFBFExZrPCQO2vOz1n6Rb3XIXdeRlquf/BSAgCrd KsQhB5sNrBoezV9F0CO9gzJptB2+UQDbi4QVEBIpw611Scv8/EWGkwT9SyW7poi2b7Ak Nx5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fauEAA2B; 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 z14si8085270pgv.128.2019.05.17.11.00.32; Fri, 17 May 2019 11:00:48 -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=fauEAA2B; 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 S1729071AbfEQR7P (ORCPT + 99 others); Fri, 17 May 2019 13:59:15 -0400 Received: from mail-ua1-f73.google.com ([209.85.222.73]:56110 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728536AbfEQR7P (ORCPT ); Fri, 17 May 2019 13:59:15 -0400 Received: by mail-ua1-f73.google.com with SMTP id j14so1121913ual.22 for ; Fri, 17 May 2019 10:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=HjnJT2XdDYKQIIRI0wRs7dq5hVXPjCbb+2fdzHD9I4I=; b=fauEAA2BclMEIkmvf+xXGB/nJbN4RY0tU6omsopEkobMhC1+AP5VAckmbkX5Jzqknn SVEFNKrI8VdjzWjxuAHIDw100HFn1N5BdfERXxuB3YqEdUymRmiuuvCgnhg0zI8gHywV 7Qhi/OJFgfd6qFzyZLNFC4vtMsHw0uVGtR0X9lmyqps1AWua+9WmmjjPJj+ozK8hqkqR B3mdI8FeOB26VZ7cYJHTRw4WXafKtSS6ERlIDidcVQnabczzRC+N2mZioB3O2ufTKuH+ 0/y6aO0L9vTt4iqVxTIb4UwKOewXmrx1fWV0uISJi/hzlgJ4OVM9qUngZhkqS0BJnRsN jPcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=HjnJT2XdDYKQIIRI0wRs7dq5hVXPjCbb+2fdzHD9I4I=; b=LXW4DniD3bZZWs5LrytYObYxB13gm3oSGm7rFBPIHZRzMjrJ/gMN+EtfWqdb6/V1gz r4vgCwbMF2cluGpjYCRyRMxsWvZhhBeZGLiYsU92pFTL1OH7Vb83R0b8ndrrJGii84hE Hscx/Bgagjw6MR3cA/eDyqvjecca1qFucyKUqjz4a0f+SVkRoSiPqteBVfq/WFaX2Pq7 Gh4jGqzSzcFTXcUeWlHr58rEM3v/YoYqv36lD4qWwg6IknOGOKrgLiS586AQlm8tqivj ozW6FNW0yYVu1vZlxfCjftcKfGM8EtgfVRwMyvYbLCh7VQgTysLELNKbQXCsGoyl4EES IBZw== X-Gm-Message-State: APjAAAWdqOf6by/w8pt3uyh73xhHmvey4A2RTtdlQQBbrUI7R9yLTj6R oDzlu66fbAIpXAMflH/SKmxiqGW56g== X-Received: by 2002:a1f:b20d:: with SMTP id b13mr13653vkf.75.1558115954425; Fri, 17 May 2019 10:59:14 -0700 (PDT) Date: Fri, 17 May 2019 10:59:06 -0700 In-Reply-To: <20190517084712.GL2623@hirez.programming.kicks-ass.net> Message-Id: <20190517175906.78742-1-yabinc@google.com> Mime-Version: 1.0 References: <20190517084712.GL2623@hirez.programming.kicks-ass.net> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog Subject: Re: [PATCH] perf/ring_buffer: Fix exposing a temporarily decreased data_head. From: Yabin Cui To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim Cc: linux-kernel@vger.kernel.org, Yabin Cui 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 > > - local_inc(&rb->nest); > > + rb->nest++; > > + barrier(); > Urgh; almost but not quite. You just lost the 'volatile' qualifier and > now the compiler can mess things up for you. I thought the barriers added could force the compiler to forget what it knows about rb->nest, and do the write as been told to. I appreciate it if you can tell me more details about it. Anyway, it's a good choice to be protective and always use WRITE_ONCE/READ_ONCE for rb->nest. > What I'm going to do is split this into two patches, one fixes the > problem and marked for backport, and one changing away from local_t. I read the split patches. They totally LGTM. Thanks for all your help and rapid reply! I appreciate it :)