The patch titled Subject: mm: change mm_update_next_owner() to update mm->owner with WRITE_ONCE has been added to the -mm tree. Its filename is mm-change-mm_update_next_owner-to-update-mm-owner-with-write_once.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-change-mm_update_next_owner-to-update-mm-owner-with-write_once.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-change-mm_update_next_owner-to-update-mm-owner-with-write_once.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Andrea Arcangeli <aarcange@xxxxxxxxxx> Subject: 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/20190325225636.11635-3-aarcange@xxxxxxxxxx Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Jann Horn <jannh@xxxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxxxxxx> Cc: "Kirill A . Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Cc: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: zhong jiang <zhongjiang@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/exit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/kernel/exit.c~mm-change-mm_update_next_owner-to-update-mm-owner-with-write_once +++ a/kernel/exit.c @@ -422,7 +422,7 @@ retry: * freed task structure. */ if (atomic_read(&mm->mm_users) <= 1) { - mm->owner = NULL; + WRITE_ONCE(mm->owner, NULL); return; } @@ -462,7 +462,7 @@ retry: * 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: @@ -483,7 +483,7 @@ assign_new_owner: put_task_struct(c); goto retry; } - mm->owner = c; + WRITE_ONCE(mm->owner, c); task_unlock(c); put_task_struct(c); } _ Patches currently in -mm which might be from aarcange@xxxxxxxxxx are coredump-fix-race-condition-between-mmget_not_zero-get_task_mm-and-core-dumping.patch userfaultfd-use-rcu-to-free-the-task-struct-when-fork-fails.patch mm-change-mm_update_next_owner-to-update-mm-owner-with-write_once.patch