Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp250030imu; Wed, 2 Jan 2019 19:02:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN7kJYSLyxxKSqu9kUqTt74qDmlBJS5T/Xfao2GpRpPxc5uwPWRy58fUkhy2PlhJO+LSVZ+5 X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr44769776plq.195.1546484549865; Wed, 02 Jan 2019 19:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546484549; cv=none; d=google.com; s=arc-20160816; b=rH1xWxkvfZD0gsWTGbmcjHVA1KSB+Eer8M7GKfhsasSRIeBN4gJgFFaOaJh8w0QBXQ t6JvpDwVYZA0lLlkrdxJIg/yCDZCEo7IImEUvCKNtl7VXOKh6nxVtIxqxR1rzznXEwdw WLjt9vD2W++Vq+LrFaZ47N1Zxrjpjh97wt37yaNKJWqybb4v3uQdpH8Yrk72n5EzuHVP RhIcGc5fpgfiqowjQPSFCmyF0eGqczOewF4FKFvpNrIfljQO8SKZBPh+6L+yQDa31JeO ZZhV3Mst9iAm+wVqVJuEMY61PutUgO5EfbLXgp8lpTjx12i7JCkgeKBj4Pzw7kLxQVVt 0kMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=r1LOw83EOtympi+lukWv1ZVYnRdYNE/Kqh/0riKEMQ8=; b=QQcqjUOPI5f0HkEIK+V/YTw35IUsq5EdLBNP8hKQCflHg15glBvz6L8YFaKzQjEVCb QG0XnBzicwhFH9KqoQhKMStnRdWPcikwd//BkfqakP7Y59NSE4VVcuPgcGUpJh+43A34 SMC6GXpuAcBkRFf/Wktd6RvWfBzql0XcST0i/JstZ5Ubsx7G91Y3nRxK3wgp0xkma6vH c/seUKIK54rMkRxf14RNYimUVfp+SUu0l+VRI5pDlYycOMO8XyLpS4Me2JwaQB/wA+Z0 cOYhDfhztdlcSc7Jg93tLTiF7enMa1sCJbRsrUSSdP1tZyA5UNJ05/gnq7h6L2b/i3Jm JcLg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 27si8124714pgp.135.2019.01.02.19.02.15; Wed, 02 Jan 2019 19:02:29 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbfABXEi (ORCPT + 99 others); Wed, 2 Jan 2019 18:04:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40250 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfABXEi (ORCPT ); Wed, 2 Jan 2019 18:04:38 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A4A5C0587EA; Wed, 2 Jan 2019 23:04:37 +0000 (UTC) Received: from redhat.com (ovpn-120-148.rdu2.redhat.com [10.10.120.148]) by smtp.corp.redhat.com (Postfix) with SMTP id 9BA2019936; Wed, 2 Jan 2019 23:04:32 +0000 (UTC) Date: Wed, 2 Jan 2019 18:04:31 -0500 From: "Michael S. Tsirkin" To: Alan Stern Cc: linux-kernel@vger.kernel.org, Jason Wang , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , linux-arch@vger.kernel.org, netdev@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH RFC 0/4] barriers using data dependency Message-ID: <20190102175247-mutt-send-email-mst@kernel.org> References: <20190102205715.14054-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 02 Jan 2019 23:04:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 02, 2019 at 04:36:40PM -0500, Alan Stern wrote: > On Wed, 2 Jan 2019, Michael S. Tsirkin wrote: > > > So as explained in Documentation/memory-barriers.txt e.g. > > a load followed by a store require a full memory barrier, > > to avoid store being ordered before the load. > > Similarly load-load requires a read memory barrier. > > > > Thinking about it, we can actually create a data dependency > > by mixing the first loaded value into the pointer being > > accessed. > > > > This adds an API for this and uses it in virtio. > > > > Written over the holiday and build tested only so far. > > You are using the terminology from memory-barriers.txt, referring to > the new dependency you create as a data dependency. However, > tools/memory-model/* uses a more precise name, calling it an address > dependency. Could you change the comments in the patches to use this > name instead? Sure, sounds good. While I'm at it, should memory-barriers.txt be switched over too? > > This patchset is also suboptimal on e.g. x86 where e.g. smp_rmb is a nop. > > This should be easy to fix with an architecture-specific override. > > Alan Stern Absolutely. It does however mean that we'll need several variants: mb/rmb, smp/dma/virt/mandatory. I am still trying to decide whether it's good since it documents the kind of barrier that we are trying to use - or bad since it's more verbose and makes you choose one where they are all pretty cheap. > > Sending out for early feedback/flames. > > > > Michael S. Tsirkin (4): > > include/linux/compiler*.h: fix OPTIMIZER_HIDE_VAR > > include/linux/compiler.h: allow memory operands > > barriers: convert a control to a data dependency > > virtio: use dependent_ptr_mb > > > > Documentation/memory-barriers.txt | 20 ++++++++++++++++++++ > > arch/alpha/include/asm/barrier.h | 1 + > > drivers/virtio/virtio_ring.c | 6 ++++-- > > include/asm-generic/barrier.h | 18 ++++++++++++++++++ > > include/linux/compiler-clang.h | 5 ++--- > > include/linux/compiler-gcc.h | 4 ---- > > include/linux/compiler-intel.h | 4 +--- > > include/linux/compiler.h | 8 +++++++- > > 8 files changed, 53 insertions(+), 13 deletions(-)