mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
Please do not apply this to mainline directly, instead please re-run the
coccinelle script shown below and apply its output.
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 harmful, and changing them results in
churn.
However, for some features, the read/write distinction is critical to
correct operation. To distinguish these cases, separate read/write
accessors must be used. This patch migrates (most) remaining
ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
coccinelle script:
----
// Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
// WRITE_ONCE()
// $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
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 <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
b03a0fe0c5
commit
6aa7de0591
180 changed files with 383 additions and 385 deletions
|
|
@ -381,7 +381,7 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
|
|||
* in __get_user_pages if userfaultfd_release waits on the
|
||||
* caller of handle_userfault to release the mmap_sem.
|
||||
*/
|
||||
if (unlikely(ACCESS_ONCE(ctx->released))) {
|
||||
if (unlikely(READ_ONCE(ctx->released))) {
|
||||
/*
|
||||
* Don't return VM_FAULT_SIGBUS in this case, so a non
|
||||
* cooperative manager can close the uffd after the
|
||||
|
|
@ -477,7 +477,7 @@ int handle_userfault(struct vm_fault *vmf, unsigned long reason)
|
|||
vmf->flags, reason);
|
||||
up_read(&mm->mmap_sem);
|
||||
|
||||
if (likely(must_wait && !ACCESS_ONCE(ctx->released) &&
|
||||
if (likely(must_wait && !READ_ONCE(ctx->released) &&
|
||||
(return_to_userland ? !signal_pending(current) :
|
||||
!fatal_signal_pending(current)))) {
|
||||
wake_up_poll(&ctx->fd_wqh, POLLIN);
|
||||
|
|
@ -586,7 +586,7 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
|
|||
set_current_state(TASK_KILLABLE);
|
||||
if (ewq->msg.event == 0)
|
||||
break;
|
||||
if (ACCESS_ONCE(ctx->released) ||
|
||||
if (READ_ONCE(ctx->released) ||
|
||||
fatal_signal_pending(current)) {
|
||||
/*
|
||||
* &ewq->wq may be queued in fork_event, but
|
||||
|
|
@ -833,7 +833,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
|
|||
struct userfaultfd_wake_range range = { .len = 0, };
|
||||
unsigned long new_flags;
|
||||
|
||||
ACCESS_ONCE(ctx->released) = true;
|
||||
WRITE_ONCE(ctx->released, true);
|
||||
|
||||
if (!mmget_not_zero(mm))
|
||||
goto wakeup;
|
||||
|
|
|
|||
Loading…
Reference in a new issue