* [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page.
@ 2024-10-23 17:12 Zi Yan
2024-10-23 18:50 ` David Hildenbrand
2024-10-23 19:59 ` Usama Arif
0 siblings, 2 replies; 3+ messages in thread
From: Zi Yan @ 2024-10-23 17:12 UTC (permalink / raw)
To: linux-mm, Andrew Morton
Cc: usamaarif642, baohua, cerasuolodomenico, corbet, david, hannes,
kernel-team, linux-doc, linux-kernel, npache, riel,
roman.gushchin, rppt, ryan.roberts, ryncsn, shakeel.butt, willy,
yuzhao, Zi Yan
An anonymous large folio can be split into non order-0 folios,
try_to_map_unused_to_zeropage() should not VM_BUG_ON compound pages but
just return false. This fixes the crash when splitting anonymous large
folios to non order-0 folios.
Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
mm/migrate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index e950fd62607f..7ffdbe078aa7 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -206,7 +206,8 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
pte_t newpte;
void *addr;
- VM_BUG_ON_PAGE(PageCompound(page), page);
+ if (PageCompound(page))
+ return false;
VM_BUG_ON_PAGE(!PageAnon(page), page);
VM_BUG_ON_PAGE(!PageLocked(page), page);
VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
--
2.45.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page.
2024-10-23 17:12 [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page Zi Yan
@ 2024-10-23 18:50 ` David Hildenbrand
2024-10-23 19:59 ` Usama Arif
1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2024-10-23 18:50 UTC (permalink / raw)
To: Zi Yan, linux-mm, Andrew Morton
Cc: usamaarif642, baohua, cerasuolodomenico, corbet, hannes,
kernel-team, linux-doc, linux-kernel, npache, riel,
roman.gushchin, rppt, ryan.roberts, ryncsn, shakeel.butt, willy,
yuzhao
On 23.10.24 19:12, Zi Yan wrote:
> An anonymous large folio can be split into non order-0 folios,
> try_to_map_unused_to_zeropage() should not VM_BUG_ON compound pages but
> just return false. This fixes the crash when splitting anonymous large
> folios to non order-0 folios.
>
> Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> mm/migrate.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e950fd62607f..7ffdbe078aa7 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -206,7 +206,8 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
> pte_t newpte;
> void *addr;
>
> - VM_BUG_ON_PAGE(PageCompound(page), page);
> + if (PageCompound(page))
> + return false;
> VM_BUG_ON_PAGE(!PageAnon(page), page);
> VM_BUG_ON_PAGE(!PageLocked(page), page);
> VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
Would read nicer in 2024 when working on folios ;)
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page.
2024-10-23 17:12 [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page Zi Yan
2024-10-23 18:50 ` David Hildenbrand
@ 2024-10-23 19:59 ` Usama Arif
1 sibling, 0 replies; 3+ messages in thread
From: Usama Arif @ 2024-10-23 19:59 UTC (permalink / raw)
To: Zi Yan, linux-mm, Andrew Morton
Cc: baohua, cerasuolodomenico, corbet, david, hannes, kernel-team,
linux-doc, linux-kernel, npache, riel, roman.gushchin, rppt,
ryan.roberts, ryncsn, shakeel.butt, willy, yuzhao
On 23/10/2024 18:12, Zi Yan wrote:
> An anonymous large folio can be split into non order-0 folios,
> try_to_map_unused_to_zeropage() should not VM_BUG_ON compound pages but
> just return false. This fixes the crash when splitting anonymous large
> folios to non order-0 folios.
>
> Fixes: b1f202060afe ("mm: remap unused subpages to shared zeropage when splitting isolated thp")
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> mm/migrate.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e950fd62607f..7ffdbe078aa7 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -206,7 +206,8 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
> pte_t newpte;
> void *addr;
>
> - VM_BUG_ON_PAGE(PageCompound(page), page);
> + if (PageCompound(page))
> + return false;
> VM_BUG_ON_PAGE(!PageAnon(page), page);
> VM_BUG_ON_PAGE(!PageLocked(page), page);
> VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
Thanks for fixing it!
Acked-by: Usama Arif <usamaarif642@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-23 19:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-23 17:12 [PATCH] mm: avoid VM_BUG_ON when try to map an anon large folio to zero page Zi Yan
2024-10-23 18:50 ` David Hildenbrand
2024-10-23 19:59 ` Usama Arif
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox