From: Brendan Jackman Date: Wed, 13 May 2026 12:35:16 +0000 (+0000) Subject: mm/page_alloc: remove ifdefs from pindex helpers X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=248b144a8a6dc534d8bc1c1470efe571de5b7ae6;p=thirdparty%2Flinux.git mm/page_alloc: remove ifdefs from pindex helpers The ifdefs are not technically needed here, everything used here is always defined. Switching to IS_ENABLED() makes the code a bit less tiresome to read. Link: https://lore.kernel.org/20260513-page_alloc-unmapped-prep-v1-4-dacdf5402be8@google.com Signed-off-by: Brendan Jackman Reviewed-by: Vlastimil Babka (SUSE) Cc: Axel Rasmussen Cc: Barry Song Cc: David Hildenbrand Cc: Johannes Weiner Cc: Kairui Song Cc: Len Brown Cc: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Michal Hocko Cc: Mike Rapoport (Microsoft) Cc: "Rafael J. Wysocki" Cc: Shakeel Butt Cc: Suren Baghdasaryan Cc: Wei Xu Cc: Yuanchu Xie Cc: Zi Yan Signed-off-by: Andrew Morton --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0278d642445a..dc09a2520313 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -650,19 +650,17 @@ out: 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; + if (order > PAGE_ALLOC_COSTLY_ORDER) { + VM_BUG_ON(!is_pmd_order(order)); - return NR_LOWORDER_PCP_LISTS + movable; + return NR_LOWORDER_PCP_LISTS + movable; + } + } else { + VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); } -#else - VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); -#endif return (MIGRATE_PCPTYPES * order) + migratetype; } @@ -671,12 +669,12 @@ 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; + } else { + VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); + } return order; }