|
|
Subscribe / Log in / New account

barriers using data dependency

From:  "Michael S. Tsirkin" <mst-AT-redhat.com>
To:  linux-kernel-AT-vger.kernel.org
Subject:  [PATCH RFC 0/4] barriers using data dependency
Date:  Wed, 2 Jan 2019 15:57:45 -0500
Message-ID:  <20190102205715.14054-1-mst@redhat.com>
Cc:  Jason Wang <jasowang-AT-redhat.com>, Alan Stern <stern-AT-rowland.harvard.edu>, Andrea Parri <andrea.parri-AT-amarulasolutions.com>, Will Deacon <will.deacon-AT-arm.com>, Peter Zijlstra <peterz-AT-infradead.org>, Boqun Feng <boqun.feng-AT-gmail.com>, Nicholas Piggin <npiggin-AT-gmail.com>, David Howells <dhowells-AT-redhat.com>, Jade Alglave <j.alglave-AT-ucl.ac.uk>, Luc Maranget <luc.maranget-AT-inria.fr>, "Paul E. McKenney" <paulmck-AT-linux.vnet.ibm.com>, Akira Yokosawa <akiyks-AT-gmail.com>, Daniel Lustig <dlustig-AT-nvidia.com>, linux-arch-AT-vger.kernel.org, netdev-AT-vger.kernel.org, virtualization-AT-lists.linux-foundation.org
Archive-link:  Article

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.

This patchset is also suboptimal on e.g. x86 where e.g. smp_rmb is a nop.

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(-)

-- 
MST



Copyright © 2019, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds