Skip to contentSkip to conversation

Final ACCESS_ONCE() cleanups for v4.15

PATCH In review Mark Rutland 4 participants 12 messages Nov 27, 2017 – Dec 12, 2017

Subsystems (3)
lore
Share & tools
lore

Mark Rutland

author reviewer
#0 lore raw

cover Final ACCESS_ONCE() cleanups for v4.15

Now that the ACCESS_ONCE() conversion settled in v4.15-rc1, these patches remove the ACCESS_ONCE() definitions from the kernel, along with the newly redundant checkpatch warning suggesting {READ,WRITE}_ONCE() are preferred.

One new user of ACCESS_ONCE() snuck into v4.15-rc1; the first patch in this series (previously sent on its own [1]) moves that over to READ_ONCE(). Otherwise, there are no remaining uses of ACCESS_ONCE().

Ingo, assuming there are no complaints, would you be happy to take this via the tip tree as a fixup for v4.15?

I've also pushed the series to my core/access-once-removal branch [2].

Thanks,
Mark.

[1] https://lkml.kernel.org/r/[email protected]
[2] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core/access-once-removal

Mark Rutland (4):
perf mmap: Convert ACCESS_ONCE() to READ_ONCE()
tools: include: remove ACCESS_ONCE()
compiler.h: remove ACCESS_ONCE()
checkpatch: remove ACCESS_ONCE() warning

 include/linux/compiler.h       | 47 ++++++++++--------------------------------
 scripts/checkpatch.pl          | 22 --------------------
 tools/include/linux/compiler.h | 21 ++++++++-----------
 tools/perf/util/mmap.h         |  2 +-
 4 files changed, 21 insertions(+), 71 deletions(-)
Signature · 1 line
2.11.0
author reviewer
#1 lore raw

PATCH 1/4 perf mmap: Convert ACCESS_ONCE() to READ_ONCE()

Recently there was a treewide conversion of ACCESS_ONCE() to {READ,WRITE}_ONCE(), but a new use was introduced concurrently by commit:

1695849735752d2a ("perf mmap: Move perf_mmap and methods to separate mmap.[ch] files")

Let's convert this over to READ_ONCE() so that we can remove the ACCESS_ONCE() definitions in subsequent patches.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Joe Perches <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/perf/util/mmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/mmap.h +1 -1
index efd78b827b05..3a5cb5a6e94a 100644
@@ -70,7 +70,7 @@ void perf_mmap__read_catchup(struct perf_mmap *md);
 static inline u64 perf_mmap__read_head(struct perf_mmap *mm)
 {
 	struct perf_event_mmap_page *pc = mm->base;
-	u64 head = ACCESS_ONCE(pc->data_head);
+	u64 head = READ_ONCE(pc->data_head);
 	rmb();
 	return head;
 }
Signature · 1 line
2.11.0
#2 lore raw

[tip:locking/urgent] tools/perf: Convert ACCESS_ONCE() to READ_ONCE()

tools/perf: Convert ACCESS_ONCE() to READ_ONCE()
Commit-ID:  f971e511cb7d6f1b3730248cf2967d3ccdd8874c
Gitweb:     https://git.kernel.org/tip/f971e511cb7d6f1b3730248cf2967d3ccdd8874c
Author:     Mark Rutland <[email protected]>
AuthorDate: Mon, 27 Nov 2017 10:38:21 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 12 Dec 2017 13:22:09 +0100

tools/perf: Convert ACCESS_ONCE() to READ_ONCE()

Recently there was a treewide conversion of ACCESS_ONCE() to {READ,WRITE}_ONCE(), but a new use was introduced concurrently by commit:

1695849735752d2a ("perf mmap: Move perf_mmap and methods to separate mmap.[ch] files")

Let's convert this over to READ_ONCE() so that we can remove the ACCESS_ONCE() definitions in subsequent patches.

---
 tools/perf/util/mmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/mmap.h +1 -1
index efd78b8..3a5cb5a 100644
@@ -70,7 +70,7 @@ void perf_mmap__read_catchup(struct perf_mmap *md);
 static inline u64 perf_mmap__read_head(struct perf_mmap *mm)
 {
 	struct perf_event_mmap_page *pc = mm->base;
-	u64 head = ACCESS_ONCE(pc->data_head);
+	u64 head = READ_ONCE(pc->data_head);
 	rmb();
 	return head;
 }
author reviewer
#3 lore raw

PATCH 2/4 tools: include: remove ACCESS_ONCE()

In reply to Mark Rutland

There are no longer any usersapce uses of ACCESS_ONCE(), so we can remove the definition from our userspace <linux/compiler.h>, which is only used by tools in the kernel directory (i.e. it isn't a uapi header).

This patch removes the ACCESS_ONCE() definition, and updates comments which referred to it. At the same time, some inconsistent and redundant whitespace is removed from comments.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Joe Perches <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/include/linux/compiler.h | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
tools/include/linux/compiler.h +9 -12
index 07fd03c74a77..04e32f965ad7 100644
@@ -84,8 +84,6 @@
 
 #define uninitialized_var(x) x = *(&(x))
 
-#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
-
 #include <linux/types.h>
 
 /*
@@ -135,20 +133,19 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 /*
  * Prevent the compiler from merging or refetching reads or writes. The
  * compiler is also forbidden from reordering successive instances of
- * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the
- * compiler is aware of some particular ordering.  One way to make the
- * compiler aware of ordering is to put the two invocations of READ_ONCE,
- * WRITE_ONCE or ACCESS_ONCE() in different C statements.
+ * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some
+ * particular ordering. One way to make the compiler aware of ordering is to
+ * put the two invocations of READ_ONCE or WRITE_ONCE in different C
+ * statements.
  *
- * In contrast to ACCESS_ONCE these two macros will also work on aggregate
- * data types like structs or unions. If the size of the accessed data
- * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)
- * READ_ONCE() and WRITE_ONCE()  will fall back to memcpy and print a
- * compile-time warning.
+ * These two macros will also work on aggregate data types like structs or
+ * unions. If the size of the accessed data type exceeds the word size of
+ * the machine (e.g., 32 bits or 64 bits) READ_ONCE() and WRITE_ONCE() will
+ * fall back to memcpy and print a compile-time warning.
  *
  * Their two major use cases are: (1) Mediating communication between
  * process-level code and irq/NMI handlers, all running on the same CPU,
- * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
+ * and (2) Ensuring that the compiler does not fold, spindle, or otherwise
  * mutilate accesses that either do not require ordering or that interact
  * with an explicit memory barrier or atomic instruction that provides the
  * required ordering.
Signature · 1 line
2.11.0
#4 lore raw

[tip:locking/urgent] tools/include: Remove ACCESS_ONCE()

tools/include: Remove ACCESS_ONCE()
Commit-ID:  2a22f692bbe0a7933acbd50045479ffc0fdf11f7
Gitweb:     https://git.kernel.org/tip/2a22f692bbe0a7933acbd50045479ffc0fdf11f7
Author:     Mark Rutland <[email protected]>
AuthorDate: Mon, 27 Nov 2017 10:38:22 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 12 Dec 2017 13:22:10 +0100

tools/include: Remove ACCESS_ONCE()

There are no longer any usersapce uses of ACCESS_ONCE(), so we can remove the definition from our userspace <linux/compiler.h>, which is only used by tools in the kernel directory (i.e. it isn't a uapi header).

This patch removes the ACCESS_ONCE() definition, and updates comments which referred to it. At the same time, some inconsistent and redundant whitespace is removed from comments.

---
 tools/include/linux/compiler.h | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
tools/include/linux/compiler.h +9 -12
index 07fd03c..04e32f9 100644
@@ -84,8 +84,6 @@
 
 #define uninitialized_var(x) x = *(&(x))
 
-#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
-
 #include <linux/types.h>
 
 /*
@@ -135,20 +133,19 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 /*
  * Prevent the compiler from merging or refetching reads or writes. The
  * compiler is also forbidden from reordering successive instances of
- * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the
- * compiler is aware of some particular ordering.  One way to make the
- * compiler aware of ordering is to put the two invocations of READ_ONCE,
- * WRITE_ONCE or ACCESS_ONCE() in different C statements.
+ * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some
+ * particular ordering. One way to make the compiler aware of ordering is to
+ * put the two invocations of READ_ONCE or WRITE_ONCE in different C
+ * statements.
  *
- * In contrast to ACCESS_ONCE these two macros will also work on aggregate
- * data types like structs or unions. If the size of the accessed data
- * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)
- * READ_ONCE() and WRITE_ONCE()  will fall back to memcpy and print a
- * compile-time warning.
+ * These two macros will also work on aggregate data types like structs or
+ * unions. If the size of the accessed data type exceeds the word size of
+ * the machine (e.g., 32 bits or 64 bits) READ_ONCE() and WRITE_ONCE() will
+ * fall back to memcpy and print a compile-time warning.
  *
  * Their two major use cases are: (1) Mediating communication between
  * process-level code and irq/NMI handlers, all running on the same CPU,
- * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
+ * and (2) Ensuring that the compiler does not fold, spindle, or otherwise
  * mutilate accesses that either do not require ordering or that interact
  * with an explicit memory barrier or atomic instruction that provides the
  * required ordering.
author reviewer
#5 lore raw

PATCH 3/4 compiler.h: remove ACCESS_ONCE()

In reply to Mark Rutland

There are no longer any kernelspace uses of ACCESS_ONCE(), so we can remove the definition from <linux/compiler.h>.

This patch removes the ACCESS_ONCE() definition, and updates comments which referred to it. At the same time, some inconsistent and redundant whitespace is removed from comments.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Joe Perches <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 include/linux/compiler.h | 47 +++++++++++------------------------------------
 1 file changed, 11 insertions(+), 36 deletions(-)
include/linux/compiler.h +11 -36
index 188ed9f65517..52e611ab9a6c 100644
@@ -220,21 +220,21 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 /*
  * Prevent the compiler from merging or refetching reads or writes. The
  * compiler is also forbidden from reordering successive instances of
- * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the
- * compiler is aware of some particular ordering.  One way to make the
- * compiler aware of ordering is to put the two invocations of READ_ONCE,
- * WRITE_ONCE or ACCESS_ONCE() in different C statements.
+ * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some
+ * particular ordering. One way to make the compiler aware of ordering is to
+ * put the two invocations of READ_ONCE or WRITE_ONCE in different C
+ * statements.
  *
- * In contrast to ACCESS_ONCE these two macros will also work on aggregate
- * data types like structs or unions. If the size of the accessed data
- * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)
- * READ_ONCE() and WRITE_ONCE() will fall back to memcpy(). There's at
- * least two memcpy()s: one for the __builtin_memcpy() and then one for
- * the macro doing the copy of variable - '__u' allocated on the stack.
+ * These two macros will also work on aggregate data types like structs or
+ * unions. If the size of the accessed data type exceeds the word size of
+ * the machine (e.g., 32 bits or 64 bits) READ_ONCE() and WRITE_ONCE() will
+ * fall back to memcpy(). There's at least two memcpy()s: one for the
+ * __builtin_memcpy() and then one for the macro doing the copy of variable
+ * - '__u' allocated on the stack.
  *
  * Their two major use cases are: (1) Mediating communication between
  * process-level code and irq/NMI handlers, all running on the same CPU,
- * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
+ * and (2) Ensuring that the compiler does not fold, spindle, or otherwise
  * mutilate accesses that either do not require ordering or that interact
  * with an explicit memory barrier or atomic instruction that provides the
  * required ordering.
@@ -327,29 +327,4 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 	compiletime_assert(__native_word(t),				\
 		"Need native word sized stores/loads for atomicity.")
 
-/*
- * Prevent the compiler from merging or refetching accesses.  The compiler
- * is also forbidden from reordering successive instances of ACCESS_ONCE(),
- * but only when the compiler is aware of some particular ordering.  One way
- * to make the compiler aware of ordering is to put the two invocations of
- * ACCESS_ONCE() in different C statements.
- *
- * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE
- * on a union member will work as long as the size of the member matches the
- * size of the union and the size is smaller than word size.
- *
- * The major use cases of ACCESS_ONCE used to be (1) Mediating communication
- * between process-level code and irq/NMI handlers, all running on the same CPU,
- * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
- * mutilate accesses that either do not require ordering or that interact
- * with an explicit memory barrier or atomic instruction that provides the
- * required ordering.
- *
- * If possible use READ_ONCE()/WRITE_ONCE() instead.
- */
-#define __ACCESS_ONCE(x) ({ \
-	 __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
-	(volatile typeof(x) *)&(x); })
-#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
-
 #endif /* __LINUX_COMPILER_H */
Signature · 1 line
2.11.0
#6 lore raw

[tip:locking/urgent] compiler.h: Remove ACCESS_ONCE()

compiler.h: Remove ACCESS_ONCE()
Commit-ID:  b899a850431e2dd0943205a63a68573f3e312d0d
Gitweb:     https://git.kernel.org/tip/b899a850431e2dd0943205a63a68573f3e312d0d
Author:     Mark Rutland <[email protected]>
AuthorDate: Mon, 27 Nov 2017 10:38:23 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 12 Dec 2017 13:22:10 +0100

compiler.h: Remove ACCESS_ONCE()

There are no longer any kernelspace uses of ACCESS_ONCE(), so we can remove the definition from <linux/compiler.h>.

This patch removes the ACCESS_ONCE() definition, and updates comments which referred to it. At the same time, some inconsistent and redundant whitespace is removed from comments.

---
 include/linux/compiler.h | 47 +++++++++++------------------------------------
 1 file changed, 11 insertions(+), 36 deletions(-)
include/linux/compiler.h +11 -36
index 188ed9f..52e611a 100644
@@ -220,21 +220,21 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 /*
  * Prevent the compiler from merging or refetching reads or writes. The
  * compiler is also forbidden from reordering successive instances of
- * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the
- * compiler is aware of some particular ordering.  One way to make the
- * compiler aware of ordering is to put the two invocations of READ_ONCE,
- * WRITE_ONCE or ACCESS_ONCE() in different C statements.
+ * READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some
+ * particular ordering. One way to make the compiler aware of ordering is to
+ * put the two invocations of READ_ONCE or WRITE_ONCE in different C
+ * statements.
  *
- * In contrast to ACCESS_ONCE these two macros will also work on aggregate
- * data types like structs or unions. If the size of the accessed data
- * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)
- * READ_ONCE() and WRITE_ONCE() will fall back to memcpy(). There's at
- * least two memcpy()s: one for the __builtin_memcpy() and then one for
- * the macro doing the copy of variable - '__u' allocated on the stack.
+ * These two macros will also work on aggregate data types like structs or
+ * unions. If the size of the accessed data type exceeds the word size of
+ * the machine (e.g., 32 bits or 64 bits) READ_ONCE() and WRITE_ONCE() will
+ * fall back to memcpy(). There's at least two memcpy()s: one for the
+ * __builtin_memcpy() and then one for the macro doing the copy of variable
+ * - '__u' allocated on the stack.
  *
  * Their two major use cases are: (1) Mediating communication between
  * process-level code and irq/NMI handlers, all running on the same CPU,
- * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
+ * and (2) Ensuring that the compiler does not fold, spindle, or otherwise
  * mutilate accesses that either do not require ordering or that interact
  * with an explicit memory barrier or atomic instruction that provides the
  * required ordering.
@@ -327,29 +327,4 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 	compiletime_assert(__native_word(t),				\
 		"Need native word sized stores/loads for atomicity.")
 
-/*
- * Prevent the compiler from merging or refetching accesses.  The compiler
- * is also forbidden from reordering successive instances of ACCESS_ONCE(),
- * but only when the compiler is aware of some particular ordering.  One way
- * to make the compiler aware of ordering is to put the two invocations of
- * ACCESS_ONCE() in different C statements.
- *
- * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE
- * on a union member will work as long as the size of the member matches the
- * size of the union and the size is smaller than word size.
- *
- * The major use cases of ACCESS_ONCE used to be (1) Mediating communication
- * between process-level code and irq/NMI handlers, all running on the same CPU,
- * and (2) Ensuring that the compiler does not  fold, spindle, or otherwise
- * mutilate accesses that either do not require ordering or that interact
- * with an explicit memory barrier or atomic instruction that provides the
- * required ordering.
- *
- * If possible use READ_ONCE()/WRITE_ONCE() instead.
- */
-#define __ACCESS_ONCE(x) ({ \
-	 __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \
-	(volatile typeof(x) *)&(x); })
-#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))
-
 #endif /* __LINUX_COMPILER_H */
author reviewer
#7 lore raw

PATCH 4/4 checkpatch: remove ACCESS_ONCE() warning

In reply to Mark Rutland

Now that ACCESS_ONCE() has been excised from the kernel, any uses will result in a build error, and we no longer need to whine about it in checkpatch.

This patch removes the newly redundant warning.

Cc Andy Whitcroft <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Joe Perches <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 scripts/checkpatch.pl | 22 ----------------------
 1 file changed, 22 deletions(-)
scripts/checkpatch.pl +0 -22
index 95cda3ecc66b..95c08493b78b 100755
@@ -6233,28 +6233,6 @@ sub process {
 			}
 		}
 
-# whine about ACCESS_ONCE
-		if ($^V && $^V ge 5.10.0 &&
-		    $line =~ /\bACCESS_ONCE\s*$balanced_parens\s*(=(?!=))?\s*($FuncArg)?/) {
-			my $par = $1;
-			my $eq = $2;
-			my $fun = $3;
-			$par =~ s/^\(\s*(.*)\s*\)$/$1/;
-			if (defined($eq)) {
-				if (WARN("PREFER_WRITE_ONCE",
-					 "Prefer WRITE_ONCE(<FOO>, <BAR>) over ACCESS_ONCE(<FOO>) = <BAR>\n" . $herecurr) &&
-				    $fix) {
-					$fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)\s*$eq\s*\Q$fun\E/WRITE_ONCE($par, $fun)/;
-				}
-			} else {
-				if (WARN("PREFER_READ_ONCE",
-					 "Prefer READ_ONCE(<FOO>) over ACCESS_ONCE(<FOO>)\n" . $herecurr) &&
-				    $fix) {
-					$fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)/READ_ONCE($par)/;
-				}
-			}
-		}
-
 # check for mutex_trylock_recursive usage
 		if ($line =~ /mutex_trylock_recursive/) {
 			ERROR("LOCKING",
Signature · 1 line
2.11.0
maintainer Acked-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning

Quoted 5 lines · Mark Rutland

Now that ACCESS_ONCE() has been excised from the kernel, any uses will result in a build error, and we no longer need to whine about it in checkpatch.

This patch removes the newly redundant warning.

Normally, I send checkpatch patches via Andrew Morton, but this could be merged this directly.

Quoted 43 lines
Cc Andy Whitcroft <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Joe Perches <[email protected]>
Cc Paul E. McKenney <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 scripts/checkpatch.pl | 22 ----------------------
 1 file changed, 22 deletions(-)
scripts/checkpatch.pl +0 -22
index 95cda3ecc66b..95c08493b78b 100755
@@ -6233,28 +6233,6 @@ sub process {
 			}
 		}
 
-# whine about ACCESS_ONCE
-		if ($^V && $^V ge 5.10.0 &&
-		    $line =~ /\bACCESS_ONCE\s*$balanced_parens\s*(=(?!=))?\s*($FuncArg)?/) {
-			my $par = $1;
-			my $eq = $2;
-			my $fun = $3;
-			$par =~ s/^\(\s*(.*)\s*\)$/$1/;
-			if (defined($eq)) {
-				if (WARN("PREFER_WRITE_ONCE",
-					 "Prefer WRITE_ONCE(<FOO>, <BAR>) over ACCESS_ONCE(<FOO>) = <BAR>\n" . $herecurr) &&
-				    $fix) {
-					$fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)\s*$eq\s*\Q$fun\E/WRITE_ONCE($par, $fun)/;
-				}
-			} else {
-				if (WARN("PREFER_READ_ONCE",
-					 "Prefer READ_ONCE(<FOO>) over ACCESS_ONCE(<FOO>)\n" . $herecurr) &&
-				    $fix) {
-					$fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)/READ_ONCE($par)/;
-				}
-			}
-		}
-
 # check for mutex_trylock_recursive usage
 		if ($line =~ /mutex_trylock_recursive/) {
 			ERROR("LOCKING",
author reviewer
#9 lore raw

Re: [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning

Quoted 11 lines · Joe Perches
Quoted 5 lines · Mark Rutland

Now that ACCESS_ONCE() has been excised from the kernel, any uses will result in a build error, and we no longer need to whine about it in checkpatch.

This patch removes the newly redundant warning.

Normally, I send checkpatch patches via Andrew Morton, but this could be merged this directly.

Cheers Joe!

Mark.

#10 lore raw

[tip:locking/urgent] checkpatch: Remove ACCESS_ONCE() warning

In reply to Mark Rutland
checkpatch: Remove ACCESS_ONCE() warning
Commit-ID:  8cb562b1d56fad42cbee44bdc9bc64cea41a0a8c
Gitweb:     https://git.kernel.org/tip/8cb562b1d56fad42cbee44bdc9bc64cea41a0a8c
Author:     Mark Rutland <[email protected]>
AuthorDate: Mon, 27 Nov 2017 10:38:24 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 12 Dec 2017 13:22:10 +0100

checkpatch: Remove ACCESS_ONCE() warning

Now that ACCESS_ONCE() has been excised from the kernel, any uses will result in a build error, and we no longer need to whine about it in checkpatch.

This patch removes the newly redundant warning.

---
 scripts/checkpatch.pl | 22 ----------------------
 1 file changed, 22 deletions(-)
scripts/checkpatch.pl +0 -22
index 040aa79..31031f1 100755
@@ -6233,28 +6233,6 @@ sub process {
 			}
 		}
 
-# whine about ACCESS_ONCE
-		if ($^V && $^V ge 5.10.0 &&
-		    $line =~ /\bACCESS_ONCE\s*$balanced_parens\s*(=(?!=))?\s*($FuncArg)?/) {
-			my $par = $1;
-			my $eq = $2;
-			my $fun = $3;
-			$par =~ s/^\(\s*(.*)\s*\)$/$1/;
-			if (defined($eq)) {
-				if (WARN("PREFER_WRITE_ONCE",
-					 "Prefer WRITE_ONCE(<FOO>, <BAR>) over ACCESS_ONCE(<FOO>) = <BAR>\n" . $herecurr) &&
-				    $fix) {
-					$fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)\s*$eq\s*\Q$fun\E/WRITE_ONCE($par, $fun)/;
-				}
-			} else {
-				if (WARN("PREFER_READ_ONCE",
-					 "Prefer READ_ONCE(<FOO>) over ACCESS_ONCE(<FOO>)\n" . $herecurr) &&
-				    $fix) {
-					$fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)/READ_ONCE($par)/;
-				}
-			}
-		}
-
 # check for mutex_trylock_recursive usage
 		if ($line =~ /mutex_trylock_recursive/) {
 			ERROR("LOCKING",
Tested-by on the v1 series
#11 lore raw
In reply to Mark Rutland
Quoted 5 lines · Mark Rutland

Now that the ACCESS_ONCE() conversion settled in v4.15-rc1, these patches remove the ACCESS_ONCE() definitions from the kernel, along with the newly redundant checkpatch warning suggesting {READ,WRITE}_ONCE() are preferred.

Quoted 8 lines

One new user of ACCESS_ONCE() snuck into v4.15-rc1; the first patch in this series (previously sent on its own [1]) moves that over to READ_ONCE(). Otherwise, there are no remaining uses of ACCESS_ONCE().

Ingo, assuming there are no complaints, would you be happy to take this via the tip tree as a fixup for v4.15?

I've also pushed the series to my core/access-once-removal branch [2].

For all four:

Quoted 21 lines

Thanks,
Mark.

[1] https://lkml.kernel.org/r/[email protected]
[2] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git core/access-once-removal

Mark Rutland (4):
perf mmap: Convert ACCESS_ONCE() to READ_ONCE()
tools: include: remove ACCESS_ONCE()
compiler.h: remove ACCESS_ONCE()
checkpatch: remove ACCESS_ONCE() warning

 include/linux/compiler.h       | 47 ++++++++++--------------------------------
 scripts/checkpatch.pl          | 22 --------------------
 tools/include/linux/compiler.h | 21 ++++++++-----------
 tools/perf/util/mmap.h         |  2 +-
 4 files changed, 21 insertions(+), 71 deletions(-)
Signature · 1 line
2.11.0