Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3405292ybi; Tue, 2 Jul 2019 07:14:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxc3n1VAbSGWmmY/grLliyCwtA3bPUJbiyyFB5lSjvpK9jJMrBko9sBbtByKSxEZWnbEVAx X-Received: by 2002:a63:5610:: with SMTP id k16mr5963026pgb.335.1562076879449; Tue, 02 Jul 2019 07:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562076879; cv=none; d=google.com; s=arc-20160816; b=dM0bgh2lKZ1CZ0pEbFp6l5445+g1UjPSe/rYH/Tpm9FhS2UYRcvTLYAIslgVwIENzv H3CBHvfyxcmi1LQNBkX9SBjb4qVCQgwZJglxAgd+/KV1d7ZWbRPp04WVprLLLi8d6KSz ZC3OSQHE51gPaF1Sq1Qe3L7PllWELiCxglxgr6p6szOTWy99hG5vuDurNRKuUw3+nOk4 ZhnqpJio3vwZ7DoJHVum5L4U9MwLJy9fY8+fARwWkX+fUuqVfC2mYko1DOS5diJscfj5 EQzxDvBpfkz65zIwLnAA7o8mZCRFIKeUAWdQysyaTvW2+W/mqmiZzqs/+4iYPT2sG8tN PoZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=OLWP1N8G9+xqsy7r2lyfSXDZ0uf+WJPG60bCUYfPHIs=; b=XoLqMLz1S8SWIGrG5lptinw3vZ68CtOcJJiubd/e04OZPp+JbOPrSFMzRKA4GtONHL PxKb9fc7Cf6KAs27vCupfo1Gjrv0D3qEpzSX4G2sEDh+uPmxFlxr1RkJAL2IiytALdut Bh2O4ArIxGbbkpap/ezbcwuZmROFoYZ3HiEjCotyyJ7yQqi7xg9Hn/Yb+JEhjeGIhYIO LNueNfQKOTTUbUL9QbYr1m0rTdiCsFi2Q3kLGWl3rQ53taoYfrdhFJSPOrt4yamPE8cx be33ttlLLopMCjjS5+wB8anNOSt0fypM/xLpGcpiNaSBjYxV2ef+V5aJXsYJIqcuB078 7T3Q== ARC-Authentication-Results: i=1; mx.google.com; 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 b7si14827844pfp.4.2019.07.02.07.14.24; Tue, 02 Jul 2019 07:14:39 -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; 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 S1726966AbfGBOOB (ORCPT + 99 others); Tue, 2 Jul 2019 10:14:01 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:45968 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbfGBOOB (ORCPT ); Tue, 2 Jul 2019 10:14:01 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hiJXa-0002RH-7F; Tue, 02 Jul 2019 16:13:50 +0200 From: John Ogness To: Andrea Parri Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , Sergey Senozhatsky Subject: Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation 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> <20190626224034.GK2490@worktop.programming.kicks-ass.net> <87mui2ujh2.fsf@linutronix.de> <20190629210528.GA3922@andrea> <87imsnaky1.fsf@linutronix.de> <20190630140855.GA6005@andrea> Date: Tue, 02 Jul 2019 16:13:48 +0200 In-Reply-To: <20190630140855.GA6005@andrea> (Andrea Parri's message of "Sun, 30 Jun 2019 16:08:55 +0200") Message-ID: <87ef38cyn7.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-06-30, Andrea Parri wrote: >> The significant events for 2 contexts that are accessing the same >> addresses of a descriptor are: >> >> P0(struct desc *d0) >> { >> // adding a new descriptor d0 >> >> WRITE_ONCE(d0->next, EOL); // C >> WRITE_ONCE(d0->seq, X); // D >> cmpxchg_release(newest, Y, indexof(d0)); // E >> } >> >> P1(struct desc *d1) >> { >> // adding a new descriptor d1 that comes after d0 >> >> struct desc *d0; >> int r0, r1; >> >> r0 = READ_ONCE(newest); // A >> d0 = &array[r0]; >> r1 = READ_ONCE(d0->seq); // B >> WRITE_ONCE(d0->next, Z); // F >> } >> >> d0 is the same address for P0 and P1. (The values of EOL, X, Y, Z are >> unrelated and irrelevant.) > > (1) If A reads from E, then B reads from D (or from another store > to ->seq, not reported in the snippet, which overwrites D) > > (2) If A reads from E, then F overwrites C > > This, IIUC, for the informal descriptions of the (intended) guarantees. > Back to the pairings in question: AFAICT, > > (a) For (1), we rely on the pairing: > > RELEASE from D to E (matching) ADDRESS DEP. from A to B > > (b) For (2), we rely on the pairing: > > RELEASE from C to E (matching) ADDRESS DEP. from A to F > > Does this make sense? Yes. This is what I needed to see. > IMO (and assuming that what I wrote above makes some sense), (a-b) and > (1-2) above, together with the associated annotations of the code/ops, > provide all the desired and necessary information to document MB5. > > For readability purposes, it could be nice to also keep the snippet you > provided above (but let me stress, again, that such a snippet should be > integrated with additional information as suggested above). > > As to "where to insert the memory barrier documentation", I really have > no suggestion ATM. I guess someone would split it (say, before A and E) > while others could prefer to keep it within a same inline comment. Thank you. This is the level of formalization I've been looking for. I will rework the comments (and naming) and post a v3. It is probably best for you to wait until then to look at this again. (And after going through such formal processes, even _I_ am having difficulties understanding what some of my memory barriers are supposed to be synchronizing.) John Ogness