Subject: linux-next: build failure after merge of the mm tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 9 Jan 2025 15:59:54 +1100

Hi all,

After merging the mm tree, today's linux-next build (x86_64 allnoconfig)
failed like this:

Caused by commit

  ce9c7ffcf303 ("rmap: add support for PUD sized mappings to rmap")

$ grep CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD .config
CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD=y
$ grep CONFIG_PGTABLE_HAS_HUGE_LEAVES .config
$

from include/linux/huge_mm.h:

#ifdef CONFIG_PGTABLE_HAS_HUGE_LEAVES
#define HPAGE_PMD_SHIFT PMD_SHIFT
#define HPAGE_PUD_SHIFT PUD_SHIFT
#else
#define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
#define HPAGE_PUD_SHIFT ({ BUILD_BUG(); 0; })
#endif

I have applied this hack for today:

From: Stephen Rothwell <[email-masked]>
Date: Thu, 9 Jan 2025 15:39:17 +1100
Subject: [PATCH] fix up for "rmap: add support for PUD sized mappings to rmap"

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 mm/rmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 227c60e38261..721d4f7b7570 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1558,7 +1558,7 @@ void folio_add_file_rmap_pmd(struct folio *folio, struct page *page,
 void folio_add_file_rmap_pud(struct folio *folio, struct page *page,
 		struct vm_area_struct *vma)
 {
-#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
+#if defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) && defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES)
 	__folio_add_file_rmap(folio, page, HPAGE_PUD_NR, vma, RMAP_LEVEL_PUD);
 #else
 	WARN_ON_ONCE(true);
@@ -1690,7 +1690,7 @@ void folio_remove_rmap_pmd(struct folio *folio, struct page *page,
 void folio_remove_rmap_pud(struct folio *folio, struct page *page,
 		struct vm_area_struct *vma)
 {
-#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
+#if defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) && defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES)
 	__folio_remove_rmap(folio, page, HPAGE_PUD_NR, vma, RMAP_LEVEL_PUD);
 #else
 	WARN_ON_ONCE(true);
-- 
2.45.2

-- 
Cheers,
Stephen Rothwell