Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp19671102ybl; Sat, 4 Jan 2020 06:34:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwk1t0T/QevM4mUgcHACoim12Sa564EiB+FLIo3CTh9Zecpm7RToSkaVeMkeX6wZbScaOl5 X-Received: by 2002:a9d:24ea:: with SMTP id z97mr107400940ota.345.1578148487133; Sat, 04 Jan 2020 06:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578148487; cv=none; d=google.com; s=arc-20160816; b=q+yf0J+gFiSYhn5WrMGDOjJzcb3lAL627B7La1UcFmlXUoH2Z0ryzkQpUaJUZjXd4D /SFq13Oe5ojPCoYN+WbV3gDNcUrek+DNvJogxmsqTxJl+5fmb3CoiEE9XEu5Fe/ZJ9CA 3R7EuP5LZoQtiZnq5hZ8un/14JCJtwNb5e2LvO16i9xXXekSMXyCdDNNCerbucnZExbo awEApN66OnBfDpBrSSw/OCzHZDhSRnKwvxs/m/BLeZD2epub8JIDX2N4S12f6MB4k1os wcFqVoPIsMaFSAQIxdBaqLO2VH1FLOHw55HOkMLgnPn54o70l8FP3JUM1CGpYLXE+brR X1JQ== 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=89bNMHaRa6L3vpJUbDlkwRJl5HZuJPwEMdwIffQFxwc=; b=VCDCLYjB4w9DkWc0rXXUt35M0Yko+7Fcko6AcunGnexNOl4i0MYxlulBowg9eIOwy3 bvXhcSSfuiqmV9K0hqemGAo4LtHN8H3eMafDx4JW4EI09WfSkp610azE71KmL1AxUl+G p5hKQ9TKBNak6BuGNuTA9aMtLvPSn6QoZcgG0XBbCbON5fjHhAQCocjRf7aj3s7jrXQm ArqIRZw3i0BlcN2dx+q4JnhVQQbqgPAPREKgFFcywAkF8cSWeaXYKJ49m01OAqt9mPMU T09VjRmIo6ovQR55wF4Jh4yVb/ZqY8P52j+QHCAX+ygGPAsMeVa6A8EABpSJaCpesuvk KQXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=atnmd4Ro; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si30120435oib.246.2020.01.04.06.34.35; Sat, 04 Jan 2020 06:34:47 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=atnmd4Ro; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726402AbgADOdZ (ORCPT + 99 others); Sat, 4 Jan 2020 09:33:25 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43738 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgADOdX (ORCPT ); Sat, 4 Jan 2020 09:33:23 -0500 Received: by mail-wr1-f68.google.com with SMTP id d16so44949748wre.10 for ; Sat, 04 Jan 2020 06:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=89bNMHaRa6L3vpJUbDlkwRJl5HZuJPwEMdwIffQFxwc=; b=atnmd4Roh9tkaAm3zd5I+/gPbZ6bZ00+TNkaXeP5xsra4QOFaNBEZDLi9PQNEaMg6B rAv+/X/ZFsMV5PHNpjs8pnnQlAOF+ulqk1FRUaBO58tChSwwhR8KJHKxQt2vUTd4n5mi xCtRXWIbnTeZmks/zThswc0/bCCzENXIk1XPvm1N/pH2UKlXKeW2Qlv6CBjmk5pODIqK sTZ5D1+vcoUTTdT4IaFdGEwp76w1U3taEN2WneZKhXDqR03Bv1xY7yoSYn6T+k85RoX0 /jK56Es7trvUUnyXUzgph+AHwmiru3ARx4UZo8UE0UjD0g3tTVXNSBFHrVPDN3viYimF Iy8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=89bNMHaRa6L3vpJUbDlkwRJl5HZuJPwEMdwIffQFxwc=; b=PTfvsIfyCGDXllt7acHuddVMa6pXtAH7vlzIwQsCF5BPN9UTlAjRk2eC8e7Nq+Zmam s7lXfREcIjkOBc3lEOEo5PFAAfKdhqaOBH2k+L2+dxOFO5m8u8Ws35fvZvIvKvtCkAT1 rieOVz8P4WNAgK0Ty0Lk6Ukx0WcLG0PNUp+sE+0+UzFyWWmBW4lvpUMvjMPLSfEs3M/y catFcUH8zBzg9A7nj1Ix4nmNeN25vvWaf5CULFpeFzfa67BuT5TofZxceN7gkBKc0x9Y MvbQk5KmfLuzbDhc8N18fi4ghXjbBRdfnGeHtqMWoFPLt2aLVYxEaEE2jydo5CglWG7c AeKQ== X-Gm-Message-State: APjAAAUpZqwlPFbPY/kmnmoXuLMAiFydxDdP9qJ/OOVQb4etKEyJxMNJ C+Iib3N6KNlBfC8nyO/8D6M= X-Received: by 2002:a5d:4d06:: with SMTP id z6mr91702666wrt.339.1578148401442; Sat, 04 Jan 2020 06:33:21 -0800 (PST) Received: from andrea ([93.187.88.19]) by smtp.gmail.com with ESMTPSA id n8sm65204186wrx.42.2020.01.04.06.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jan 2020 06:33:20 -0800 (PST) Date: Sat, 4 Jan 2020 15:33:14 +0100 From: Andrea Parri To: Petr Mladek Cc: John Ogness , linux-kernel@vger.kernel.org, Peter Zijlstra , 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) Message-ID: <20200104143314.GA3468@andrea> References: <20191128015235.12940-1-john.ogness@linutronix.de> <20191128015235.12940-2-john.ogness@linutronix.de> <20191221142235.GA7824@andrea> <87imm7820z.fsf@linutronix.de> <20200103102420.n6i5chgxaygfvx5h@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200103102420.n6i5chgxaygfvx5h@pathway.suse.cz> 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, Jan 03, 2020 at 11:24:20AM +0100, Petr Mladek wrote: > On Mon 2019-12-23 17:01:00, John Ogness wrote: > > 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? > > Good question. READ_ONCE() looks superfluous here because it is > surrounded by two read barriers. In each case, there is no > corresponding WRITE_ONCE(). > > Note that we are copying the entire struct prb_desc here. All values > are written only when state_val is in desc_reserved state. It happens > between two full write barriers: > > + A writer is allowed to modify the descriptor after successful > cmpxchg in desc_reserve(), see LMM_TAG(desc_reserve:A). > > + The writer must not touch the descriptor after changing > state_var to committed state, see > LMM_TAG(prb_commit:A) in prb_commit(). > > These barriers are mentioned in the comments for the two > read barriers here. Thanks for these remarks. As usual, I'd recommend to (try to) map those comments into litmus tests and check with the LKMM simulator. > BTW: Documentation/memory-barriers.txt describes various aspects of > the memory barriers. It describes implicit barriers provided > by spin locks, mutexes, semaphores, and various scheduler-related > operations. > > But I can't find any explanation of the various variants of the atomic > operations: acquire, release, fetch, return, try, relaxed. I can find > some clues here and there but it is hard to get the picture. Documentation/atomic_t.txt could serve this purpose. Please have a look there and let me know if you have any comments. Thanks, Andrea