From patchwork Mon Oct 23 21:07:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 116875 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5084168qgn; Mon, 23 Oct 2017 14:10:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T5CUzgNJy2CyCtnodPD2EjX6Bvwq9oosX3gvCbniYQ6XMx001U31WT85RN8t3A1oM1/Zhd X-Received: by 10.99.99.71 with SMTP id x68mr12997646pgb.334.1508793006525; Mon, 23 Oct 2017 14:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508793006; cv=none; d=google.com; s=arc-20160816; b=ULCbcIjmON1E8aPnfRUD7YyVhbt5KaIbDVxjFD8Eg6cCJCdYElCBw0oDz1Pwfx0fxi 6TLWGTDMbakPi0E0waDfGumCKrVnn0tTpPwOPW01bqLAkhUpEF127fgho1oeSncaKFOP nXWqXyjhcxPDM76HMh4VIJNp0fWBBC2hTL9UncpmKlVuATU2OZHXZPvHw1EXeUYXs6Yf b/efN6AHRn9qEZ7dYqGor5fb9oHRl5PiXGObcPK0ovbv6ZLG9zMnPZ5eKjwA1IM1h+ta AGx8sVgb3u6y1/ZA+8VlQYUrITe3V3DqXRcaJ1m2379jnwxFUCu1o+FbaEeYVTfoYYGA CuoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=xFfwhM0lyoZ3WyBNOw/ppt+FOK/l10xKwmehGWynFtc=; b=Km80WlJiwJKHynWHyA1jfAf2hLQoGpHG4EDwzygrGDE6UT+IHJlxdPxqAUmy/Ei8U9 LaarHKggcoRxjGZd9398mWQDe4HcxNBjkMKwWKvkAPWkFLDcSroM9oVF/U0eK6GiHC3W 1QrcJHg6pBZR2CYNnu81gzZW3Wf9n1j0PQnKM9fbTOlVy6FbvXTLrbIDR40gTt+xMF9/ vzaPI8Q2/zQT/zHtR9Xc/CQ6kxbcTtU87qWqk8yhRX84jY7llv7JXD46qWrL8qfT3m70 SCl8qJL7HcHY1BuoXy0q5kTPeHsuuRVbx0oNFlPMfsD4bVVA8vGfebV5zaKbV03Gq8/s R+pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w62si5312086pgd.355.2017.10.23.14.10.06; Mon, 23 Oct 2017 14:10:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932291AbdJWVKE (ORCPT + 27 others); Mon, 23 Oct 2017 17:10:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42736 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751618AbdJWVHm (ORCPT ); Mon, 23 Oct 2017 17:07:42 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9NL6Baw003105 for ; Mon, 23 Oct 2017 17:07:42 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dsku2bdhr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 23 Oct 2017 17:07:41 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Oct 2017 17:07:40 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Oct 2017 17:07:35 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9NL7YOj46661682; Mon, 23 Oct 2017 21:07:34 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 350ABB205E; Mon, 23 Oct 2017 17:04:49 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.80.218.156]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 1B9DAB205A; Mon, 23 Oct 2017 17:04:49 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id C6CAE16C4135; Mon, 23 Oct 2017 14:07:33 -0700 (PDT) From: "Paul E. McKenney" To: mingo@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, will.deacon@arm.com, mark.rutland@arm.com, snitzer@redhat.com, thor.thayer@linux.intel.com, viro@zeniv.linux.org.uk, davem@davemloft.net, shuah@kernel.org, mpe@ellerman.id.au, tj@kernel.org, torvalds@linux-foundation.org Subject: [PATCH 10/19] samples: mic/mpssd/mpssd.c: Kill off ACCESS_ONCE() Date: Mon, 23 Oct 2017 14:07:20 -0700 X-Mailer: git-send-email 2.5.2 In-Reply-To: <20171023210408.GA2930@linux.vnet.ibm.com> References: <20171023210408.GA2930@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17102321-0008-0000-0000-00000294C77C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007941; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00935454; UDB=6.00471299; IPR=6.00715720; BA=6.00005656; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017676; XFM=3.00000015; UTC=2017-10-23 21:07:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102321-0009-0000-0000-00003718CA94 Message-Id: <1508792849-3115-10-git-send-email-paulmck@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-23_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710230296 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland For several reasons, it is desirable to use {READ,WRITE}_ONCE() in preference to ACCESS_ONCE(), and new code is expected to use one of the former. So far, there's been no reason to change most existing uses of ACCESS_ONCE(), as these aren't currently harmful. However, for some features it is necessary to instrument reads and writes separately, which is not possible with ACCESS_ONCE(). This distinction is critical to correct operation. The bulk of the kernel code can be transformed via Coccinelle to use {READ,WRITE}_ONCE(), though this only modifies users of ACCESS_ONCE(), and not the implementation itself. As such, it has the potential to break homebrew ACCESS_ONCE() macros seen in some user code in the kernel tree (e.g. the virtio code, as fixed in commit ea9156fb3b71d9f7). To avoid fragility if/when that transformation occurs, and to align with the preferred usage of {READ,WRITE}_ONCE(), this patch updates the MPSSD sample code to use READ_ONCE() rather than ACCESS_ONCE(). There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Shuah Khan --- samples/mic/mpssd/mpssd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.5.2 diff --git a/samples/mic/mpssd/mpssd.c b/samples/mic/mpssd/mpssd.c index 49db1def1721..f42ce551bb48 100644 --- a/samples/mic/mpssd/mpssd.c +++ b/samples/mic/mpssd/mpssd.c @@ -65,7 +65,7 @@ static struct mic_info mic_list; /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE) -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) +#define READ_ONCE(x) (*(volatile typeof(x) *)&(x)) #define GSO_ENABLED 1 #define MAX_GSO_SIZE (64 * 1024) @@ -382,7 +382,7 @@ disp_iovec(struct mic_info *mic, struct mic_copy_desc *copy, static inline __u16 read_avail_idx(struct mic_vring *vr) { - return ACCESS_ONCE(vr->info->avail_idx); + return READ_ONCE(vr->info->avail_idx); } static inline void txrx_prepare(int type, bool tx, struct mic_vring *vr, @@ -523,7 +523,7 @@ spin_for_descriptors(struct mic_info *mic, struct mic_vring *vr) { __u16 avail_idx = read_avail_idx(vr); - while (avail_idx == le16toh(ACCESS_ONCE(vr->vr.avail->idx))) { + while (avail_idx == le16toh(READ_ONCE(vr->vr.avail->idx))) { #ifdef DEBUG mpsslog("%s %s waiting for desc avail %d info_avail %d\n", mic->name, __func__,