linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] mm/huge_memory: Mark moved huge zero page PMD as special
@ 2026-02-18  3:45 Chris Down
  2026-02-18  7:53 ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Down @ 2026-02-18  3:45 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Hildenbrand, Matthew Wilcox, kernel-team, linux-mm,
	linux-kernel, stable

Without pmd_mkspecial(), vm_normal_page_pmd() on architectures with
CONFIG_ARCH_HAS_PTE_SPECIAL does not recognise the moved huge zero page
as special, incorrectly treating it as a normal page and corrupting its
refcount.

Fixes: d82d09e48219 ("mm/huge_memory: mark PMD mappings of the huge zero folio special")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
 mm/huge_memory.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index fed57951a7cd..5f908cdb11f1 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2795,6 +2795,7 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
 	} else {
 		src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
 		_dst_pmd = folio_mk_pmd(page_folio(src_page), dst_vma->vm_page_prot);
+		_dst_pmd = pmd_mkspecial(_dst_pmd);
 	}
 	set_pmd_at(mm, dst_addr, dst_pmd, _dst_pmd);
 
-- 
2.51.2



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

* Re: [PATCH 2/2] mm/huge_memory: Mark moved huge zero page PMD as special
  2026-02-18  3:45 [PATCH 2/2] mm/huge_memory: Mark moved huge zero page PMD as special Chris Down
@ 2026-02-18  7:53 ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand (Arm) @ 2026-02-18  7:53 UTC (permalink / raw)
  To: Chris Down, Andrew Morton
  Cc: Matthew Wilcox, kernel-team, linux-mm, linux-kernel, stable

On 2/18/26 04:45, Chris Down wrote:
> Without pmd_mkspecial(), vm_normal_page_pmd() on architectures with
> CONFIG_ARCH_HAS_PTE_SPECIAL does not recognise the moved huge zero page
> as special, incorrectly treating it as a normal page and corrupting its
> refcount.
> 
> Fixes: d82d09e48219 ("mm/huge_memory: mark PMD mappings of the huge zero folio special")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---
>   mm/huge_memory.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index fed57951a7cd..5f908cdb11f1 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2795,6 +2795,7 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
>   	} else {
>   		src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
>   		_dst_pmd = folio_mk_pmd(page_folio(src_page), dst_vma->vm_page_prot);
> +		_dst_pmd = pmd_mkspecial(_dst_pmd);
>   	}
>   	set_pmd_at(mm, dst_addr, dst_pmd, _dst_pmd);
>   

In theory that's correct, but we should look into just moving the PMD 
instead of reconstructing things. See my reply to patch #1.

-- 
Cheers,

David


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

end of thread, other threads:[~2026-02-18  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-18  3:45 [PATCH 2/2] mm/huge_memory: Mark moved huge zero page PMD as special Chris Down
2026-02-18  7:53 ` David Hildenbrand (Arm)

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