Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp214135imu; Wed, 2 Jan 2019 18:04:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN5qifEnr0HuUfko51ALrqJXKp6GkQdz5ZrHK6cPIkBcR6ivpPH2HgySTdKXgp5gpnZOU3Qq X-Received: by 2002:a17:902:28e6:: with SMTP id f93mr44851900plb.239.1546481085157; Wed, 02 Jan 2019 18:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546481085; cv=none; d=google.com; s=arc-20160816; b=OJ0eSXBRc/8U3xRRgidPHKeaRpoEN+QJZUAg//n57eqWzoaSPm0fZ95mN2i+vOsPZw /qEkV/fFhPRToshdnB+iAkfSP03aO67nhES3GpE3TWFmsSMwz7TGIRN/WF/DHHboU2If yAjpRSZBl2bJVdUL4tYctATsmoEp709hFCOMTdaEf8oT299ju0JTJarVYlR+Je4fpurV Qn89Bra10t/cXHU0C4rP0iYnXqYF6kqXgWxci4ino8JPoxctX3L/CcV0YSQAhESySjRw Sp8y+teC3wIAP1I1Mew+7RdKWfLz46YjrvBa3BSvScNzqfBlbiIUWf9OAooOmlydgwmj Q3ng== 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:in-reply-to :subject:cc:to:from:date; bh=EXbf2kaV8c12IGSSocuat+REFlDzDpqaqxx6VdBUjyU=; b=iQxnva4NeXHwfZjdAemoHzz5Fvh8Ywwxs0jdzN33+YPt0cYtP2q8Z4Bku6n14cJD94 MFiAKXM8GPMecq2HAVVykhkM4U4AIVX54b6bMiQyGzXsEvPe3qhWzpcFFn67inyxwA/c rEv1pA5YFZ7+9vcs0SHDL2i9gorMTbJBGignJIECYh3jsIGCvsio0GZUHnaqRhGVGvpF pDzCDRhSIbz+u7RDQ2aEHlHK8CEaGpuwT8WoazViS6ezqX0VQaheeTpEGPBarGp4w0hD hc0ayDElYHs0qXXRaszSMlPxu4wx1B/d1jIXHw/XVzHAzkHlixiwoLswNPf892eCy8jb Yctg== 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 g98si50654707plb.99.2019.01.02.18.04.04; Wed, 02 Jan 2019 18:04:45 -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 S1726235AbfABVgm (ORCPT + 99 others); Wed, 2 Jan 2019 16:36:42 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:53766 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726089AbfABVgl (ORCPT ); Wed, 2 Jan 2019 16:36:41 -0500 Received: (qmail 10623 invoked by uid 2102); 2 Jan 2019 16:36:40 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 2 Jan 2019 16:36:40 -0500 Date: Wed, 2 Jan 2019 16:36:40 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Michael S. Tsirkin" 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 , , , Subject: Re: [PATCH RFC 0/4] barriers using data dependency In-Reply-To: <20190102205715.14054-1-mst@redhat.com> Message-ID: 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 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? > 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 > 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(-)