Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755479AbcKYRxB (ORCPT ); Fri, 25 Nov 2016 12:53:01 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:33178 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755107AbcKYRww (ORCPT ); Fri, 25 Nov 2016 12:52:52 -0500 MIME-Version: 1.0 In-Reply-To: References: <1479983114-17190-1-git-send-email-mark.rutland@arm.com> <20161124222357-mutt-send-email-mst@kernel.org> <20161125112203.GA26611@leverpostej> <32dfca07-59f3-b75a-3154-cf6b6c8538f0@de.ibm.com> <20161125122356.GB26611@leverpostej> <20161125124044.GN3092@twins.programming.kicks-ass.net> <20161125124404.GI3174@twins.programming.kicks-ass.net> <20161125145512.GA4014@Boquns-MacBook-Pro.local> <20161125161004.GA30181@leverpostej> <20161125161709.GQ3092@twins.programming.kicks-ass.net> From: Linus Torvalds Date: Fri, 25 Nov 2016 09:52:50 -0800 X-Google-Sender-Auth: mlgc09pefPeWfgYJ5H7F5U1jClI Message-ID: Subject: Re: [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE() To: Dmitry Vyukov Cc: Peter Zijlstra , Mark Rutland , Boqun Feng , Christian Borntraeger , "Michael S. Tsirkin" , LKML , Davidlohr Bueso , Davidlohr Bueso , Jason Wang , KVM list , netdev , Paul McKenney , virtualization Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1593 Lines: 41 On Fri, Nov 25, 2016 at 9:28 AM, Dmitry Vyukov wrote: On Fri, Nov 25, 2016 at 5:17 PM, Peter Zijlstra wrote: >> >> IE, they are strictly stronger than {READ,WRITE}_ONCE(). No, they are strictly bullshit. Stop this idiocy. We went through this once already. > Uh, so, READ/WRITE_ONCE are non-atomic now. I missed that. No. READ/WRITE_ONCE() are atomic *WHEN*THAT*IS*POSSIBLE*. So for something that fits in a register, it will read it in one atomic access. For something that fits in a register and is _possible_ to write atomically, it will do so. But sometimes it's not going to be atomic. We do not for a moment try to make multi-word accesses be atomic. Not even if you could try to use some magic cmpxchg16b thing. It's not "atomic" in that sense: it will be doing multiple accesses. Similarly, if you try to write a 8- or 16-bit word on alpha with WRITE_ONCE() or you try to do other things, you have what's coming to you. And they just force some "copy to stable storage" when it isn't (ie a "memcpy()" is not necessarily a single access and might be done as multiple overlapping reads, but the end result is stable). So trying to make anything else out of them is f*cking stupid. READ_ONCE() and friends do the right thing. Trying to limit them is *wrong*, because the restrictions would simply make them less useful. And trying to make up something new is pointless and stupid. So leave this code alone. Don't add some stupid "SINGLE_LOAD()" crap. That's just moronic. READ_ONCE() is that, and so much more. Linus