2023-04-15 08:23:32

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] [v2] mm: make arch_has_descending_max_zone_pfns() static

From: Arnd Bergmann <[email protected]>

clang produces a build failure on x86 for some randconfig builds
after a change that moves around code to mm/mm_init.c:

Cannot find symbol for section 2: .text.
mm/mm_init.o: failed

I have not been able to figure out why this happens, but the __weak
annotation on arch_has_descending_max_zone_pfns() is the trigger here.

Removing the weak function in favor of an open-coded Kconfig option
check avoids the problem and becomes clearer as well as better to
optimize by the compiler.

Fixes: 9420f89db2dd ("mm: move most of core MM initialization to mm/mm_init.c")
Cc: [email protected]
Signed-off-by: Arnd Bergmann <[email protected]>
---
v2: fix logic bug reported-by: kernel test robot <[email protected]>,
see https://lore.kernel.org/oe-lkp/[email protected]
---
arch/arc/mm/init.c | 5 -----
include/linux/mm.h | 1 -
mm/mm_init.c | 4 ++--
3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce4e939a7f07..2b89b6c53801 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -74,11 +74,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
base, TO_MB(size), !in_use ? "Not used":"");
}

-bool arch_has_descending_max_zone_pfns(void)
-{
- return !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
-}
-
/*
* First memory setup routine called from setup_arch()
* 1. setup swapper's mm @init_mm
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 63acf4a598fe..75d8adce0aee 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3061,7 +3061,6 @@ extern void setup_per_cpu_pageset(void);
extern int min_free_kbytes;
extern int watermark_boost_factor;
extern int watermark_scale_factor;
-extern bool arch_has_descending_max_zone_pfns(void);

/* nommu.c */
extern atomic_long_t mmap_pages_allocated;
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 35302b7bca83..7f7f9c677854 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1754,9 +1754,9 @@ static void __init free_area_init_memoryless_node(int nid)
* Some architectures, e.g. ARC may have ZONE_HIGHMEM below ZONE_NORMAL. For
* such cases we allow max_zone_pfn sorted in the descending order
*/
-bool __weak arch_has_descending_max_zone_pfns(void)
+static bool arch_has_descending_max_zone_pfns(void)
{
- return false;
+ return IS_ENABLED(CONFIG_ARC) && !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
}

/**
--
2.39.2


2023-04-17 10:08:40

by Vlastimil Babka

[permalink] [raw]
Subject: Re: [PATCH] [v2] mm: make arch_has_descending_max_zone_pfns() static

On 4/15/23 10:18, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> clang produces a build failure on x86 for some randconfig builds
> after a change that moves around code to mm/mm_init.c:
>
> Cannot find symbol for section 2: .text.
> mm/mm_init.o: failed
>
> I have not been able to figure out why this happens, but the __weak
> annotation on arch_has_descending_max_zone_pfns() is the trigger here.
>
> Removing the weak function in favor of an open-coded Kconfig option
> check avoids the problem and becomes clearer as well as better to
> optimize by the compiler.
>
> Fixes: 9420f89db2dd ("mm: move most of core MM initialization to mm/mm_init.c")
> Cc: [email protected]
> Signed-off-by: Arnd Bergmann <[email protected]>

Makes sense if there's only a single arch that has the special case.

Acked-by: Vlastimil Babka <[email protected]>

> ---
> v2: fix logic bug reported-by: kernel test robot <[email protected]>,
> see https://lore.kernel.org/oe-lkp/[email protected]
> ---
> arch/arc/mm/init.c | 5 -----
> include/linux/mm.h | 1 -
> mm/mm_init.c | 4 ++--
> 3 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
> index ce4e939a7f07..2b89b6c53801 100644
> --- a/arch/arc/mm/init.c
> +++ b/arch/arc/mm/init.c
> @@ -74,11 +74,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> base, TO_MB(size), !in_use ? "Not used":"");
> }
>
> -bool arch_has_descending_max_zone_pfns(void)
> -{
> - return !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
> -}
> -
> /*
> * First memory setup routine called from setup_arch()
> * 1. setup swapper's mm @init_mm
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 63acf4a598fe..75d8adce0aee 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3061,7 +3061,6 @@ extern void setup_per_cpu_pageset(void);
> extern int min_free_kbytes;
> extern int watermark_boost_factor;
> extern int watermark_scale_factor;
> -extern bool arch_has_descending_max_zone_pfns(void);
>
> /* nommu.c */
> extern atomic_long_t mmap_pages_allocated;
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 35302b7bca83..7f7f9c677854 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1754,9 +1754,9 @@ static void __init free_area_init_memoryless_node(int nid)
> * Some architectures, e.g. ARC may have ZONE_HIGHMEM below ZONE_NORMAL. For
> * such cases we allow max_zone_pfn sorted in the descending order
> */
> -bool __weak arch_has_descending_max_zone_pfns(void)
> +static bool arch_has_descending_max_zone_pfns(void)
> {
> - return false;
> + return IS_ENABLED(CONFIG_ARC) && !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
> }
>
> /**

2023-04-17 19:02:30

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH] [v2] mm: make arch_has_descending_max_zone_pfns() static

On Sat, 15 Apr 2023 10:18:20 +0200 Arnd Bergmann <[email protected]> wrote:

> From: Arnd Bergmann <[email protected]>
>
> clang produces a build failure on x86 for some randconfig builds
> after a change that moves around code to mm/mm_init.c:
>
> Cannot find symbol for section 2: .text.
> mm/mm_init.o: failed
>
> I have not been able to figure out why this happens, but the __weak
> annotation on arch_has_descending_max_zone_pfns() is the trigger here.
>
> Removing the weak function in favor of an open-coded Kconfig option
> check avoids the problem and becomes clearer as well as better to
> optimize by the compiler.
>
> Fixes: 9420f89db2dd ("mm: move most of core MM initialization to mm/mm_init.c")
> Cc: [email protected]
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> v2: fix logic bug reported-by: kernel test robot <[email protected]>,
> see https://lore.kernel.org/oe-lkp/[email protected]

I was also encountering similar issue, and confirmed replacing the old version
of this patch with this one fixes it.

Tested-by: SeongJae Park <[email protected]>


Thanks,
SJ

> ---
> arch/arc/mm/init.c | 5 -----
> include/linux/mm.h | 1 -
> mm/mm_init.c | 4 ++--
> 3 files changed, 2 insertions(+), 8 deletions(-)

2023-04-18 12:37:26

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] [v2] mm: make arch_has_descending_max_zone_pfns() static

Hi Arnd,

On Sat, 15 Apr 2023, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> clang produces a build failure on x86 for some randconfig builds
> after a change that moves around code to mm/mm_init.c:
>
> Cannot find symbol for section 2: .text.
> mm/mm_init.o: failed
>
> I have not been able to figure out why this happens, but the __weak
> annotation on arch_has_descending_max_zone_pfns() is the trigger here.
>
> Removing the weak function in favor of an open-coded Kconfig option
> check avoids the problem and becomes clearer as well as better to
> optimize by the compiler.
>
> Fixes: 9420f89db2dd ("mm: move most of core MM initialization to mm/mm_init.c")
> Cc: [email protected]
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> v2: fix logic bug reported-by: kernel test robot <[email protected]>,
> see https://lore.kernel.org/oe-lkp/[email protected]

Thanks, reverting commit 413d478d3b366d09 ("mm: make
arch_has_descending_max_zone_pfns() static") in next-20230417 and
applying your v2 makes Salvator-XS regain its DMA memory zone.

Tested-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2023-04-18 20:26:54

by Mike Rapoport

[permalink] [raw]
Subject: Re: [PATCH] [v2] mm: make arch_has_descending_max_zone_pfns() static

On Sat, Apr 15, 2023 at 10:18:20AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> clang produces a build failure on x86 for some randconfig builds
> after a change that moves around code to mm/mm_init.c:
>
> Cannot find symbol for section 2: .text.
> mm/mm_init.o: failed
>
> I have not been able to figure out why this happens, but the __weak
> annotation on arch_has_descending_max_zone_pfns() is the trigger here.
>
> Removing the weak function in favor of an open-coded Kconfig option
> check avoids the problem and becomes clearer as well as better to
> optimize by the compiler.
>
> Fixes: 9420f89db2dd ("mm: move most of core MM initialization to mm/mm_init.c")
> Cc: [email protected]
> Signed-off-by: Arnd Bergmann <[email protected]>

Acked-by: Mike Rapoport (IBM) <[email protected]>

> ---
> v2: fix logic bug reported-by: kernel test robot <[email protected]>,
> see https://lore.kernel.org/oe-lkp/[email protected]
> ---
> arch/arc/mm/init.c | 5 -----
> include/linux/mm.h | 1 -
> mm/mm_init.c | 4 ++--
> 3 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
> index ce4e939a7f07..2b89b6c53801 100644
> --- a/arch/arc/mm/init.c
> +++ b/arch/arc/mm/init.c
> @@ -74,11 +74,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> base, TO_MB(size), !in_use ? "Not used":"");
> }
>
> -bool arch_has_descending_max_zone_pfns(void)
> -{
> - return !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
> -}
> -
> /*
> * First memory setup routine called from setup_arch()
> * 1. setup swapper's mm @init_mm
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 63acf4a598fe..75d8adce0aee 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3061,7 +3061,6 @@ extern void setup_per_cpu_pageset(void);
> extern int min_free_kbytes;
> extern int watermark_boost_factor;
> extern int watermark_scale_factor;
> -extern bool arch_has_descending_max_zone_pfns(void);
>
> /* nommu.c */
> extern atomic_long_t mmap_pages_allocated;
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 35302b7bca83..7f7f9c677854 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1754,9 +1754,9 @@ static void __init free_area_init_memoryless_node(int nid)
> * Some architectures, e.g. ARC may have ZONE_HIGHMEM below ZONE_NORMAL. For
> * such cases we allow max_zone_pfn sorted in the descending order
> */
> -bool __weak arch_has_descending_max_zone_pfns(void)
> +static bool arch_has_descending_max_zone_pfns(void)
> {
> - return false;
> + return IS_ENABLED(CONFIG_ARC) && !IS_ENABLED(CONFIG_ARC_HAS_PAE40);
> }
>
> /**
> --
> 2.39.2
>

--
Sincerely yours,
Mike.