Skip to content

Commit 987717e

Browse files
aagittorvalds
authored andcommitted
mm: change mm_update_next_owner() to update mm->owner with WRITE_ONCE
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]>
1 parent c3f3ce0 commit 987717e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/exit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void mm_update_next_owner(struct mm_struct *mm)
422422
* freed task structure.
423423
*/
424424
if (atomic_read(&mm->mm_users) <= 1) {
425-
mm->owner = NULL;
425+
WRITE_ONCE(mm->owner, NULL);
426426
return;
427427
}
428428

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

468468
assign_new_owner:
@@ -483,7 +483,7 @@ void mm_update_next_owner(struct mm_struct *mm)
483483
put_task_struct(c);
484484
goto retry;
485485
}
486-
mm->owner = c;
486+
WRITE_ONCE(mm->owner, c);
487487
task_unlock(c);
488488
put_task_struct(c);
489489
}

0 commit comments

Comments
 (0)