[PATCH v2] mm/page_alloc: remove VM_BUG_ON()s from pindex helpers

From: Brendan Jackman

Date: Tue May 26 2026 - 07:28:47 EST


Vlastimil pointed out that the VM_BUG_ON()s have fallen out of
favour, so remove them.

Suggested-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
Link: https://lore.kernel.org/all/4074a816-9e75-45a6-8141-25459bcc106b@xxxxxxxxxx/
Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx>
---
Changes in v2:
- Rebased onto mm-new, removed VM_BUG_ON()s
- Link to v1: https://lore.kernel.org/r/20260513-page_alloc-unmapped-prep-v1-0-dacdf5402be8@xxxxxxxxxx
---
mm/page_alloc.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1b5b1e556f76feadf21f3f44a9440fe883fb7651..e47679e7a9dbc772aa27f550a10aa8c0e95af55a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -653,13 +653,8 @@ static inline unsigned int order_to_pindex(int migratetype, int order)
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
bool movable = migratetype == MIGRATE_MOVABLE;

- if (order > PAGE_ALLOC_COSTLY_ORDER) {
- VM_BUG_ON(!is_pmd_order(order));
-
+ if (order > PAGE_ALLOC_COSTLY_ORDER)
return NR_LOWORDER_PCP_LISTS + movable;
- }
- } else {
- VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
}

return (MIGRATE_PCPTYPES * order) + migratetype;
@@ -672,8 +667,6 @@ static inline int pindex_to_order(unsigned int pindex)
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
if (pindex >= NR_LOWORDER_PCP_LISTS)
order = HPAGE_PMD_ORDER;
- } else {
- VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
}

return order;

---
base-commit: da0a06486ac3ce47c6ffb603d2fd332229d41592
change-id: 20260512-page_alloc-unmapped-prep-c3ae0381d58b

Best regards,
--
Brendan Jackman <jackmanb@xxxxxxxxxx>