Re: [PATCH v5 4/6] mm/huge_memory: convert VM_BUG* to VM_WARN* in __folio_split.

From: David Hildenbrand
Date: Tue Jul 22 2025 - 11:34:24 EST


On 18.07.25 20:37, Zi Yan wrote:
These VM_BUG* can be handled gracefully without crashing kernel.

Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
---
mm/huge_memory.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index d36f7bdaeb38..d98283164eda 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3601,8 +3601,8 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
pgoff_t end;
bool is_hzp;
- VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);
- VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
+ VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);
+ VM_WARN_ON_ONCE_FOLIO(!folio_test_large(folio), folio);
if (folio != page_folio(split_at) || folio != page_folio(lock_at))
return -EINVAL;
@@ -3766,7 +3766,11 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
}
if (folio_test_swapcache(folio)) {
- VM_BUG_ON(mapping);
+ if (mapping) {
+ VM_WARN_ON_ONCE_FOLIO(mapping, folio);
+ ret = -EINVAL;
+ goto fail;
+ }
swap_cache = swap_address_space(folio->swap);
xa_lock(&swap_cache->i_pages);


Acked-by: David Hildenbrand <david@xxxxxxxxxx>

--
Cheers,

David / dhildenb