Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp153725imu; Wed, 2 Jan 2019 16:29:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/VS6JeVU7nAoEIccLCbo8GvXh7yHcyQT9UUpUZYyTmq6q9P4dkU63IyKmb1cimyODGL32s9 X-Received: by 2002:a62:ed0f:: with SMTP id u15mr45358864pfh.188.1546475370704; Wed, 02 Jan 2019 16:29:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546475370; cv=none; d=google.com; s=arc-20160816; b=Dq3WkT2BqShrjtgQewRtc8+1IfkSZkdVnHVfZut61iy6q5Px8d8F30siEOs+9mj4IK u5elQDzH1yEE5Evl5u5i5RtVCpc/HzoZUjz9fGkkQccPnV0nnlfXmp3EHOH7V1FKgpdp wf3kVJHEwXjeACe6hZMiijt3uQ1QjgFbUlP9OclYU3MA0nCYMRAAv2CsMkM+DBZFYkXK /UgIPaou7Nuwsc4js62icjE/XLAN8vrCc4zv15llh6aZXh/uRU5qOXm+4/5IIzmYhwZH EPPSdjCCB6KGFv+6SgdpXAyiZVB4dapEqW1O4a2phUk76HxO4MQyP71ZqqaCZcjKypHQ zfzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date; bh=zC2Akm7B93ju1nZBH+nuTtAEJA8/F8mwUciKMCJ90CU=; b=VHsXPjCV+tqjQTcYD3t3MBmdrqm143d20c6G58ou7Y8lgWntwN/qnpOi5NPcBvEtEH yJ0UiO3DBWuDZAF9vemw7sJGEII3P9ynjuC8e1H3UQ29Mu+6Sx72qnRgCbM71NCf7yXp zcvJYCepN0hCR2UFpZNO8KtszrwCOdwgX7OSavLvTWOtqVusdh58WZB9FAgGiKqcZ5sW lTxofNanF5MQ82P0Jiq5lm6cqYT09P90cmqnAx+hXQqBjEEEDv3BIygrB6xHFBzvC2aq QBID4mjboXJYEv3wrp8L1D36dh/JN1CM2YPvpJCqLA1sDXJbYDngWPF83y6Spy9HJR/7 EA3g== 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 i2si48255187pfi.125.2019.01.02.16.29.13; Wed, 02 Jan 2019 16:29:30 -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 S1728264AbfABU5u (ORCPT + 99 others); Wed, 2 Jan 2019 15:57:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40820 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726409AbfABU5u (ORCPT ); Wed, 2 Jan 2019 15:57:50 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 421F2B0826; Wed, 2 Jan 2019 20:57:49 +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 362085C1A1; Wed, 2 Jan 2019 20:57:46 +0000 (UTC) Date: Wed, 2 Jan 2019 15:57:45 -0500 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Jason Wang , Alan Stern , 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: [PATCH RFC 0/4] barriers using data dependency Message-ID: <20190102205715.14054-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 02 Jan 2019 20:57:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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