From patchwork Mon Oct 9 18:28:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115288 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2862796qgn; Mon, 9 Oct 2017 11:31:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDiDoUzPvC/Nm9rIE89yH1S39HiLXGjO7sdDWKrVEt78QjMxqva6f7qDM5yvJMpMT1qYkxa X-Received: by 10.99.47.6 with SMTP id v6mr9904737pgv.452.1507573876932; Mon, 09 Oct 2017 11:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507573876; cv=none; d=google.com; s=arc-20160816; b=b1UoOZ9wxbbhpb1nDq3/sPuorD/N/Wm9OzpekaPhmYx+eHdn9mxhAryP1FXuNWLBRp NIfJtj0uT/5huGIJiBrTkPHjrbmVBeEn70nM+jyH2NMHPiMgU1O9HG+zpfbK8VYtH1my /+sQWhU6UGGctyQmscrxTgVO0iV5kqwi5SV5rENTfvhMf/iA2gB/rN1uGpLPfr2I66NS p2q2wKYbgiIWDB2HrkeDTNawaXFomvOX1nUh7hwjsxT+0xgyxmk1xAmYYfNZUq9+PKSB +9813LnklAQWSUnR5m+h42WxYJl2vuKxBgQuQ92baPf+74eWbgFakKhf/7hcJ/ROLqjH KZtw== 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=PwSqlqgpaSIxPSHYYIb/1W2S+k792QfoMF/ZbzIqa7k=; b=JQTAH6B4rWGbOlbHxTMkB6K+sdDgVyRLZiaJyEnDf+7Ev3wTY3lbvKADEQmYidKCtj pZiQUiDzkDaOhw+qrKqZvbDaKXvjm5/beF06VSQH12piSC1u0TwRrlWHHkF47xJLOk7i NlPWckBakim770Spva7uql/NmVTU0z5bxccWVhZmW1Q1VcDPZjrBzFmoOw++Jrp7lmlG 0Ft8EFiGlZ1P8dO5ZvvTKetoluBrf2z5ovC0+Fp63G6cF2X0dvb7FSPINU0jgpPkexaG Ho6gRsqVSLRPzCFcGyf/q+epYzc/7uGsnnyTzXLaEBa/hGupbFfPY/urPQXrDFX205zr y0SQ== 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 o29si3658752pfi.90.2017.10.09.11.31.16; Mon, 09 Oct 2017 11:31:16 -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 S1755430AbdJISbO (ORCPT + 26 others); Mon, 9 Oct 2017 14:31:14 -0400 Received: from foss.arm.com ([217.140.101.70]:33848 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754216AbdJISbB (ORCPT ); Mon, 9 Oct 2017 14:31:01 -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 83D341688; Mon, 9 Oct 2017 11:31:01 -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 BAB7B3F483; Mon, 9 Oct 2017 11:31:00 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , "Paul E. McKenney" Subject: [PATCH 13/13] rcutorture: formal: prepare for ACCESS_ONCE() removal Date: Mon, 9 Oct 2017 19:28:50 +0100 Message-Id: <1507573730-8083-14-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. 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, this patch reworks the rcutorture formal tests to use an intermediate __ACCESS_ONCE() helper, which will avoid {READ,WRITE}_ONCE() being turned into tautological definitions. There should be no functional change as a result of this patch. Cc: Paul E. McKenney Signed-off-by: Mark Rutland --- tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/barriers.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/barriers.h b/tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/barriers.h index 6687acc..ee4e4f8 100644 --- a/tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/barriers.h +++ b/tools/testing/selftests/rcutorture/formal/srcu-cbmc/src/barriers.h @@ -34,8 +34,9 @@ #define rs_smp_mb() do {} while (0) #endif -#define ACCESS_ONCE(x) (*(volatile typeof(x) *) &(x)) -#define READ_ONCE(x) ACCESS_ONCE(x) -#define WRITE_ONCE(x, val) (ACCESS_ONCE(x) = (val)) +#define __ACCESS_ONCE(x) (*(volatile typeof(x) *) &(x)) +#define ACCESS_ONCE(x) __ACCESS_ONCE(x) +#define READ_ONCE(x) __ACCESS_ONCE(x) +#define WRITE_ONCE(x, val) (__ACCESS_ONCE(x) = (val)) #endif