Re: linux-next: build failure after merge of the akpm-current tree

Mike Kravetz
2019-11-06T00:02:41Z

On 11/5/19 2:19 AM, Stephen Rothwell wrote:
> Hi all,
>
> After merging the akpm-current tree, today's linux-next build (powerpc64
> allnoconfig) failed like this:
>
> In file included from arch/powerpc/mm/mem.c:30:
> include/linux/hugetlb.h:233:19: error: redefinition of 'pmd_huge'
> 233 | static inline int pmd_huge(pmd_t pmd)
> | ^~~~~~~~
> In file included from arch/powerpc/include/asm/book3s/64/pgtable.h:301,
> from arch/powerpc/include/asm/book3s/64/mmu-hash.h:20,
> from arch/powerpc/include/asm/book3s/64/mmu.h:46,
> from arch/powerpc/include/asm/mmu.h:356,
> from arch/powerpc/include/asm/lppaca.h:47,
> from arch/powerpc/include/asm/paca.h:17,
> from arch/powerpc/include/asm/current.h:13,
> from include/linux/sched.h:12,
> from arch/powerpc/mm/mem.c:16:
> arch/powerpc/include/asm/book3s/64/pgtable-4k.h:74:19: note: previous definition of 'pmd_huge' was here
> 74 | static inline int pmd_huge(pmd_t pmd) { return 0; }
> | ^~~~~~~~
> In file included from arch/powerpc/mm/mem.c:30:
> include/linux/hugetlb.h:238:19: error: redefinition of 'pud_huge'
> 238 | static inline int pud_huge(pud_t pud)
> | ^~~~~~~~
> In file included from arch/powerpc/include/asm/book3s/64/pgtable.h:301,
> from arch/powerpc/include/asm/book3s/64/mmu-hash.h:20,
> from arch/powerpc/include/asm/book3s/64/mmu.h:46,
> from arch/powerpc/include/asm/mmu.h:356,
> from arch/powerpc/include/asm/lppaca.h:47,
> from arch/powerpc/include/asm/paca.h:17,
> from arch/powerpc/include/asm/current.h:13,
> from include/linux/sched.h:12,
> from arch/powerpc/mm/mem.c:16:
> arch/powerpc/include/asm/book3s/64/pgtable-4k.h:75:19: note: previous definition of 'pud_huge' was here
> 75 | static inline int pud_huge(pud_t pud) { return 0; }
> | ^~~~~~~~
>
> Caused by commit
>
> 9823e12e021f ("hugetlbfs: convert macros to static inline, fix sparse warning")
>
> I have reverted that commit for today.

Hello Michael,

When I started to look into this I noticed that you added commit aad71e3928be
("powerpc/mm: Fix build break with RADIX=y & HUGETLBFS=n") some time back.
It appears that all other architectures get the definition of pmd_huge and
pud_huge from <linux/hugetlb.h> in the !CONFIG_HUGETLB_PAGE case. Previously,
this was not an issue as the #define pmd_huge/pud_huge did not conflict with
the static inline in the powerpc header files. The conflicts above happened
when I converted the macros to also be static inlines. Could you live with
a patch like the following to remove the stubs from powerpc header files and
fix your original build break by including <linux/hugetlb.h>? After the
below patch is applied, the above commit will not cause the build errors seen
in linux-next.

From 4b3ab017e639e4e583fff801e6d8e6727b7877e8 Mon Sep 17 00:00:00 2001
From: Mike Kravetz <mike.kravetz@oracle.com>
Date: Tue, 5 Nov 2019 15:12:15 -0800
Subject: [PATCH] powerpc/mm: remove pmd_huge/pud_huge stubs and include
hugetlb.h

This removes the power specific stubs created by commit aad71e3928be
("powerpc/mm: Fix build break with RADIX=y & HUGETLBFS=n") used when
!CONFIG_HUGETLB_PAGE. Instead, it addresses the build break by
getting the definitions from <linux/hugetlb.h>.

Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
arch/powerpc/include/asm/book3s/64/pgtable-4k.h | 3 ---
arch/powerpc/include/asm/book3s/64/pgtable-64k.h | 3 ---
arch/powerpc/mm/book3s64/radix_pgtable.c | 1 +
3 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
index a069dfcac9a9..4e697bc2f4cd 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h
@@ -70,9 +70,6 @@ static inline int get_hugepd_cache_index(int index)
/* should not reach */
}

-#else /* !CONFIG_HUGETLB_PAGE */
-static inline int pmd_huge(pmd_t pmd) { return 0; }
-static inline int pud_huge(pud_t pud) { return 0; }
#endif /* CONFIG_HUGETLB_PAGE */

#endif /* __ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h
index e3d4dd4ae2fa..34d1018896b3 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h
@@ -59,9 +59,6 @@ static inline int get_hugepd_cache_index(int index)
BUG();
}

-#else /* !CONFIG_HUGETLB_PAGE */
-static inline int pmd_huge(pmd_t pmd) { return 0; }
-static inline int pud_huge(pud_t pud) { return 0; }
#endif /* CONFIG_HUGETLB_PAGE */

static inline int remap_4k_pfn(struct vm_area_struct *vma, unsigned long addr,
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 6ee17d09649c..974109bb85db 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -13,6 +13,7 @@
#include <linux/memblock.h>
#include <linux/of_fdt.h>
#include <linux/mm.h>
+#include <linux/hugetlb.h>
#include <linux/string_helpers.h>
#include <linux/stop_machine.h>

--
2.23.0