Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH hotfix] mm: fix pmd_special() fallback to observe huge_zero
@ 2026-04-29  5:08 Hugh Dickins
  2026-04-29  5:54 ` Lance Yang
  0 siblings, 1 reply; 12+ messages in thread
From: Hugh Dickins @ 2026-04-29  5:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Baolin Wang, Barry Song, David Hildenbrand, Dev Jain, Lance Yang,
	Liam Howlett, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
	Nico Pache, Qi Zheng, Ryan Roberts, Suren Baghdasaryan, Zi Yan,
	linux-mm

On x86 32-bit with THP enabled, zap_huge_pmd() is seen to generate a
"WARNING: mm/memory.c:735 at __vm_normal_page+0x6a/0x7d", from the
VM_WARN_ON_ONCE(is_zero_pfn(pfn) || is_huge_zero_pfn(pfn)); followed
by "BUG: Bad rss-counter state"s, then later "BUG: Bad page state"s
when reclaim gets to call shrink_huge_zero_folio_scan().

It's as if the _PAGE_SPECIAL bit never got set in the huge_zero pmd:
and indeed, whereas pte_special() and pte_mkspecial() are subject to a
dedicated CONFIG_ARCH_HAS_PTE_SPECIAL, pmd_special() and pmd_mkspecial()
are subject to CONFIG_ARCH_SUPPORTS_PMD_PFNMAP, which is never enabled
on any 32-bit architecture.

Add CONFIG_ARCH_HAS_PMD_SPECIAL?  Perhaps; but I think it's better just
to observe the huge_zero pmd in the fallback version of pmd_special().

Fixes: d80a9cb1a64a ("mm/huge_memory: add and use normal_or_softleaf_folio_pmd()")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0b776907152e..3b02ac43bcb7 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3422,7 +3422,7 @@ static inline pte_t pte_mkspecial(pte_t pte)
 #ifndef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
 static inline bool pmd_special(pmd_t pmd)
 {
-	return false;
+	return is_huge_zero_pmd(pmd);
 }
 
 static inline pmd_t pmd_mkspecial(pmd_t pmd)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-04-30  9:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29  5:08 [PATCH hotfix] mm: fix pmd_special() fallback to observe huge_zero Hugh Dickins
2026-04-29  5:54 ` Lance Yang
2026-04-29  6:12   ` David Hildenbrand (Arm)
2026-04-29  6:57     ` Lance Yang
2026-04-29  7:14       ` David Hildenbrand (Arm)
2026-04-29  7:33         ` Lance Yang
2026-04-30  5:53           ` David Hildenbrand (Arm)
2026-04-30  6:46             ` Lance Yang
2026-04-30  8:30             ` Lance Yang
2026-04-30  8:48             ` Hugh Dickins
2026-04-30  8:54               ` David Hildenbrand (Arm)
2026-04-30  9:10                 ` Lance Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox