Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp596080ybg; Tue, 9 Jun 2020 08:10:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW0XlrePpzfkejfLk1XQqFzElnltaG/5HNuR8PuTfcYqkchgdKUSjBgB0EXHBkYPBulYpn X-Received: by 2002:aa7:da17:: with SMTP id r23mr28284431eds.261.1591715420094; Tue, 09 Jun 2020 08:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591715420; cv=none; d=google.com; s=arc-20160816; b=CRIRUGGPdfsyudLas1ZqMVIJsA3Sts11tkJSVTxwwld0KTzELrTkj61HIkujRQwvTE i9f4pWv9QsAZoUMFsfr9EOJ4Dk/ynPokwqsMBPs9UKTsgmqD/X6+QhqtxcJAbIeUut+g OB4KzKGvFmdGSFL4lnISwjUKA+K/XxgGPoYDNlsYkMchGHSm9dipJDRitG2BsK9F+5iV Teyc5fOWt9pes0/tPlg0T3nUAiv5HbvXWGPD2L/bTnJEVei4cjNfhq97pmGY4yeXE00Y co+IYEuaD/mkN/I9PExBrFyUnUPn+96MYWdVXAp+dtAwBFiMZKLsPD4CrwR5zC2RqGgt GNgA== 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=l8HyeOObLHHheFsBXw3J9PXlQKFkeWWGUY3I39SdY4E=; b=AVIcnKQo+GCg3f+sBWAUubAOD+Jxn5R8CkwnKV8sGnF3V6+EBN8pjVmhGc+hshqCV3 2bvc73Qh4R5/WnDR4ywa+/hu8dnutxbGhjMHALmTAgW20RIwllfPeEvbchJlUYEa9lSY CadcbNzpbjS7PnGQ/JRbY+Odas0lgf1+WRABT1NqUJQ+YTGK8JXysG+UoZ8MKF8H/dIR EvxoQhX8xb5NPVMm/gvZN8y6mVNi8EUzQ6VTwWThOIQn0IKpEK09PvgG1enENipiPYLl OQ5Qoyvf3Kh8wUX6mwp8GsA6ba3uXX0tFygZpLBqqgajLeitLYcr/+4sdl6CqjuSIBEN B8Ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n23si10868447edq.264.2020.06.09.08.09.55; Tue, 09 Jun 2020 08:10:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730364AbgFIPEA (ORCPT + 99 others); Tue, 9 Jun 2020 11:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbgFIPD7 (ORCPT ); Tue, 9 Jun 2020 11:03:59 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52FB2C05BD1E for ; Tue, 9 Jun 2020 08:03:59 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=vostro) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1jifnA-0003HL-4R; Tue, 09 Jun 2020 17:03:56 +0200 From: John Ogness To: Petr Mladek Cc: Peter Zijlstra , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Paul McKenney Subject: Re: Full barrier in data_push_tail(): was [PATCH v2 2/3] printk: add lockless buffer References: <20200501094010.17694-1-john.ogness@linutronix.de> <20200501094010.17694-3-john.ogness@linutronix.de> <20200609094820.GC23752@linux-b0ei> Date: Tue, 09 Jun 2020 17:03:54 +0200 In-Reply-To: <20200609094820.GC23752@linux-b0ei> (Petr Mladek's message of "Tue, 9 Jun 2020 11:48:20 +0200") Message-ID: <87h7vkuvqd.fsf@vostro.fn.ogness.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-09, Petr Mladek wrote: >> --- /dev/null >> +++ b/kernel/printk/printk_ringbuffer.c >> +static bool data_push_tail(struct printk_ringbuffer *rb, >> + struct prb_data_ring *data_ring, >> + unsigned long lpos) >> +{ >> ... >> + >> + /* >> + * Guarantee any descriptor states that have transitioned to >> + * reusable are stored before pushing the tail lpos. This >> + * allows readers to identify if data has expired while >> + * reading the descriptor. This pairs with desc_read:D. >> + */ >> + smp_mb(); /* LMM(data_push_tail:C) */ > > The comment does not explain why we need a full barrier here. > > I would add something like: > > * Full barrier is necessary because the descriptors > * might have been made reusable also by other CPUs. Agreed. Somehow I missed that explanation for this comment. > For people like me, it would be great to add also link to a more > detailed explanation, for example, the litmus tests, or something > even more human readable ;-) I think that it is a "rather" common > problem. I wonder whether it is already documented somewhere. I believe that memory barriers need to be formally documented. Perhaps in such a way that litmus tests can be easily generated. Tools could greatly assist with this. It is my hope that my memory barrier documentation can spark some ideas about how we could do this. (Doing all this manually really sucks!) John Ogness