From patchwork Mon Oct 23 21:07:18 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: 116880 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5085943qgn; Mon, 23 Oct 2017 14:12:30 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R20aM2o7gP1/PDw6EyzjwuPr0vWNe4P5533OnTsTRP/u6czpbhkVNKLjytP6LRks4FNhQU X-Received: by 10.98.35.18 with SMTP id j18mr14403169pfj.37.1508793149978; Mon, 23 Oct 2017 14:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508793149; cv=none; d=google.com; s=arc-20160816; b=gg45XXEm9+P/K2wP2Lb3NcobXCYtMX0fNznwkGwlNCQl4NZf2hkhAy9DrKyT9S5gDQ PFxLq3r8wExD3b+A5eZozMAtiAZ7pRczVJtsJtyYFu6WIbpvyDLytLKzO0J1bh2/E4oq Fd6DcxVoksvPZWcNSEr6p65iyz3y9MZej1zJb7dktZvEcp3fSAinOIZyJZ4Kpz/imwO7 Gaw3HOnn8Ow7DFhq18Y3Of/Z0PR1wBVcp0QyddRdXV4C3KKyOTrtmJ1iTQmZewN4pTqA Ka42mjmaHfn3g+JRBtVVg0gTslHc3UM/b7Gs8rJMr5XUwSe45DyY2UTCAOU63wIyN2Z5 hOyg== 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=Si9oOsvj21/uKAeyZcgloffuGjyoX6PI8kD/nfaEq9I=; b=ZjNmO1TBDSdSESat7x5zDr8trxPbSvVjpoE/j5MU3DXHhX3vyDxP7MPqX+dD8sKXHg F2+NakAnWCT5uSFIIsTQBljGxdSh6QaOJ+IcTNF+XXrX0MvBQOuGiuTX3dIYBeI3F41w 3iBhRHSDPWw8GXqWOcwDET6oXZIpgDo47vmnbCoYztEkkFCDmcQQoa5Kec4WiQbRCmbg +rMDSZ/ggLWx/mO5azB8QfAW5xx49d8c1QSE8DZuCczZlihbrxEzEi8QA6GbOOZ2QoCX 6/6dI1C8C3oVj8L/lcV543M7s4G3JR85fQ8eydDopOv1FGgBe1ubxdRU8nrntKPkbfZ0 Qpgg== 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 s7si5397254pgc.415.2017.10.23.14.12.29; Mon, 23 Oct 2017 14:12:29 -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 S1751916AbdJWVM2 (ORCPT + 27 others); Mon, 23 Oct 2017 17:12:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39864 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405AbdJWVHk (ORCPT ); Mon, 23 Oct 2017 17:07:40 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9NL7KdQ124376 for ; Mon, 23 Oct 2017 17:07:40 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dskcm4tr5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 23 Oct 2017 17:07:40 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Oct 2017 17:07:38 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e12.ny.us.ibm.com (146.89.104.199) 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 b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9NL7YGt2818338; 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 276C8B205D; 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 0E261B204E; Mon, 23 Oct 2017 17:04:49 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id BBFC316C3E32; 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 08/19] net/ipv4/tcp_input.c: Kill off ACCESS_ONCE() Date: Mon, 23 Oct 2017 14:07:18 -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-0048-0000-0000-000001F9CA9E 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-0049-0000-0000-000042F5F049 Message-Id: <1508792849-3115-8-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 handle comments, leaving references to ACCESS_ONCE() instances which have been removed. As a preparatory step, this patch converts the IPv4 TCP input code and comments to use {READ,WRITE}_ONCE() consistently. ---- 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: David S. Miller --- net/ipv4/tcp_input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.5.2 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index c5d7656beeee..133e7e4d94b5 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -815,12 +815,12 @@ static void tcp_update_pacing_rate(struct sock *sk) if (likely(tp->srtt_us)) do_div(rate, tp->srtt_us); - /* ACCESS_ONCE() is needed because sch_fq fetches sk_pacing_rate + /* WRITE_ONCE() is needed because sch_fq fetches sk_pacing_rate * without any lock. We want to make sure compiler wont store * intermediate values in this location. */ - ACCESS_ONCE(sk->sk_pacing_rate) = min_t(u64, rate, - sk->sk_max_pacing_rate); + WRITE_ONCE(sk->sk_pacing_rate, min_t(u64, rate, + sk->sk_max_pacing_rate)); } /* Calculate rto without backoff. This is the second half of Van Jacobson's