From patchwork Mon Oct 23 21:07:19 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: 116867 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5082463qgn; Mon, 23 Oct 2017 14:08:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RMSvrAE2q3d6/fxblpbb76MT+nLINleoVuKWdgCM4TCARCJIne8Nin7VOQjWYIMM4Hk2bt X-Received: by 10.84.232.138 with SMTP id i10mr11532115plk.104.1508792886308; Mon, 23 Oct 2017 14:08:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508792886; cv=none; d=google.com; s=arc-20160816; b=GX4ehe9PBlhK6Uv58ga0l3sN6BVKV0P6Y0ma7WP4hFz3ghcjYRixkBxxySMVfjtl2b +7EEF/GoyPUdYFzXr15u5A7RgzTcfMAmw++7/ZoDrUhxkSLuIoNT8vhwgEvejfOrRxEs 5KoSBvot/A9JnmckUE+2X+TNaAQQUd8CSfTzE/YUIDLZVq0MfTGbeJqRwLeqbaFqruI3 yGmw/OViubwQsDxcNwkA/crV0fNbpC4hswPBpQR/5omYsfttMzc9sFXF6AR7k3RwQQcZ CzbrSJGNffUN6+Bazu5CpoXyTKvgyMPBFxjSR71TbwsNDlWWqSDdgJfCCTSmiaUTr6uv GMfA== 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=ek4SX58ny5T8usGBBazF4NrnMpaXqRXkB11Gn6tirL4=; b=EmLFzzTMG+BWb9Z+GkGP15mXG6M90qvQXZc73wgnU2EAQxOgeuze2hGbeRsojidFTp NUsG734YrsUK2m8DCec+0YjS3Aa+MuI0Y2lvC+tySqF1eblU3ZkmSf/PJETe1TuzoPL/ B0rUiPYHCdERA6x9HSsPBz6WBm7QwdzXhrO0WrGOQBg3OHzloOn24LLZguhWjvzKNhZb lnRvApJuVX5CvJj314TsZ1oKnT+5w5wNBF8M0gDuVOKcFgjVn9WDIy67l2lApF1IVdm7 OkoRKSy2he0m9g8ZRKx758DZxu8EvXtlaoBqoTIJwBJNOiwr+PZaZ5FG+emONLMLt0z/ jaPw== 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 1si4459473plx.766.2017.10.23.14.08.05; Mon, 23 Oct 2017 14:08: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 S1751804AbdJWVIE (ORCPT + 27 others); Mon, 23 Oct 2017 17:08:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57832 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751591AbdJWVHm (ORCPT ); Mon, 23 Oct 2017 17:07:42 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9NL7MjE031183 for ; Mon, 23 Oct 2017 17:07:41 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dsjcg7ebu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 23 Oct 2017 17:07:41 -0400 Received: from localhost by e16.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 b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 23 Oct 2017 17:07:36 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9NL7WUj37879838; Mon, 23 Oct 2017 21:07:35 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 308DAB2056; Mon, 23 Oct 2017 17:04:50 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.80.218.156]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 0DEA3B2052; Mon, 23 Oct 2017 17:04:50 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id C1DC316C3FB5; 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, Johannes Berg Subject: [PATCH 09/19] net: average: Kill off ACCESS_ONCE() Date: Mon, 23 Oct 2017 14:07:19 -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-0024-0000-0000-000002E6C971 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:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102321-0025-0000-0000-000045D1D80B Message-Id: <1508792849-3115-9-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. It's possible to transform the bulk of kernel code using the Coccinelle script below. However, this doesn't pick up some uses, including those in . As a preparatory step, this patch converts the file to use {READ,WRITE}_ONCE() consistently. At the same time, this patch addds missing includes necessary for {READ,WRITE}_ONCE(), *BUG_ON*(), and ilog2(). ---- virtual patch @ depends on patch @ expression E1, E2; @@ - ACCESS_ONCE(E1) = E2 + WRITE_ONCE(E1, E2) @ depends on patch @ expression E; @@ - ACCESS_ONCE(E) + READ_ONCE(E) ---- Signed-off-by: Mark Rutland Cc: Johannes Berg Cc: David S. Miller --- include/linux/average.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.5.2 Reviewed-by: Johannes Berg diff --git a/include/linux/average.h b/include/linux/average.h index 7ddaf340d2ac..3f462292269c 100644 --- a/include/linux/average.h +++ b/include/linux/average.h @@ -1,6 +1,10 @@ #ifndef _LINUX_AVERAGE_H #define _LINUX_AVERAGE_H +#include +#include +#include + /* * Exponentially weighted moving average (EWMA) * @@ -48,7 +52,7 @@ static inline void ewma_##name##_add(struct ewma_##name *e, \ unsigned long val) \ { \ - unsigned long internal = ACCESS_ONCE(e->internal); \ + unsigned long internal = READ_ONCE(e->internal); \ unsigned long weight_rcp = ilog2(_weight_rcp); \ unsigned long precision = _precision; \ \ @@ -57,10 +61,10 @@ BUILD_BUG_ON((_precision) > 30); \ BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \ \ - ACCESS_ONCE(e->internal) = internal ? \ + WRITE_ONCE(e->internal, internal ? \ (((internal << weight_rcp) - internal) + \ (val << precision)) >> weight_rcp : \ - (val << precision); \ + (val << precision)); \ } #endif /* _LINUX_AVERAGE_H */