Bug 8679 - Section mismatch: reference to .init.text
Summary: Section mismatch: reference to .init.text
Status: CLOSED PATCH_ALREADY_AVAILABLE
Alias: None
Product: Other
Classification: Unclassified
Component: Configuration (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Satyam Sharma
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-26 10:50 UTC by wbrana
Modified: 2007-08-22 14:21 UTC (History)
3 users (show)

See Also:
Kernel Version: 2.6.22-rc6
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
config (39.36 KB, text/plain)
2007-06-26 10:52 UTC, wbrana
Details

Description wbrana 2007-06-26 10:50:27 UTC
Software Environment:
gcc 3.4.6, binutils 2.17

Problem Description:
Warnings appeared while building kernel:

WARNING: arch/i386/kernel/built-in.o(.data+0x2148): Section mismatch: reference to .init.text: (between 'thermal_throttle_cpu_notifier' and 'mtrr_mutex')
WARNING: kernel/built-in.o(.text+0x15f84): Section mismatch: reference to .init.text: (between 'kthreadd' and 'init_waitqueue_head')
Comment 1 wbrana 2007-06-26 10:52:13 UTC
Created attachment 11886 [details]
config
Comment 2 Randy Dunlap 2007-06-26 12:05:10 UTC
Subject: Re:  New: Section mismatch: reference to .init.text

On Tue, 26 Jun 2007 10:46:36 -0700 (PDT) bugme-daemon@bugzilla.kernel.org wrote:

> http://bugzilla.kernel.org/show_bug.cgi?id=8679
> 
>            Summary: Section mismatch: reference to .init.text
>            Product: Other
>            Version: 2.5
>      KernelVersion: 2.6.22-rc6
>           Platform: All
>         OS/Version: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: Configuration
>         AssignedTo: zippel@linux-m68k.org
>         ReportedBy: wbrana@gmail.com
> 
> 
> Software Environment:
> gcc 3.4.6, binutils 2.17
> 
> Problem Description:
> Warnings appeared while building kernel:
> 
> WARNING: arch/i386/kernel/built-in.o(.data+0x2148): Section mismatch:
> reference
> to .init.text: (between 'thermal_throttle_cpu_notifier' and 'mtrr_mutex')
> WARNING: kernel/built-in.o(.text+0x15f84): Section mismatch: reference to
> .init.text: (between 'kthreadd' and 'init_waitqueue_head')


I don't see the kernel/built-in.o warning when I build this (I have
binutils 2.16++).  Can you test the patch below to verify that it
fixes the warning?

On the other warning ('thermal_throttle_cpu_notifier'), we have:

static struct notifier_block thermal_throttle_cpu_notifier =
{
	.notifier_call = thermal_throttle_cpu_callback,
};

where CONFIG_CPU_HOTPLUG=n, so __cpuinit == __init in:

static __cpuinit int thermal_throttle_cpu_callback(struct notifier_block *nfb,
						   unsigned long action,
						   void *hcpu)


so CPU hotplug actions should never happen here.  Still, we have
a registered notifier that is in __init space and has been discarded... :(
Any suggestions out there?



---
From: Randy Dunlap <randy.dunlap@oracle.com>

kthreadd_setup() is in an __init section, but we know that it's
safe to be called from kthreadd() since the latter is only called
at kernel init time, so mark kthreadd_setup() __init_refok so
that modpost won't complain about what text section it is in.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
 kernel/kthread.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.22-rc6.orig/kernel/kthread.c
+++ linux-2.6.22-rc6/kernel/kthread.c
@@ -215,7 +215,7 @@ int kthread_stop(struct task_struct *k)
 EXPORT_SYMBOL(kthread_stop);
 
 
-static __init void kthreadd_setup(void)
+static __init_refok void kthreadd_setup(void)
 {
 	struct task_struct *tsk = current;
 
Comment 3 Alexander Bokovoy 2007-06-26 12:36:54 UTC
Subject: Re:  Section mismatch: reference to .init.text

> 
> On the other warning ('thermal_throttle_cpu_notifier'), we have:
> 
> static struct notifier_block thermal_throttle_cpu_notifier =
> {
>         .notifier_call = thermal_throttle_cpu_callback,
> };
> 
> where CONFIG_CPU_HOTPLUG=n, so __cpuinit == __init in:
> 
> static __cpuinit int thermal_throttle_cpu_callback(struct notifier_block
> *nfb,
>                                                    unsigned long action,
>                                                    void *hcpu)
> 
> 
> so CPU hotplug actions should never happen here.  Still, we have
> a registered notifier that is in __init space and has been discarded... :(
> Any suggestions out there?

Kill the three uses of __cpuinit in this file.
The noise/benefit level does not justofy anything special.

We could do:
static struct notifier_block __init_refok thermal_throttle_cpu_notifier =

and we could accept __init references from variables named *_notifier.

But seems to much special casing to my taste.

	Sam
Comment 4 Satyam Sharma 2007-08-20 21:27:05 UTC
[ The kthread warning is resolved in latest kernel. ]

(In reply to comment #3)
> Subject: Re:  Section mismatch: reference to .init.text
> 
> > 
> > On the other warning ('thermal_throttle_cpu_notifier'), we have:
> > 
> > static struct notifier_block thermal_throttle_cpu_notifier =
> > {
> >         .notifier_call = thermal_throttle_cpu_callback,
> > };
> > 
> > where CONFIG_CPU_HOTPLUG=n, so __cpuinit == __init in:
> > 
> > static __cpuinit int thermal_throttle_cpu_callback(...)
> > 
> > so CPU hotplug actions should never happen here.  Still, we have
> > a registered notifier that is in __init space and has been discarded... :(
> > Any suggestions out there?
> 
> Kill the three uses of __cpuinit in this file.
> The noise/benefit level does not justofy anything special.
> 
> We could do:
> static struct notifier_block __init_refok thermal_throttle_cpu_notifier =
> and we could accept __init references from variables named *_notifier.> > 
> 
> But seems to much special casing to my taste.

Hi Sam,

When CONFIG_HOTPLUG_CPU=n, this warning occurs because the
thermal_throttle_cpu_notifier notifier_block is in .data but
the callback function itself is __cpuinit == .init.text.
The warning is bogus, because the callback will never be
called out if HOTPLUG_CPU=n in the first place.

To shut the warning up, the notifier block itself must be made
__cpuinitdata because it has no purpose in life after initcall
stage, if HOTPLUG_CPU=n, just like the callback function itself
does not have.
Comment 5 Satyam Sharma 2007-08-20 21:40:33 UTC
Hi wbrana, please try the patch at: http://lkml.org/lkml/2007/8/21/6
and let us know if the thermal_throttle_cpu_notifier section mismatch
warning you're seeing goes away, so we can close this bug. Thank you.
Comment 6 wbrana 2007-08-21 12:59:46 UTC
I compiled 2.6.22.4 with patch from http://lkml.org/lkml/2007/8/21/6
Hunk #1 succeeded at 150 (offset -2 lines).

I can't see thermal_throttle_cpu_notifier section mismatch warning.

Note You need to log in before you can comment on or make changes to this bug.