Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6571120ybl; Mon, 23 Dec 2019 08:02:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxT9kgdri9qYeZJ0RDGbJUYjsX6vBdsNGWVl1G0J7/zNwgzZuJJuX272ywExRdGnYezH7/8 X-Received: by 2002:a05:6830:2057:: with SMTP id f23mr29984462otp.110.1577116971339; Mon, 23 Dec 2019 08:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577116971; cv=none; d=google.com; s=arc-20160816; b=iEAnF4ZH7h4pCqCZG+lLNRJfydpiX5Qx4U31qTmQa1MjeUl575G+gl3/bvNrQb0dOO wVw/OPCIuPQ4dAwYJN8tstH+0Gzma9aem4wyWr5b/lKuT4oQ4eQ/aSMU++H1Y+RF+Hr+ liniO60n8uJUBhc6q8uarxH7Mrt1gx5gErTBc6QDuntAP1zRg2OrA2cO/lmrhseuxlR0 F3I0/UPFaMxFuNiIj+TrmOweqxHTHv+J2SGotHSzgvN/U+Kn2lvEtfl+wvQilbo0cG95 cS+gHrc97HDEr3jeNKkW5336Kv69yavppiS3MrlvEK7ppOISnMq5mTgK3Zc0/XbzQ5Yp xeDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :subject:cc:to:from; bh=RN8rhrnsBVA/l1JVjN1o9EPSmJifr+NATpwuDhz6iJE=; b=MFCPczd7wCS8Q7dQPFFu6c4xFQEWrkHNILAMl9JX4hE/V3emcZYRQvDiX0SBnvKTB7 qs5W+IXWYPgFp2TCIiauOolheRcLn8/THo+IgKXAQA4/Y+5D3vRuT7P1VGd6cAX6OTFW Esws/V/0oU/5kZUg3blZI1JxTkn/W5duXCAReEE79jioNGRJ4LGfh5zoJmMHKHbY230X uLk7mPGpCQa14C4I22RlPvqan4eCwZ9E0/UhDZLISp9Np1yhxz34WnK3fMW4diWI/pvb LGleFW6mBNgz9WBJ1xJ5bHoYpAsGHEUXE5745qurAWzCGXL9ED5RPD5Re9GQK8HYQK30 Ivbw== 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 w7si10445091otq.250.2019.12.23.08.02.34; Mon, 23 Dec 2019 08:02:51 -0800 (PST) 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 S1726756AbfLWQBY (ORCPT + 99 others); Mon, 23 Dec 2019 11:01:24 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:37989 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfLWQBY (ORCPT ); Mon, 23 Dec 2019 11:01:24 -0500 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1ijQ8k-0004jA-Bx; Mon, 23 Dec 2019 17:01:02 +0100 From: John Ogness To: Andrea Parri Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , Sergey Senozhatsky , Brendan Higgins , kexec@lists.infradead.org Subject: Re: [RFC PATCH v5 1/3] printk-rb: new printk ringbuffer implementation (writer) References: <20191128015235.12940-1-john.ogness@linutronix.de> <20191128015235.12940-2-john.ogness@linutronix.de> <20191221142235.GA7824@andrea> Date: Mon, 23 Dec 2019 17:01:00 +0100 Message-ID: <87imm7820z.fsf@linutronix.de> 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 Hi Andrea, On 2019-12-21, Andrea Parri wrote: >> + *desc_out = READ_ONCE(*desc); >> + >> + /* Load data before re-checking state. */ >> + smp_rmb(); /* matches LMM_REF(desc_reserve:A) */ > > I looked for a matching WRITE_ONCE() or some other type of marked write, > but I could not find it. What is the rationale? Or what did I miss? This smp_rmb() matches LMM_TAG(desc_reserve:A). >> + do { >> + next_lpos = get_next_lpos(data_ring, begin_lpos, size); >> + >> + if (!data_push_tail(rb, data_ring, >> + next_lpos - DATA_SIZE(data_ring))) { >> + /* Failed to allocate, specify a data-less block. */ >> + blk_lpos->begin = INVALID_LPOS; >> + blk_lpos->next = INVALID_LPOS; >> + return NULL; >> + } >> + } while (!atomic_long_try_cmpxchg(&data_ring->head_lpos, &begin_lpos, >> + next_lpos)); >> + >> + /* >> + * No barrier is needed here. The data validity is defined by >> + * the state of the associated descriptor. They are marked as >> + * invalid at the moment. And only the winner of the above >> + * cmpxchg() could write here. >> + */ > > The (successful) CMPXCHG provides a full barrier. This comment suggests > that that could be somehow relaxed? Or the comment could be improved? You are correct. There is no need for the full barrier here. This code is based on Petr's POC. I focussed on making sure needed barriers are in place, but did not try to eliminate excessive barriers. > (The patch introduces a number of CMPXCHG: similar questions would > apply to those other instances...) LMM_TAG(data_push_tail:A) is the only CMPXCHG that requires its full barrier. All others can be relaxed. I will make this change for the next series. Thanks for taking time for this. John Ogness