2008-08-20 19:08:42

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] x86: silence section mismatch warning - uv_cpu_init

WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
The function __cpuinit uv_cpu_init() references
a function __init uv_system_init().
If uv_system_init is only used by uv_cpu_init then
annotate uv_system_init with a matching annotation.

uv_system_init was ment to be called only once, so make explicit
by creating properly-named function and annotate it as __ref.

Old code relied on uv_node_to_blade being initialized to 0,
but it'a not initialized from anywhere and it's not static either.

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jack Steiner <[email protected]>
---
arch/x86/kernel/genx2apic_uv_x.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index 2d7e307..ecbfefa 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -385,14 +385,24 @@ static __init void uv_system_init(void)
map_mmioh_high(max_pnode);
}

+/* Wrapper for uv_system_init which calls it only once. */
+static void __ref uv_system_init_once(void)
+{
+ static bool uv_system_inited = false;
+
+ if (!uv_system_inited) {
+ uv_system_init();
+ uv_system_inited = true;
+ }
+}
+
/*
* Called on each cpu to initialize the per_cpu UV data area.
* ZZZ hotplug not supported yet
*/
void __cpuinit uv_cpu_init(void)
{
- if (!uv_node_to_blade)
- uv_system_init();
+ uv_system_init_once();

uv_blade_info[uv_numa_blade_id()].nr_online_cpus++;

--
1.5.4.5


2008-08-20 20:12:08

by Rufus & Azrael

[permalink] [raw]
Subject: Re:[PATCH] x86: silence section mismatch warning - uv_cpu_init

>
> WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
> The function __cpuinit uv_cpu_init() references
> a function __init uv_system_init().
> If uv_system_init is only used by uv_cpu_init then
> annotate uv_system_init with a matching annotation.
>
> uv_system_init was ment to be called only once, so make explicit
> by creating properly-named function and annotate it as __ref.
>
> Old code relied on uv_node_to_blade being initialized to 0,
> but it'a not initialized from anywhere and it's not static either.
>
> Signed-off-by: Marcin Slusarz<[email protected]>
> Cc: Ingo Molnar<[email protected]>
> Cc: Jack Steiner<[email protected]>
> ---
> arch/x86/kernel/genx2apic_uv_x.c | 14 ++++++++++++--
> 1 files changed, 12 insertions(+), 2 deletions(-)
> diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
> index 2d7e307..ecbfefa 100644
> --- a/arch/x86/kernel/genx2apic_uv_x.c
> +++ b/arch/x86/kernel/genx2apic_uv_x.c
> @@ -385,14 +385,24 @@ static __init void uv_system_init(void)
> map_mmioh_high(max_pnode);
> }
>
> +/* Wrapper for uv_system_init which calls it only once. */
> +static void __ref uv_system_init_once(void)
> +{
> + static bool uv_system_inited = false;
> +
> + if (!uv_system_inited) {
> + uv_system_init();
> + uv_system_inited = true;
> + }
> +}
> +
> /*
> * Called on each cpu to initialize the per_cpu UV data area.
> * ZZZ hotplug not supported yet
> */
> void __cpuinit uv_cpu_init(void)
> {
> - if (!uv_node_to_blade)
> - uv_system_init();
> + uv_system_init_once();
>
> uv_blade_info[uv_numa_blade_id()].nr_online_cpus++;
>
> --
> 1.5.4.5
>
>
Hi Marcin,

Your patch works fine on my box and section mismatch desappears.

Thanks.

Regards.

P.S. : 3 section mimsatches are remaining unsolved at this time on my
config :

WARNING: vmlinux.o(.meminit.text+0x2f2): Section mismatch in reference
from the function alloc_low_page() to the function
.init.text:early_ioremap()
The function __meminit alloc_low_page() references
a function __init early_ioremap().
If early_ioremap is only used by alloc_low_page then
annotate early_ioremap with a matching annotation.

WARNING: vmlinux.o(.meminit.text+0x608): Section mismatch in reference
from the function phys_pmd_init() to the function .init.text:early_iounmap()
The function __meminit phys_pmd_init() references
a function __init early_iounmap().
If early_iounmap is only used by phys_pmd_init then
annotate early_iounmap with a matching annotation.

WARNING: vmlinux.o(.meminit.text+0x861): Section mismatch in reference
from the function phys_pud_init() to the function .init.text:early_iounmap()
The function __meminit phys_pud_init() references
a function __init early_iounmap().
If early_iounmap is only used by phys_pud_init then
annotate early_iounmap with a matching annotation.

2008-08-21 10:35:11

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86: silence section mismatch warning - uv_cpu_init


* Marcin Slusarz <[email protected]> wrote:

> WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
> The function __cpuinit uv_cpu_init() references
> a function __init uv_system_init().
> If uv_system_init is only used by uv_cpu_init then
> annotate uv_system_init with a matching annotation.
>
> uv_system_init was ment to be called only once, so make explicit by
> creating properly-named function and annotate it as __ref.
>
> Old code relied on uv_node_to_blade being initialized to 0, but it'a
> not initialized from anywhere and it's not static either.

this needs a proper fix as the patch is too ugly. If something should be
called only once then it has to go into a codepath that will only
initialize it once.

Ingo

2008-08-21 18:50:22

by Marcin Slusarz

[permalink] [raw]
Subject: Re: [PATCH] x86: silence section mismatch warning - uv_cpu_init

On Thu, Aug 21, 2008 at 12:34:44PM +0200, Ingo Molnar wrote:
>
> * Marcin Slusarz <[email protected]> wrote:
>
> > WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
> > The function __cpuinit uv_cpu_init() references
> > a function __init uv_system_init().
> > If uv_system_init is only used by uv_cpu_init then
> > annotate uv_system_init with a matching annotation.
> >
> > uv_system_init was ment to be called only once, so make explicit by
> > creating properly-named function and annotate it as __ref.
> >
> > Old code relied on uv_node_to_blade being initialized to 0, but it'a
> > not initialized from anywhere and it's not static either.
>
> this needs a proper fix as the patch is too ugly. If something should be
> called only once then it has to go into a codepath that will only
> initialize it once.

Agreed. However it was the easiest solution.
Below is a new version of this fix. It was compile and boot tested
only on simple x86-64 box, so it needs testing on affected hardware
(where is_uv_system() == true).

---
From: Marcin Slusarz <[email protected]>
Subject: [PATCH v2] x86: fix section mismatch warning - uv_cpu_init

WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
The function __cpuinit uv_cpu_init() references
a function __init uv_system_init().
If uv_system_init is only used by uv_cpu_init then
annotate uv_system_init with a matching annotation.

uv_system_init was ment to be called only once, so do it from codepath
(native_smp_prepare_cpus) which is called once, right before activation
of other cpus (smp_init).

Note: old code relied on uv_node_to_blade being initialized to 0,
but it'a not initialized from anywhere.

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jack Steiner <[email protected]>
---
arch/x86/kernel/genx2apic_uv_x.c | 8 +++++---
arch/x86/kernel/smpboot.c | 3 +++
include/asm-x86/genapic_32.h | 1 +
include/asm-x86/genapic_64.h | 1 +
4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index 2d7e307..bfa837c 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -293,7 +293,9 @@ static __init void uv_rtc_init(void)
sn_rtc_cycles_per_second = ticks_per_sec;
}

-static __init void uv_system_init(void)
+static bool uv_system_inited;
+
+void __init uv_system_init(void)
{
union uvh_si_addr_map_config_u m_n_config;
union uvh_node_id_u node_id;
@@ -383,6 +385,7 @@ static __init void uv_system_init(void)
map_mmr_high(max_pnode);
map_config_high(max_pnode);
map_mmioh_high(max_pnode);
+ uv_system_inited = true;
}

/*
@@ -391,8 +394,7 @@ static __init void uv_system_init(void)
*/
void __cpuinit uv_cpu_init(void)
{
- if (!uv_node_to_blade)
- uv_system_init();
+ BUG_ON(!uv_system_inited);

uv_blade_info[uv_numa_blade_id()].nr_online_cpus++;

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index e139e61..7985c5b 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1221,6 +1221,9 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
printk(KERN_INFO "CPU%d: ", 0);
print_cpu_info(&cpu_data(0));
setup_boot_clock();
+
+ if (is_uv_system())
+ uv_system_init();
out:
preempt_enable();
}
diff --git a/include/asm-x86/genapic_32.h b/include/asm-x86/genapic_32.h
index b02ea6e..754d635 100644
--- a/include/asm-x86/genapic_32.h
+++ b/include/asm-x86/genapic_32.h
@@ -118,6 +118,7 @@ enum uv_system_type {UV_NONE, UV_LEGACY_APIC, UV_X2APIC, UV_NON_UNIQUE_APIC};
#define get_uv_system_type() UV_NONE
#define is_uv_system() 0
#define uv_wakeup_secondary(a, b) 1
+#define uv_system_init() do {} while (0)


#endif
diff --git a/include/asm-x86/genapic_64.h b/include/asm-x86/genapic_64.h
index 0f85046..a47d631 100644
--- a/include/asm-x86/genapic_64.h
+++ b/include/asm-x86/genapic_64.h
@@ -42,6 +42,7 @@ extern int is_uv_system(void);
extern struct genapic apic_x2apic_uv_x;
DECLARE_PER_CPU(int, x2apic_extra_bits);
extern void uv_cpu_init(void);
+extern void uv_system_init(void);
extern int uv_wakeup_secondary(int phys_apicid, unsigned int start_rip);

extern void setup_apic_routing(void);
--
1.5.4.5

2008-08-22 06:19:33

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86: silence section mismatch warning - uv_cpu_init


* Marcin Slusarz <[email protected]> wrote:

> From: Marcin Slusarz <[email protected]>
> Subject: [PATCH v2] x86: fix section mismatch warning - uv_cpu_init
>
> WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
> The function __cpuinit uv_cpu_init() references
> a function __init uv_system_init().
> If uv_system_init is only used by uv_cpu_init then
> annotate uv_system_init with a matching annotation.
>
> uv_system_init was ment to be called only once, so do it from codepath
> (native_smp_prepare_cpus) which is called once, right before activation
> of other cpus (smp_init).
>
> Note: old code relied on uv_node_to_blade being initialized to 0,
> but it'a not initialized from anywhere.

thanks - applied it to tip/x86/urgent. Jack, any objections?

Ingo

2008-08-22 11:31:48

by tip-bot for Jack Steiner

[permalink] [raw]
Subject: Re: [PATCH] x86: silence section mismatch warning - uv_cpu_init

On Fri, Aug 22, 2008 at 08:19:01AM +0200, Ingo Molnar wrote:
>
> * Marcin Slusarz <[email protected]> wrote:
>
> > From: Marcin Slusarz <[email protected]>
> > Subject: [PATCH v2] x86: fix section mismatch warning - uv_cpu_init
> >
> > WARNING: vmlinux.o(.cpuinit.text+0x3cc4): Section mismatch in reference from the function uv_cpu_init() to the function .init.text:uv_system_init()
> > The function __cpuinit uv_cpu_init() references
> > a function __init uv_system_init().
> > If uv_system_init is only used by uv_cpu_init then
> > annotate uv_system_init with a matching annotation.
> >
> > uv_system_init was ment to be called only once, so do it from codepath
> > (native_smp_prepare_cpus) which is called once, right before activation
> > of other cpus (smp_init).
> >
> > Note: old code relied on uv_node_to_blade being initialized to 0,
> > but it'a not initialized from anywhere.
>
> thanks - applied it to tip/x86/urgent. Jack, any objections?

Looks good. Thanks.

Acked-by: Jack Steiner <[email protected]>

--- jack