Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753364AbcKYLeG (ORCPT ); Fri, 25 Nov 2016 06:34:06 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44281 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751294AbcKYLd4 (ORCPT ); Fri, 25 Nov 2016 06:33:56 -0500 Subject: Re: [PATCH 0/3] virtio/vringh: kill off ACCESS_ONCE() To: Mark Rutland , "Michael S. Tsirkin" References: <1479983114-17190-1-git-send-email-mark.rutland@arm.com> <20161124222357-mutt-send-email-mst@kernel.org> <20161125112203.GA26611@leverpostej> Cc: linux-kernel@vger.kernel.org, dave@stgolabs.net, dbueso@suse.de, dvyukov@google.com, jasowang@redhat.com, kvm@vger.kernel.org, netdev@vger.kernel.org, paulmck@linux.vnet.ibm.com, virtualization@lists.linux-foundation.org From: Christian Borntraeger Date: Fri, 25 Nov 2016 12:33:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161125112203.GA26611@leverpostej> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16112511-0020-0000-0000-0000023A99C5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16112511-0021-0000-0000-00001E71E3DF Message-Id: <32dfca07-59f3-b75a-3154-cf6b6c8538f0@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-25_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611250203 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2144 Lines: 54 On 11/25/2016 12:22 PM, Mark Rutland wrote: > On Thu, Nov 24, 2016 at 10:36:58PM +0200, Michael S. Tsirkin wrote: >> On Thu, Nov 24, 2016 at 10:25:11AM +0000, Mark Rutland wrote: >>> For several reasons, it would be beneficial to kill off ACCESS_ONCE() >>> tree-wide, in favour of {READ,WRITE}_ONCE(). These work with aggregate types, >>> more obviously document their intended behaviour, and are necessary for tools >>> like KTSAN to work correctly (as otherwise reads and writes cannot be >>> instrumented separately). >>> >>> While it's possible to script the bulk of this tree-wide conversion, some cases >>> such as the virtio code, require some manual intervention. This series moves >>> the virtio and vringh code over to {READ,WRITE}_ONCE(), in the process fixing a >>> bug in the virtio headers. >>> >>> Thanks, >>> Mark. >> >> I don't have a problem with this specific patchset. > > Good to hear. :) > > Does that mean you're happy to queue these patches? Or would you prefer > a new posting at some later point, with ack/review tags accumulated? > >> Though I really question the whole _ONCE APIs esp with >> aggregate types - these seem to generate a memcpy and >> an 8-byte read/writes sometimes, and I'm pretty sure this simply >> can't be read/written at once on all architectures. > > Yes, in cases where the access is larger than the machine can perform in > a single access, this will result in a memcpy. > > My understanding is that this has always been the case with > ACCESS_ONCE(), where multiple accesses were silently/implicitly > generated by the compiler. > > We could add some compile-time warnings for those cases. I'm not sure if > there's a reason we avoided doing that so far; perhaps Christian has a > some idea. My first version had this warning, but it was removed later on as requested by Linus http://lkml.iu.edu/hypermail/linux/kernel/1503.3/02670.html ---snip--- Get rid of the f*cking size checks etc on READ_ONCE() and friends. They are about - wait for it - "reading a value once". Note how it doesn't say ANYTHING about "atomic" or anything like that. It's about reading *ONCE*. ---snip---