From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752136AbcAARX4 (ORCPT ); Fri, 1 Jan 2016 12:23:56 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:35121 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbcAARXu (ORCPT ); Fri, 1 Jan 2016 12:23:50 -0500 Subject: Re: [PATCH v2 32/32] virtio_ring: use virt_store_mb To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org References: <1451572003-2440-1-git-send-email-mst@redhat.com> <1451572003-2440-33-git-send-email-mst@redhat.com> Cc: Peter Zijlstra , Arnd Bergmann , linux-arch@vger.kernel.org, Andrew Cooper , virtualization@lists.linux-foundation.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, user-mode-linux-devel@lists.sourceforge.net, adi-buildroot-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, xen-devel@lists.xenproject.org From: Sergei Shtylyov Message-ID: <5686B622.6070600@cogentembedded.com> Date: Fri, 1 Jan 2016 20:23:46 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1451572003-2440-33-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On 12/31/2015 10:09 PM, Michael S. Tsirkin wrote: > We need a full barrier after writing out event index, using > virt_store_mb there seems better than open-coding. As usual, we need a > wrapper to account for strong barriers. > > It's tempting to use this in vhost as well, for that, we'll > need a variant of smp_store_mb that works on __user pointers. > > Signed-off-by: Michael S. Tsirkin > --- > include/linux/virtio_ring.h | 12 ++++++++++++ > drivers/virtio/virtio_ring.c | 15 +++++++++------ > 2 files changed, 21 insertions(+), 6 deletions(-) > > diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h > index f3fa55b..3a74d91 100644 > --- a/include/linux/virtio_ring.h > +++ b/include/linux/virtio_ring.h > @@ -45,6 +45,18 @@ static inline void virtio_wmb(bool weak_barriers) > wmb(); > } > > +static inline void virtio_store_mb(bool weak_barriers, > + __virtio16 *p, __virtio16 v) > +{ > + if (weak_barriers) > + virt_store_mb(*p, v); > + else > + { The kernel coding style dictates: if (weak_barriers) { virt_store_mb(*p, v); } else { > + WRITE_ONCE(*p, v); > + mb(); > + } > +} > + [...] MBR, Sergei