Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086646; b=FahwPikSJNy9FY25WsMgWAZodjq34umqP5oDunt6t3AXYcyd3RclFQy+zx6blP4g58si jUYaSMyHuenARjQb6lOma9JDWU/jl1vVIsE2ZcSWxK8r4abGxoCbtla6IChtkgwv3D/DZ XBK6RtCwHvdGcLmuOB0vyDc5J/Gv4Kcj5rWbTUggE/BLs88ns8UBk+olYEqoZVDdGGDvC /PHH2ustjFcKsq4YDWd3Rzxgg6fq46htt3SBj0EOyHADi5hHwcuzOySz/zkJinNzCDVAD 2n0XrRA+vRiKfrSdzFyhHN0TkgO93wQSDejvZtOnaOzfAUWRgYTPvy6qRIiWWz0P50Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086646; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=ZomgYaYOywrqXwJXQsoaYMByTXcRk8vKHdQc6ZCqFe0=; b=qMunlA8DnsggguN8BNaVxqRBdx/XjAbN5wJk72sYRne4LsK2lUkzbuQ8ynDNvMOidWMP s6WQrZ6WXwXjFDMmYnC2cUjBgUPZFmPZGjC5QmT2SwIhZxcx4IiGC/wG6fH00WjbHyxLC ppeU4ZHmT2y7bI3Zy8mh9Waz6UoonoXnREwqGTpmWsKxujkpRY4hn2XZJw0LuF3AyWswu DSMfE/FNUjQui+qmQO4+4A3xfGYkLFzRgRsHNucBTI/eCGidizLZSgV0hO1W1IetZmpfT b6ptWf1CPpTFzSafrxvMWm1kf6fcFWNPk3/VcUVmWNY1ueFzrhufyp4VllKko5/4jdg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Jeqgv2qk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56332606A31A; Tue, 1 Dec 2026 00:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Jeqgv2qk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 018FB1F000C1; Tue, 1 Dec 2026 00:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796086646; bh=ZomgYaYOywrqXwJXQsoaYMByTXcRk8vKHdQc6ZCqFe0=; h=Date:To:From:In-Reply-To:References:Subject; b=Jeqgv2qkSrV9GTpGovIHTzCOmwPf/XCoXMJC83kg2M2UZk5mzKQRKD1qznB7fvPzv vwCeQAU9WQ/vDgKYJGsJVu3c5iEUlvCZTkXmaqrCW0nvmnHHH+SACj43K+lj/qqj2z +y+GAEp1Qe164TNnmYy6BuU1S8nhN8ijogt/V4ug= Date: Mon, 30 Nov 2026 16:57:25 -0800 To: mm-commits@vger.kernel.org,zhangpeng362@huawei.com,yi.zhang@huawei.com, willy@infradead.org,wangkefeng.wang@huawei.com,tytso@mit.edu, stable@vger.kernel.org,ojaswin@linux.ibm.com,mcgrof@kernel.org, mason@kernel.org,libaokun1@huawei.com,john.garry@linux.dev,jack@suse.cz, huang.ying.caritas@gmail.com,hare@suse.de,brauner@kernel.org, david@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261129-filemap_fixes-v1-1-1546675e3c97@kernel.org> References: <20261129-filemap_fixes-v1-1-1546675e3c97@kernel.org> Subject: + mm-filemap-avoid-retrying-faults-on-uffd-wp-markers.patch added to mm-new branch Message-Id: <20261201005726.018FB1F000C1@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/filemap: avoid retrying faults on uffd-wp markers has been added to the -mm mm-new branch. Its filename is mm-filemap-avoid-retrying-faults-on-uffd-wp-markers.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-filemap-avoid-retrying-faults-on-uffd-wp-markers.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next 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 various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: "David Hildenbrand (Arm)" Subject: mm/filemap: avoid retrying faults on uffd-wp markers Date: Sun, 29 Nov 2026 10:05:09 +0100 Patch series "mm/filemap: two smaller fixes". Two fairly small pagecache-related fixes. I was surprised to learn under which circumstances ext4 can change the maximum folio order of a file, but I guess we just have to support that. I have a related khugepaged fix coming up. This patch (of 2): filemap_fault_recheck_pte_none() avoids unnecessary major faults in mlocked mappings by checking whether an apparently empty PTE was only temporarily cleared. If the PTE is no longer empty, it returns VM_FAULT_NOPAGE to retry the fault before populating the page cache. However, filemap_fault() can also be reached with an uffd-wp marker in vmf->orig_pte. If the page is absent from the page cache, the recheck treats the nonempty marker as a reason to retry, but the marker remains unchanged. Consequently, the fault repeats indefinitely. This can be reproduced by mapping a fresh sparse regular file, applying mlock2(MLOCK_ONFAULT), registering for async uffd-wp and write-protecting the unpopulated mapping. A read from the mapping then fails to complete. Let's fix it by checking pte_present() instead, allowing marker faults to populate the page cache while still detecting temporarily cleared mappings, including NUMA hinting PTEs, and by renaming the helper accordingly. This has low urgency, as it requires the unusual combination of MLOCK_ONFAULT and async uffd-wp. Link: https://lore.kernel.org/20261129-filemap_fixes-v1-0-1546675e3c97@kernel.org Link: https://patch.msgid.link/20261129-filemap_fixes-v1-1-1546675e3c97@kernel.org Fixes: 58f327f2ce80 ("filemap: avoid unnecessary major faults in filemap_fault()") Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Cc: Matthew Wilcox (Oracle) Cc: Jan Kara Cc: Ying Huang Cc: Kefeng Wang Cc: ZhangPeng Cc: Hannes Reinecke Cc: Christian Brauner Cc: Luis Chamberlain Cc: John Garry Cc: Zhang Yi Cc: Baokun Li Cc: Ojaswin Mujoo Cc: Theodore Ts'o Cc: Chris Mason Cc: mm/filemap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/filemap.c~mm-filemap-avoid-retrying-faults-on-uffd-wp-markers +++ a/mm/filemap.c @@ -3529,7 +3529,7 @@ static struct file *do_async_mmap_readah return fpin; } -static vm_fault_t filemap_fault_recheck_pte_none(struct vm_fault *vmf) +static vm_fault_t filemap_fault_recheck_pte_present(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; vm_fault_t ret = 0; @@ -3560,11 +3560,11 @@ static vm_fault_t filemap_fault_recheck_ if (unlikely(!ptep)) return VM_FAULT_NOPAGE; - if (unlikely(!pte_none(ptep_get_lockless(ptep)))) { + if (unlikely(pte_present(ptep_get_lockless(ptep)))) { ret = VM_FAULT_NOPAGE; } else { spin_lock(vmf->ptl); - if (unlikely(!pte_none(ptep_get(ptep)))) + if (unlikely(pte_present(ptep_get(ptep)))) ret = VM_FAULT_NOPAGE; spin_unlock(vmf->ptl); } @@ -3629,7 +3629,7 @@ vm_fault_t filemap_fault(struct vm_fault mapping_locked = true; } } else { - ret = filemap_fault_recheck_pte_none(vmf); + ret = filemap_fault_recheck_pte_present(vmf); if (unlikely(ret)) return ret; _ Patches currently in -mm which might be from david@kernel.org are mm-hugetlb-charge-the-copy-made-at-fork-to-the-parent.patch mm-mprotect-dont-skip-uffd-marker-install-when-racing-with-pte-table-reclaim.patch mm-userfaultfd-prevent-poison-marker-loss.patch mm-hugetlb-compare-against-persistent-count-when-freeing-lowmem-folios.patch mm-hugetlb-preserve-reservations-when-shrinking-on-highmem.patch mm-hugetlb-account-temporary-folios-separately.patch mm-hugetlb-account-temporary-folios-separately-fix.patch mm-hugetlb-serialize-page-cache-allocations-with-truncation.patch mm-hugetlb-serialize-page-cache-allocations-with-truncation-fix.patch mm-memfd-recheck-the-page-cache-before-allocating-a-hugetlb-folio.patch mm-hugetlb-count-again-if-the-reserve-map-shrank.patch mm-hugetlb-account-restored-reservations-before-freeing-folios.patch mm-hugetlb-delay-anon-folio-rmap-removal-until-after-the-tlb-flush.patch mm-userfaultfd-reject-dax-mappings.patch uprobes-skip-mappings-not-managed-by-core-mm.patch mm-memory-store-the-pfn-of-cow-pfnmap-mappings-in-the-anon-page-offset.patch mm-hugetlb-always-mark-new-page-cache-folios-migratable.patch mm-memfd-mark-new-hugetlb-folios-migratable.patch mm-hugetlb-free-surplus-folios-of-other-nodes-on-free.patch hugetlbfs-dont-zero-poisoned-pages-in-a-hole-punch.patch mm-hugetlb-only-check-pmd-table-sharing-for-pmd-sized-folios.patch mm-migrate-check-hugetlb-pmd-sharing-in-move_pages.patch mm-hugetlb-dont-share-page-tables-of-a-vma-during-mprotect.patch mm-hugetlb-count-migration-entries-at-fork-and-unmap.patch mm-hugetlb-stop-accounting-hugetlbpages-once-pmd-tables-were-shared.patch fs-proc-task_mmu-dont-clear-vm_softdirty-on-hugetlb-vmas.patch mm-hugetlb-use-the-vma-lock-to-stabilize-flags-for-pmd-sharing.patch rfc-mm-hugetlb_cgroup-charge-faults-to-mm-owner.patch mm-filemap-avoid-retrying-faults-on-uffd-wp-markers.patch