Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755738AbcKYSrn (ORCPT ); Fri, 25 Nov 2016 13:47:43 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:34166 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755680AbcKYSre (ORCPT ); Fri, 25 Nov 2016 13:47:34 -0500 MIME-Version: 1.0 In-Reply-To: <20161125180649.GC30811@leverpostej> References: <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> <20161125180649.GC30811@leverpostej> From: Linus Torvalds Date: Fri, 25 Nov 2016 10:47:32 -0800 X-Google-Sender-Auth: oLyhlPwPRRzElZYzl60m6HonwlY Message-ID: Subject: Re: [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE() To: Mark Rutland Cc: Dmitry Vyukov , Peter Zijlstra , 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: 1037 Lines: 28 On Fri, Nov 25, 2016 at 10:07 AM, Mark Rutland wrote: > On Fri, Nov 25, 2016 at 09:52:50AM -0800, Linus Torvalds wrote: >> READ/WRITE_ONCE() are atomic *WHEN*THAT*IS*POSSIBLE*. > >> But sometimes it's not going to be atomic. > > That's the problem. It has never really been much of a problem, and quite frankly, the solution would never be to add _another_ crazy new function that will just confuse everybody. If you have code that depends on atomicity of READ_ONCE() and friends, then you should add the appropriate built-time assert to *your* code. Not to some random generic function that others care about and that others do _not_ have problems with. So if you have a data structure in virtio that is architecture-dependent and might not be a word size, you add the BUILD_BUG_ON(sizeof(mytype) > sizeof(long)); or whatever. With a big comment saying "this needs to actually fit in a single register so that we can do atomic accesses". You do not screw it up for everybody else. Linus