From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796007130; b=47uZy2BAunqkF6I4YhnxImzdE9ChanLX1TcU+H5WvUoI+bxTVnlY+rfmVYyHD8jlbMNQ 4Y+v8rKMd+ao8Wov8bqvU0H2sb0Bgd0jEaaL/zqEqnDkXYQce8Uv4ghUxBHIMmdHe4fAA gWEY+jmDpbdtSd1R+a72VBRSqwf4jP9cQrEE1wCd3//jPVdNINB7z93OGh8ojMG5Ry6LG mDCmbqf48Iv8DCMyUFJErCKGH4dHLIWwwJydPKTT4qh7AmxiIoHf6EI+U9s9CsKpCZPDY 5tC79hw/xA0SWrmjvonQTuW97VQ1Tm42t3iLbxo80cNHM4+GvIfR5ngXmq4skAuDt4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796007130; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=9LdDxd1PmXAzGjwq9tift1QoKRVBhRvmgcty88gDaJA=; b=1LOT/0zsj7ZekyqjaSwzEyWycNv0Iw+Mb7ds3DRVt+D5AOvcdCncUDu+iHrEDkZdJ+uK 7CqjAmT1Q3GExK5gFPXP1OWsUcSTC2dvxZvNqC/brXNiChR16nl17FbgRtuji4gnb2smD FV6cg4hpjIGNmP6rQHe+xYfJ+mzn5WcQXcc6pP6JmV5fKMb/vfQsdmJkgNiYJw9j91qdE fkb90RJb4olb/T5yAzHJSNaWel2JEq8NJhyN0eB52PzX0p0zf4RT+xl1rj5JhNBrjrZkH CYOYIEVHqpyjZYxU7DTtcLYGvuO0uQKmGrWcIeUv8j0MBoyMO5Naa/U1Vgh5Lb2qVhg== 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=MFJnNh63; 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 B22B6606A337 for ; Mon, 30 Nov 2026 02:52:10 +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=MFJnNh63 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CFE01F0089F; Mon, 30 Nov 2026 02:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796007130; bh=9LdDxd1PmXAzGjwq9tift1QoKRVBhRvmgcty88gDaJA=; h=Date:To:From:In-Reply-To:References:Subject; b=MFJnNh63P2N/vlN5R6IS3gHeBuvyk9Mb1WQPhaA7/5iNdzX9qiyJntz/mK2cFQINT RdpUspTw+8mIoP+f52XRb1UQZpwW9k2GRx0X/mfPKaudV1Ypf33KhWA34keks8+r6O mFbK+GsNZli5YkH6XU/1t6IAZQyyEGgX6uyH/UDg= Date: Sun, 29 Nov 2026 18:52:09 -0800 To: mm-commits@vger.kernel.org,mason@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261125-hugetlb_fixes_2-v1-9-db27fd2f71a8@kernel.org> References: <20261125-hugetlb_fixes_2-v1-9-db27fd2f71a8@kernel.org> Subject: + mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch added to mm-new branch Message-Id: <20261130025210.0CFE01F0089F@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/hugetlb: don't zap non-present entries when unmapping a folio has been added to the -mm mm-new branch. Its filename is mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.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: Chris Mason Subject: mm/hugetlb: don't zap non-present entries when unmapping a folio Date: Wed, 25 Nov 2026 23:33:07 +0100 When the owner of a private hugetlb mapping fails to allocate a folio for COW, unmap_ref_private() unmaps the old folio from the forked children, and marks them with HPAGE_RESV_UNMAPPED, so they get a SIGBUS on their next access. hugetlb_unmap_range() is supposed to only unmap that folio, but it clears non-present page table entries unconditionally. A child can silently lose its COWed folio while it is getting migrated, or a hwpoison entry or uffd poison marker, without HPAGE_RESV_UNMAPPED getting set. Consequently, it would not SIGBUS on the next access. Let's fix it by ignoring non-present entries when unmapping a folio. As the folio is locked, migration entries of that folio do not apply. This has low urgency, as it requires a failing COW allocation in the owner racing with migration or memory failure in the child. Let's not CC stable. [david@kernel.org: adjust comment and description] Link: https://patch.msgid.link/20261125-hugetlb_fixes_2-v1-9-db27fd2f71a8@kernel.org Fixes: 8c4894c6bc79 ("hwpoison, hugetlbfs: fix "bad pmd" warning in unmapping hwpoisoned hugepage") Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Reviewed-by: Muchun Song (ByteDance) Cc: Oscar Salvador Cc: Jinmeng Zhou Cc: Hongfu Li Cc: Andrea Arcangeli Cc: Mike Kravetz Cc: Naoya Horiguchi Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Vivek Kasireddy Cc: Gerd Hoffmann Cc: Mike Rapoport Cc: Mel Gorman Cc: Dave McCracken Cc: Andy Whitcroft Cc: Adam Litke Cc: Lorenzo Stoakes Cc: Rik van Riel Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Harry Yoo Cc: Jann Horn Cc: Lance Yang Cc: James Houghton Cc: Yang Shi Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato Cc: Gregory Price Cc: Zi Yan Cc: Joshua Hahn Cc: Rakie Kim Cc: Ying Huang Cc: Matthew Brost Cc: Byungchul Park Cc: Alistair Popple Cc: Wanpeng Li Cc: Andi Kleen Cc: Kenneth W Chen Cc: Michal Hocko Cc: David Rientjes Cc: Joern Engel Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Aneesh Kumar K.V Cc: KAMEZAWA Hiroyuki Cc: Kiryl Shutsemau Cc: Sasha Levin Cc: Guillaume Morin Cc: Wanpeng Li Cc: Jason Gunthorpe Cc: luojiajun Cc: Josef Bacik Cc: Daehyeon Ko <4ncienth@gmail.com> Cc: Ackerley Tng Cc: "Oscar Salvador (SUSE)" Cc: Jiaqi Yan mm/hugetlb.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/hugetlb.c~mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio +++ a/mm/hugetlb.c @@ -5435,6 +5435,14 @@ static void hugetlb_unmap_range(struct m */ if (unlikely(!pte_present(pte))) { /* + * If we have a folio provided, we only care about + * present page table entries (folio is locked). + */ + if (folio_provided) { + spin_unlock(ptl); + continue; + } + /* * If the pte was wr-protected by uffd-wp in any of the * swap forms, meanwhile the caller does not want to * drop the uffd-wp bit in this zap, then replace the _ Patches currently in -mm which might be from mason@kernel.org are mm-swap-fix-large-swap-in-across-swap-file-extents.patch hugetlbfs-do-not-grow-a-sealed-file-in-mmap.patch mm-hugetlb-keep-surplus-folios-that-are-reserved.patch mm-hugetlb-fix-reservation-leak-on-min_size=-mounts.patch mm-cachestat-count-each-page-only-once.patch mm-cachestat-restart-the-walk-after-each-entry.patch percpu-queue-the-balance-work-on-an-unbound-workqueue.patch mm-vma-fix-uncharge-after-failed-stack-relocation.patch mm-mremap-apply-the-mmap-offset-limits-on-expansion.patch mm-mremap-respect-guard-gaps-on-in-place-expansion.patch mm-vma-make-brk-mappings-non-executable-under-mdwe.patch mm-hmm-refuse-secretmem-vmas-in-hmm_range_fault.patch mm-mglru-count-all-generations-as-evictable.patch mm-mglru-test-pg_lru-before-taking-a-folio-reference.patch mm-mglru-report-root-reclaim-to-memorypressure_level.patch kfence-use-a-nofault-store-to-zero-the-guard-page.patch mm-hugetlb-fix-truncated-copy-result-in-uffdio_copy.patch hugetlbfs-fix-deadlock-between-hole-punching-and-memory-failure.patch hugetlbfs-recheck-the-vma-range-after-the-lock-wait.patch mm-hugetlb-dont-zap-non-present-entries-when-unmapping-a-folio.patch mm-hugetlb-unshare-pmds-of-a-split-vma-if-allocating-its-lock-fails.patch mm-hugetlb_cgroup-track-in-use-folios-per-cgroup.patch hugetlbfs-seal-shm_hugetlb-files-against-growth.patch mm-hugetlb-resolve-protnone-faults-without-a-uffd-bit.patch