From patchwork Mon Oct 9 18:28:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115291 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2864010qgn; Mon, 9 Oct 2017 11:32:43 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCIaol7fCW0tWp8lRHbwtg4koLxSiecXyZyd0yf1Y+YKX+7WccyrQht/w+ag/7OOhTOyDtC X-Received: by 10.84.238.136 with SMTP id v8mr9792675plk.37.1507573963477; Mon, 09 Oct 2017 11:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507573963; cv=none; d=google.com; s=arc-20160816; b=d04LZDLlMTlF3chnDcOjA0jWvXAR4y/v8S3RmGs0swbRdSJNoAEWdcw8BWsAmwybAV xvHdAavTWD+xKHbUQdtQxm9hCuVQ71iRCNgR7TKIXzzge5p+jjMtuoXj85jAt5aQaags 8NOuYC93E8mmof6kyxQxEWaOpsCmGzxWPJcO2+g+8MBNKACXNHNUdwF+nQxFQ+Tx4/wG 1YBIZD1RerHiQLCdSCmCwrO9uzn6CtWUSfwDvjq+LWLIFfPZJfG2cyjUm6W3zzDgDNk9 zgaDvzqDMQWi77FfXKMznfJejFCN8so+UlS7THMYs6YQt8w+pG4OrZ/e2TLfq7N9tf/f nZQQ== 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=P24Qhvs5Qy0oE+Hw3MQXAjw1CwbTYTbGAo8l466hS1o=; b=BF73oZfsd53TEsC/LDfwwUsa6VA3slQT4Z7BEaobUzTSf6/CDnIsSvPmfgPLCb3crY fY5AEoBz1NDDCqFT7yIiWQl59dw5r2XNzjeuwP0TdS18KeTUzhO+duOOxy1HSshJ/VAN ht5zUdqK+EVXJxZaC2Uu+VGMIxh8ivOMXP22E/J9q3XDQ47Hgh+FTCWzZnnsqpJF1/jz PYux0RsvMBqjMdTR4JbOfscxOKwLsdHuK2pR5Lc0i57MAJ/uTlG4VAMS4A1bXC5sIoDQ c+SrZhpWS+qYN79JlFlA5wKKyKC2g1yTHELE3WXumNU3mDGYjfeAoNXo+B6tRgqUVnhi 5ENQ== 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 h128si7460402pfb.194.2017.10.09.11.32.43; Mon, 09 Oct 2017 11:32:43 -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 S1755453AbdJIScm (ORCPT + 26 others); Mon, 9 Oct 2017 14:32:42 -0400 Received: from foss.arm.com ([217.140.101.70]:33810 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755310AbdJISaz (ORCPT ); Mon, 9 Oct 2017 14:30:55 -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 E98B6165D; Mon, 9 Oct 2017 11:30:54 -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 2E1643F483; Mon, 9 Oct 2017 11:30:54 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , Johannes Berg , "David S. Miller" Subject: [PATCH 09/13] net: average: kill off ACCESS_ONCE() Date: Mon, 9 Oct 2017 19:28:46 +0100 Message-Id: <1507573730-8083-10-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 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(-) -- 1.9.1 diff --git a/include/linux/average.h b/include/linux/average.h index 7ddaf34..7a72de4 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 */