Skip to content

Commit

Permalink
mm: change mm_update_next_owner() to update mm->owner with WRITE_ONCE
Browse files Browse the repository at this point in the history
The RCU reader uses rcu_dereference() inside rcu_read_lock critical
sections, so the writer shall use WRITE_ONCE.  Just a cleanup, we still
rely on gcc to emit atomic writes in other places.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andrea Arcangeli <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: "Kirill A . Shutemov" <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: zhong jiang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
aagit authored and torvalds committed May 15, 2019
1 parent c3f3ce0 commit 987717e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void mm_update_next_owner(struct mm_struct *mm)
* freed task structure.
*/
if (atomic_read(&mm->mm_users) <= 1) {
mm->owner = NULL;
WRITE_ONCE(mm->owner, NULL);
return;
}

Expand Down Expand Up @@ -462,7 +462,7 @@ void mm_update_next_owner(struct mm_struct *mm)
* most likely racing with swapoff (try_to_unuse()) or /proc or
* ptrace or page migration (get_task_mm()). Mark owner as NULL.
*/
mm->owner = NULL;
WRITE_ONCE(mm->owner, NULL);
return;

assign_new_owner:
Expand All @@ -483,7 +483,7 @@ void mm_update_next_owner(struct mm_struct *mm)
put_task_struct(c);
goto retry;
}
mm->owner = c;
WRITE_ONCE(mm->owner, c);
task_unlock(c);
put_task_struct(c);
}
Expand Down

0 comments on commit 987717e

Please sign in to comment.