mm/page_alloc.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
The ifdefs are not technically needed here, everything used here is
always defined, so switch to IS_ENABLED() to make things a little less
tiresome to read.
Also, Vlastimil pointed out that the VM_BUG_ON()s have fallen out of
favour, so remove them.
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
>> And it's all internal to page alloc so I'd just drop those checks
>> completely at this point.
>
> But, I won't die on the above hill, if people really hate BUG that much
> happy to go with the flow.
>
> In that case, I'd suggest we drop them as a separate patch.
Oh, actually no, the VM_BUG_ONs were the main thing making the ifdefs
awkward, it makes sense to drop them together. Here's a combined patch.
mm/page_alloc.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5d6144c8860ed..76d5d9464e2ef 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -650,19 +650,12 @@ static void bad_page(struct page *page, const char *reason)
static inline unsigned int order_to_pindex(int migratetype, int order)
{
+ if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
+ bool movable = migratetype == MIGRATE_MOVABLE;
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
- bool movable;
- if (order > PAGE_ALLOC_COSTLY_ORDER) {
- VM_BUG_ON(!is_pmd_order(order));
-
- movable = migratetype == MIGRATE_MOVABLE;
-
- return NR_LOWORDER_PCP_LISTS + movable;
+ if (order > PAGE_ALLOC_COSTLY_ORDER)
+ return NR_LOWORDER_PCP_LISTS + movable;
}
-#else
- VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
-#endif
return (MIGRATE_PCPTYPES * order) + migratetype;
}
@@ -671,12 +664,10 @@ static inline int pindex_to_order(unsigned int pindex)
{
int order = pindex / MIGRATE_PCPTYPES;
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
- if (pindex >= NR_LOWORDER_PCP_LISTS)
- order = HPAGE_PMD_ORDER;
-#else
- VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER);
-#endif
+ if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
+ if (pindex >= NR_LOWORDER_PCP_LISTS)
+ order = HPAGE_PMD_ORDER;
+ }
return order;
}
--
2.51.2
© 2016 - 2026 Red Hat, Inc.