[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFwwm=NA_KcxL2GQdqN=d4fLd+swLkSJYWsjV-kL61BrWg@mail.gmail.com>
Date: Fri, 25 Nov 2016 10:47:32 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Mark Rutland <mark.rutland@....com>
Cc: Dmitry Vyukov <dvyukov@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
Davidlohr Bueso <dave@...olabs.net>,
Davidlohr Bueso <dbueso@...e.de>,
Jason Wang <jasowang@...hat.com>,
KVM list <kvm@...r.kernel.org>,
netdev <netdev@...r.kernel.org>,
Paul McKenney <paulmck@...ux.vnet.ibm.com>,
virtualization <virtualization@...ts.linux-foundation.org>
Subject: Re: [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE()
On Fri, Nov 25, 2016 at 10:07 AM, Mark Rutland <mark.rutland@....com> 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
Powered by blists - more mailing lists