The patch titled Subject: mm/memory: fix folio_set_dirty() vs. folio_mark_dirty() in zap_pte_range() has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-memory-fix-folio_set_dirty-vs-folio_mark_dirty-in-zap_pte_range.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memory-fix-folio_set_dirty-vs-folio_mark_dirty-in-zap_pte_range.patch This patch will later appear in the mm-hotfixes-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: David Hildenbrand <david@xxxxxxxxxx> Subject: mm/memory: fix folio_set_dirty() vs. folio_mark_dirty() in zap_pte_range() Date: Mon, 22 Jan 2024 18:17:51 +0100 The correct folio replacement for "set_page_dirty()" is "folio_mark_dirty()", not "folio_set_dirty()". Using the latter won't properly inform the FS using the dirty_folio() callback. This has been found by code inspection, but likely this can result in some real trouble when zapping dirty PTEs that point at clean pagecache folios. Link: https://lkml.kernel.org/r/20240122171751.272074-1-david@xxxxxxxxxx Fixes: c46265030b0f ("mm/memory: page_remove_rmap() -> folio_remove_rmap_pte()") Signed-off-by: David Hildenbrand <david@xxxxxxxxxx> Reported-by: Ryan Roberts <ryan.roberts@xxxxxxx> Closes: https://lkml.kernel.org/r/2445cedb-61fb-422c-8bfb-caf0a2beed62@xxxxxxx Reviewed-by: Ryan Roberts <ryan.roberts@xxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/memory.c~mm-memory-fix-folio_set_dirty-vs-folio_mark_dirty-in-zap_pte_range +++ a/mm/memory.c @@ -1464,7 +1464,7 @@ static unsigned long zap_pte_range(struc delay_rmap = 0; if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { - folio_set_dirty(folio); + folio_mark_dirty(folio); if (tlb_delay_rmap(tlb)) { delay_rmap = 1; force_flush = 1; _ Patches currently in -mm which might be from david@xxxxxxxxxx are uprobes-use-pagesize-aligned-virtual-address-when-replacing-pages.patch mm-huge_memory-fix-folio_set_dirty-vs-folio_mark_dirty.patch mm-memory-fix-folio_set_dirty-vs-folio_mark_dirty-in-zap_pte_range.patch arm-pgtable-define-pfn_pte_shift-on-arm-and-arm64.patch nios2-pgtable-define-pfn_pte_shift.patch powerpc-pgtable-define-pfn_pte_shift.patch risc-pgtable-define-pfn_pte_shift.patch s390-pgtable-define-pfn_pte_shift.patch sparc-pgtable-define-pfn_pte_shift.patch mm-memory-factor-out-copying-the-actual-pte-in-copy_present_pte.patch mm-memory-pass-pte-to-copy_present_pte.patch mm-memory-optimize-fork-with-pte-mapped-thp.patch mm-memory-ignore-dirty-accessed-soft-dirty-bits-in-folio_pte_batch.patch mm-memory-ignore-writable-bit-in-folio_pte_batch.patch