linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15
@ 2017-11-27 10:38 Mark Rutland
  2017-11-27 10:38 ` [PATCH 1/4] perf mmap: Convert ACCESS_ONCE() to READ_ONCE() Mark Rutland
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Mark Rutland @ 2017-11-27 10:38 UTC (permalink / raw)
  To: linux-kernel, mingo; +Cc: acme, apw, joe, mark.rutland, paulmck, peterz

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/20171114103138.9931-1-mark.rutland@arm.com
[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(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/4] perf mmap: Convert ACCESS_ONCE() to READ_ONCE()
  2017-11-27 10:38 [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Mark Rutland
@ 2017-11-27 10:38 ` Mark Rutland
  2017-12-12 15:06   ` [tip:locking/urgent] tools/perf: " tip-bot for Mark Rutland
  2017-11-27 10:38 ` [PATCH 2/4] tools: include: remove ACCESS_ONCE() Mark Rutland
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Mark Rutland @ 2017-11-27 10:38 UTC (permalink / raw)
  To: linux-kernel, mingo; +Cc: acme, apw, joe, mark.rutland, paulmck, peterz

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.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/perf/util/mmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index efd78b827b05..3a5cb5a6e94a 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -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;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] tools: include: remove ACCESS_ONCE()
  2017-11-27 10:38 [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Mark Rutland
  2017-11-27 10:38 ` [PATCH 1/4] perf mmap: Convert ACCESS_ONCE() to READ_ONCE() Mark Rutland
@ 2017-11-27 10:38 ` Mark Rutland
  2017-12-12 15:07   ` [tip:locking/urgent] tools/include: Remove ACCESS_ONCE() tip-bot for Mark Rutland
  2017-11-27 10:38 ` [PATCH 3/4] compiler.h: remove ACCESS_ONCE() Mark Rutland
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Mark Rutland @ 2017-11-27 10:38 UTC (permalink / raw)
  To: linux-kernel, mingo; +Cc: acme, apw, joe, mark.rutland, paulmck, peterz

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.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 tools/include/linux/compiler.h | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c74a77..04e32f965ad7 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -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.
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/4] compiler.h: remove ACCESS_ONCE()
  2017-11-27 10:38 [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Mark Rutland
  2017-11-27 10:38 ` [PATCH 1/4] perf mmap: Convert ACCESS_ONCE() to READ_ONCE() Mark Rutland
  2017-11-27 10:38 ` [PATCH 2/4] tools: include: remove ACCESS_ONCE() Mark Rutland
@ 2017-11-27 10:38 ` Mark Rutland
  2017-12-12 15:07   ` [tip:locking/urgent] compiler.h: Remove ACCESS_ONCE() tip-bot for Mark Rutland
  2017-11-27 10:38 ` [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning Mark Rutland
  2017-11-27 21:11 ` [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Paul E. McKenney
  4 siblings, 1 reply; 12+ messages in thread
From: Mark Rutland @ 2017-11-27 10:38 UTC (permalink / raw)
  To: linux-kernel, mingo; +Cc: acme, apw, joe, mark.rutland, paulmck, peterz

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.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 include/linux/compiler.h | 47 +++++++++++------------------------------------
 1 file changed, 11 insertions(+), 36 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 188ed9f65517..52e611ab9a6c 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -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 */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning
  2017-11-27 10:38 [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Mark Rutland
                   ` (2 preceding siblings ...)
  2017-11-27 10:38 ` [PATCH 3/4] compiler.h: remove ACCESS_ONCE() Mark Rutland
@ 2017-11-27 10:38 ` Mark Rutland
  2017-11-27 10:50   ` Joe Perches
  2017-12-12 15:07   ` [tip:locking/urgent] checkpatch: Remove " tip-bot for Mark Rutland
  2017-11-27 21:11 ` [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Paul E. McKenney
  4 siblings, 2 replies; 12+ messages in thread
From: Mark Rutland @ 2017-11-27 10:38 UTC (permalink / raw)
  To: linux-kernel, mingo; +Cc: acme, apw, joe, mark.rutland, paulmck, peterz

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.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 scripts/checkpatch.pl | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 95cda3ecc66b..95c08493b78b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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",
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning
  2017-11-27 10:38 ` [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning Mark Rutland
@ 2017-11-27 10:50   ` Joe Perches
  2017-11-27 10:58     ` Mark Rutland
  2017-12-12 15:07   ` [tip:locking/urgent] checkpatch: Remove " tip-bot for Mark Rutland
  1 sibling, 1 reply; 12+ messages in thread
From: Joe Perches @ 2017-11-27 10:50 UTC (permalink / raw)
  To: Mark Rutland, linux-kernel, mingo; +Cc: acme, apw, paulmck, peterz

On Mon, 2017-11-27 at 10:38 +0000, Mark Rutland wrote:
> 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.

Acked-by: Joe Perches <joe@perches.com>

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

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Andy Whitcroft <apw@canonical.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Joe Perches <joe@perches.com>
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> ---
>  scripts/checkpatch.pl | 22 ----------------------
>  1 file changed, 22 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 95cda3ecc66b..95c08493b78b 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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",

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning
  2017-11-27 10:50   ` Joe Perches
@ 2017-11-27 10:58     ` Mark Rutland
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Rutland @ 2017-11-27 10:58 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, mingo, acme, apw, paulmck, peterz

On Mon, Nov 27, 2017 at 02:50:00AM -0800, Joe Perches wrote:
> On Mon, 2017-11-27 at 10:38 +0000, Mark Rutland wrote:
> > 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.
> 
> Acked-by: Joe Perches <joe@perches.com>
> 
> Normally, I send checkpatch patches via Andrew Morton,
> but this could be merged this directly.

Cheers Joe!

Mark.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15
  2017-11-27 10:38 [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Mark Rutland
                   ` (3 preceding siblings ...)
  2017-11-27 10:38 ` [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning Mark Rutland
@ 2017-11-27 21:11 ` Paul E. McKenney
  4 siblings, 0 replies; 12+ messages in thread
From: Paul E. McKenney @ 2017-11-27 21:11 UTC (permalink / raw)
  To: Mark Rutland; +Cc: linux-kernel, mingo, acme, apw, joe, peterz

On Mon, Nov 27, 2017 at 10:38:20AM +0000, Mark Rutland wrote:
> 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].

For all four:

Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

> Thanks,
> Mark.
> 
> [1] https://lkml.kernel.org/r/20171114103138.9931-1-mark.rutland@arm.com
> [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(-)
> 
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [tip:locking/urgent] tools/perf: Convert ACCESS_ONCE() to READ_ONCE()
  2017-11-27 10:38 ` [PATCH 1/4] perf mmap: Convert ACCESS_ONCE() to READ_ONCE() Mark Rutland
@ 2017-12-12 15:06   ` tip-bot for Mark Rutland
  0 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Mark Rutland @ 2017-12-12 15:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, peterz, tglx, paulmck, torvalds, acme, linux-kernel, joe,
	hpa, mark.rutland

Commit-ID:  f971e511cb7d6f1b3730248cf2967d3ccdd8874c
Gitweb:     https://git.kernel.org/tip/f971e511cb7d6f1b3730248cf2967d3ccdd8874c
Author:     Mark Rutland <mark.rutland@arm.com>
AuthorDate: Mon, 27 Nov 2017 10:38:21 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: apw@canonical.com
Link: http://lkml.kernel.org/r/20171127103824.36526-2-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 tools/perf/util/mmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h
index efd78b8..3a5cb5a 100644
--- a/tools/perf/util/mmap.h
+++ b/tools/perf/util/mmap.h
@@ -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;
 }

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:locking/urgent] tools/include: Remove ACCESS_ONCE()
  2017-11-27 10:38 ` [PATCH 2/4] tools: include: remove ACCESS_ONCE() Mark Rutland
@ 2017-12-12 15:07   ` tip-bot for Mark Rutland
  0 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Mark Rutland @ 2017-12-12 15:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: joe, mingo, acme, mark.rutland, peterz, paulmck, tglx,
	linux-kernel, hpa, torvalds

Commit-ID:  2a22f692bbe0a7933acbd50045479ffc0fdf11f7
Gitweb:     https://git.kernel.org/tip/2a22f692bbe0a7933acbd50045479ffc0fdf11f7
Author:     Mark Rutland <mark.rutland@arm.com>
AuthorDate: Mon, 27 Nov 2017 10:38:22 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: apw@canonical.com
Link: http://lkml.kernel.org/r/20171127103824.36526-3-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 tools/include/linux/compiler.h | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..04e32f9 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -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.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:locking/urgent] compiler.h: Remove ACCESS_ONCE()
  2017-11-27 10:38 ` [PATCH 3/4] compiler.h: remove ACCESS_ONCE() Mark Rutland
@ 2017-12-12 15:07   ` tip-bot for Mark Rutland
  0 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Mark Rutland @ 2017-12-12 15:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, joe, peterz, mingo, paulmck, linux-kernel, acme, torvalds,
	tglx, mark.rutland

Commit-ID:  b899a850431e2dd0943205a63a68573f3e312d0d
Gitweb:     https://git.kernel.org/tip/b899a850431e2dd0943205a63a68573f3e312d0d
Author:     Mark Rutland <mark.rutland@arm.com>
AuthorDate: Mon, 27 Nov 2017 10:38:23 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: apw@canonical.com
Link: http://lkml.kernel.org/r/20171127103824.36526-4-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/compiler.h | 47 +++++++++++------------------------------------
 1 file changed, 11 insertions(+), 36 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 188ed9f..52e611a 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -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 */

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [tip:locking/urgent] checkpatch: Remove ACCESS_ONCE() warning
  2017-11-27 10:38 ` [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning Mark Rutland
  2017-11-27 10:50   ` Joe Perches
@ 2017-12-12 15:07   ` tip-bot for Mark Rutland
  1 sibling, 0 replies; 12+ messages in thread
From: tip-bot for Mark Rutland @ 2017-12-12 15:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: joe, hpa, peterz, paulmck, linux-kernel, torvalds, mingo, apw,
	mark.rutland, tglx

Commit-ID:  8cb562b1d56fad42cbee44bdc9bc64cea41a0a8c
Gitweb:     https://git.kernel.org/tip/8cb562b1d56fad42cbee44bdc9bc64cea41a0a8c
Author:     Mark Rutland <mark.rutland@arm.com>
AuthorDate: Mon, 27 Nov 2017 10:38:24 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: acme@redhat.com
Link: http://lkml.kernel.org/r/20171127103824.36526-5-mark.rutland@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 scripts/checkpatch.pl | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 040aa79..31031f1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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",

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-12-12 15:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-27 10:38 [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Mark Rutland
2017-11-27 10:38 ` [PATCH 1/4] perf mmap: Convert ACCESS_ONCE() to READ_ONCE() Mark Rutland
2017-12-12 15:06   ` [tip:locking/urgent] tools/perf: " tip-bot for Mark Rutland
2017-11-27 10:38 ` [PATCH 2/4] tools: include: remove ACCESS_ONCE() Mark Rutland
2017-12-12 15:07   ` [tip:locking/urgent] tools/include: Remove ACCESS_ONCE() tip-bot for Mark Rutland
2017-11-27 10:38 ` [PATCH 3/4] compiler.h: remove ACCESS_ONCE() Mark Rutland
2017-12-12 15:07   ` [tip:locking/urgent] compiler.h: Remove ACCESS_ONCE() tip-bot for Mark Rutland
2017-11-27 10:38 ` [PATCH 4/4] checkpatch: remove ACCESS_ONCE() warning Mark Rutland
2017-11-27 10:50   ` Joe Perches
2017-11-27 10:58     ` Mark Rutland
2017-12-12 15:07   ` [tip:locking/urgent] checkpatch: Remove " tip-bot for Mark Rutland
2017-11-27 21:11 ` [PATCH 0/4] Final ACCESS_ONCE() cleanups for v4.15 Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).