The patch titled Subject: userfaultfd: remove WRITE_ONCE when setting folio->index during UFFDIO_MOVE has been added to the -mm mm-unstable branch. Its filename is userfaultfd-remove-write_once-when-setting-folio-index-during-uffdio_move.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/userfaultfd-remove-write_once-when-setting-folio-index-during-uffdio_move.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm 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 via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Suren Baghdasaryan <surenb@xxxxxxxxxx> Subject: userfaultfd: remove WRITE_ONCE when setting folio->index during UFFDIO_MOVE Date: Sun, 14 Apr 2024 19:08:21 -0700 When folio is moved with UFFDIO_MOVE it gets locked before the rmap and index are modified. Due to the folio lock being already held, WRITE_ONCE() is not needed when setting the folio index. Remove it. Link: https://lkml.kernel.org/r/20240415020821.1152951-1-surenb@xxxxxxxxxx Reported-by: Matthew Wilcox <willy@xxxxxxxxxxxxx> Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> Reviewed-by: David Hildenbrand <david@xxxxxxxxxx> Reviewed-by: Peter Xu <peterx@xxxxxxxxxx> Cc: Lokesh Gidra <lokeshgidra@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/huge_memory.c | 2 +- mm/userfaultfd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/mm/huge_memory.c~userfaultfd-remove-write_once-when-setting-folio-index-during-uffdio_move +++ a/mm/huge_memory.c @@ -2200,7 +2200,7 @@ int move_pages_huge_pmd(struct mm_struct } folio_move_anon_rmap(src_folio, dst_vma); - WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr)); + src_folio->index = linear_page_index(dst_vma, dst_addr); _dst_pmd = mk_huge_pmd(&src_folio->page, dst_vma->vm_page_prot); /* Follow mremap() behavior and treat the entry dirty after the move */ --- a/mm/userfaultfd.c~userfaultfd-remove-write_once-when-setting-folio-index-during-uffdio_move +++ a/mm/userfaultfd.c @@ -1026,7 +1026,7 @@ static int move_present_pte(struct mm_st } folio_move_anon_rmap(src_folio, dst_vma); - WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr)); + src_folio->index = linear_page_index(dst_vma, dst_addr); orig_dst_pte = mk_pte(&src_folio->page, dst_vma->vm_page_prot); /* Follow mremap() behavior and treat the entry dirty after the move */ _ Patches currently in -mm which might be from surenb@xxxxxxxxxx are fix-missing-vmalloch-includes-fix-2.patch fix-missing-vmalloch-includes-fix-6.patch mm-introduce-slabobj_ext-to-support-slab-object-extensions.patch mm-introduce-__gfp_no_obj_ext-flag-to-selectively-prevent-slabobj_ext-creation.patch mm-slab-introduce-slab_no_obj_ext-to-avoid-obj_ext-creation.patch slab-objext-introduce-objext_flags-as-extension-to-page_memcg_data_flags.patch lib-code-tagging-framework.patch lib-code-tagging-module-support.patch lib-prevent-module-unloading-if-memory-is-not-freed.patch lib-add-allocation-tagging-support-for-memory-allocation-profiling.patch lib-add-allocation-tagging-support-for-memory-allocation-profiling-fix.patch lib-add-allocation-tagging-support-for-memory-allocation-profiling-fix-2.patch lib-introduce-support-for-page-allocation-tagging.patch lib-introduce-early-boot-parameter-to-avoid-page_ext-memory-overhead.patch mm-percpu-increase-percpu_module_reserve-to-accommodate-allocation-tags.patch mm-percpu-increase-percpu_module_reserve-to-accommodate-allocation-tags-fix.patch change-alloc_pages-name-in-dma_map_ops-to-avoid-name-conflicts.patch mm-enable-page-allocation-tagging.patch mm-enable-page-allocation-tagging-fix.patch mm-create-new-codetag-references-during-page-splitting.patch mm-fix-non-compound-multi-order-memory-accounting-in-__free_pages.patch mm-page_ext-enable-early_page_ext-when-config_mem_alloc_profiling_debug=y.patch lib-add-codetag-reference-into-slabobj_ext.patch mm-slab-add-allocation-accounting-into-slab-allocation-and-free-paths.patch mm-slab-enable-slab-allocation-tagging-for-kmalloc-and-friends.patch mm-slab-enable-slab-allocation-tagging-for-kmalloc-and-friends-fix.patch mempool-hook-up-to-memory-allocation-profiling-fix.patch mempool-hook-up-to-memory-allocation-profiling-fix-2.patch mm-percpu-enable-per-cpu-allocation-tagging.patch mm-percpu-enable-per-cpu-allocation-tagging-fix.patch mm-vmalloc-enable-memory-allocation-profiling-fix.patch mm-vmalloc-enable-memory-allocation-profiling-fix-2.patch rhashtable-plumb-through-alloc-tag-fix.patch lib-add-memory-allocations-report-in-show_mem.patch codetag-debug-skip-objext-checking-when-its-for-objext-itself.patch codetag-debug-mark-codetags-for-reserved-pages-as-empty.patch codetag-debug-introduce-objexts_alloc_fail-to-mark-failed-slab_ext-allocations.patch userfaultfd-remove-write_once-when-setting-folio-index-during-uffdio_move.patch