Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1334530ybd; Wed, 26 Jun 2019 15:50:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQDuWytaCI8VWlESIiV6XvDXngzSdL1mv61H92Dd6HOffVjJEx4xbhlYd72+pylBtmx6nO X-Received: by 2002:a63:b90d:: with SMTP id z13mr406397pge.16.1561589427513; Wed, 26 Jun 2019 15:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561589427; cv=none; d=google.com; s=arc-20160816; b=iXeFsLl9uQv0gfnq2vjmKx6Mxe5eXW4QPcLguyHrXb/t/yymD5VJJwjYv2LOu0zmpq +nTXg/q+hS8p7Q2/gLCX44eQYcv5u2M/IiERv7RUU4fwTNRRH2tL3Y7maK1+1HJ9O90r RUnmNXrYoDs17d8YvSJ0D7hDzCZu/BDAJYaWczRDviZAo0gqCaQsNPbAQiZTfynrp9xK CK0wqMv6Yl6Y5cZUlVi2hBYvHcC5rI5tVIibBbznsPVAP8we2z4anAqI4PKHfyxlNDyD 3hbAHs//hctqe+akv5Nars6q7C0Ujooi7ddaqLlOH+GNhUfa6aibU2JsESLiEQqLxLCW EMnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cSOYeJb33t5DLExxhAnhlCHJrYRdxM+QS30ifzE4/kw=; b=tPY8i+q2l6AE93f6LMGjW1ANd7wpqTAYt0oIfjOlepFvhG1vj9Fl2S1NyDnZcwHb2T oKdjeZDE++SsMHkpR0Gz+TCRZLwqPfgieS/WnS/OiOG8M68T9pk1oZ+taea1tTVLAfxO oT7fyDaXRqAcEkXkH/9hjJr2gvwVcO5ZQul9Y+UWsrmUA8swgQHszxWU7dNMLcmBtHWO 82Z/pKFd8J5nW2Iz8gafOt/JlIfgMBdakC7WITOuo/DLYPTJTDIKmLJdYQ8xnQFkZOUe b5PefoK9sSacOXNHSh4N3hSI9ifDfkJ2Vr8fHMd48w4E7sFS8e4tvXAFfDXnVUG3PXzq 8FCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Yka6dmsW; 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 y6si267469pga.501.2019.06.26.15.50.11; Wed, 26 Jun 2019 15:50:27 -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=merlin.20170209 header.b=Yka6dmsW; 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 S1726549AbfFZWsF (ORCPT + 99 others); Wed, 26 Jun 2019 18:48:05 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49396 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbfFZWsF (ORCPT ); Wed, 26 Jun 2019 18:48:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cSOYeJb33t5DLExxhAnhlCHJrYRdxM+QS30ifzE4/kw=; b=Yka6dmsWLTG8z6U+LsrlGtKwK 5CXuIC6g42C8cu14FDBm4T2FozEHZPDR0A2GeObyaCB86sZxW4UsqhtKvcvn+XwIvJsZp4hZ0mZqT PvT5oaV8CGsU19XHPYWZ19grhmB1cgcD55b663KSHfQAccP/qrjKaNBXYXiVtuxVIVU28pwCwWdva dNaMcukltXVzYLm+2qe6HczbUkRGtAl4PmgWyPFJ4FNo1OOVDNKjePrJuYOsdEDoS3TVqfoRHtdm7 qjARXbRgaao/iQYdLtKy84oLQYe8mhJn5jPoqzlzA9pudgFiw97vHPZFjjBDJzgUwNmNtaLCpfDue ugPlGTxag==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hgGhU-0002yx-3d; Wed, 26 Jun 2019 22:47:36 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id E6A4A98198F; Thu, 27 Jun 2019 00:47:03 +0200 (CEST) Date: Thu, 27 Jun 2019 00:47:03 +0200 From: Peter Zijlstra To: John Ogness Cc: linux-kernel@vger.kernel.org, Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Sergey Senozhatsky Subject: Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation Message-ID: <20190626224703.GL2490@worktop.programming.kicks-ass.net> References: <20190607162349.18199-1-john.ogness@linutronix.de> <20190607162349.18199-2-john.ogness@linutronix.de> <20190618114747.GQ3436@hirez.programming.kicks-ass.net> <87k1df28x4.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k1df28x4.fsf@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 12:23:19AM +0200, John Ogness wrote: > On 2019-06-18, Peter Zijlstra wrote: > >> + > >> + if (unlikely(newest_id == EOL)) { > >> + /* no previous newest means we *are* the list, set oldest */ > >> + > >> + /* > >> + * MB UNPAIRED > > > > That's a bug, MB must always be paired. > > Well, it "pairs" with the smp_rmb() of the readers, but I didn't think > that counts as a pair. That's why I wrote unpaired. The litmus test is: > > P0(int *x, int *y) > { > WRITE_ONCE(*x, 1); > smp_store_release(y, 1); > } > > P1(int *x, int *y) > { > int rx; > int ry; > > ry = READ_ONCE(*y); > smp_rmb(); > rx = READ_ONCE(*x); > } > > exists (1:rx=0 /\ 1:ry=1) > > The readers rely on the store_releases "pairing" with the smp_rmb() so > that the readers see things in a sane order. That is certainly a valid pairing, see also the 'SMP BARRIER PAIRING' section in memory-barriers.txt (I thought we had a table in there, but apparently that never quite made it in).