From patchwork Mon Oct 9 18:28:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115285 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2862538qgn; Mon, 9 Oct 2017 11:31:00 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAULHNkkKxkMPGaiFfcGq8BnF+vwNSwR/4sCKS2ihHdZG+stuJPRsK4rvmzP2YVszvlt6XS X-Received: by 10.99.63.199 with SMTP id m190mr9957868pga.275.1507573860864; Mon, 09 Oct 2017 11:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507573860; cv=none; d=google.com; s=arc-20160816; b=eyqoHaPVjrVFH6HxZFVhTaH01ZljjWqnBcFgqi52H1Co+rimECfKlxrhKLAz5XVfPu yIH4xo6sEb9pDoFNxRQL1U2ckpxoA9mCYEtaoD4v8QEyetXrW9xAIJTVW6LA4Jh+OhAu 61Jby8WuMclqPD0Knukyo3jnxtaDxZPhh3HDWaoRwbX2dgLZg6JZcc6dwkQ3wV2YwpMW I7H+omDL0wygRDWQBnr2ak3+l9ccZ0H/q+dYmKcITfMCTc/Ty77Iq8F0K0MyM7nvGdEp ZFOn8enrgxGARg5hSj6SsBSn9dvnDUwjiZvrcF2UfGyLrXMbh43Hhlpbr9fSZR2ME4h4 D0Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=xvXabnzEX4Hk0OmSP1cDO/UiXm4jiS1mQ9FpDzdwETI=; b=IfMSHEBmBjiyIbyk753l4QqUTqmjA/fNLWez/ww5pcrc1tSFDAZ6o2JUEpjfVSDKEq AFA3sJBP6lqutTiJkm+hxtlAhzu3yER0OD+PrC6hFtvzoAU1OiaG0ScGyTfckmeTmDuh toTc6wPDJ+5CvnHA/oaz65rWWM3iB9DiFFMji0HpSw45+tNvNEAEHoVrWhArf34zG/tX e5ITh4uADZEciWYAVFA+BqBqISyX/RGYb7FtxrT8Dl7K60PeRk32Wvx5yeGughgjo1vO itofDs3nmmel0/ipGXyhNHG9UxnXq7PB8uo0GTdGEi7f+Np7XoGxzkLsBa+GRREed9QE spiQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e72si7432058pfm.35.2017.10.09.11.31.00; Mon, 09 Oct 2017 11:31:00 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755371AbdJISa5 (ORCPT + 26 others); Mon, 9 Oct 2017 14:30:57 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33802 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754216AbdJISax (ORCPT ); Mon, 9 Oct 2017 14:30:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A8BC165C; Mon, 9 Oct 2017 11:30:53 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A34413F483; Mon, 9 Oct 2017 11:30:52 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , "David S. Miller" Subject: [PATCH 08/13] net/ipv4/tcp_input.c: kill off ACCESS_ONCE() Date: Mon, 9 Oct 2017 19:28:45 +0100 Message-Id: <1507573730-8083-9-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507573730-8083-1-git-send-email-mark.rutland@arm.com> References: <1507573730-8083-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.9.1 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index c5d7656..0b3bb19 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