* Section mismatch warnings for early memory allocations
@ 2007-07-23 16:22 Luck, Tony
2007-07-23 16:43 ` Sam Ravnborg
0 siblings, 1 reply; 2+ messages in thread
From: Luck, Tony @ 2007-07-23 16:22 UTC (permalink / raw)
To: Linux Kernel Mailing List; +Cc: Sam Ravnborg
Checking for section mismatches across all of vmlinux is kicking
out a bunch of new warnings. Many of them real, but I have a
few from routines like this:
foo(...)
{
static int first_time = 1;
if (first_time) {
all_i_need = alloc_bootmem(NR_CPUS * xxx);
first_time = 0;
}
... use smp_processor_id() to use pre-allocated memory ...
}
Now this is safe, since the first call to foo is made when alloc_bootmem
is still available. But it kicks out a "Section mismatch" warning since
a non __init routine (foo) is calling an __init one.
Any suggestions on how to tell modpost that this is safe?
-Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Section mismatch warnings for early memory allocations
2007-07-23 16:22 Section mismatch warnings for early memory allocations Luck, Tony
@ 2007-07-23 16:43 ` Sam Ravnborg
0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2007-07-23 16:43 UTC (permalink / raw)
To: Luck, Tony; +Cc: Linux Kernel Mailing List
On Mon, Jul 23, 2007 at 09:22:14AM -0700, Luck, Tony wrote:
> Checking for section mismatches across all of vmlinux is kicking
> out a bunch of new warnings. Many of them real, but I have a
> few from routines like this:
>
> foo(...)
> {
> static int first_time = 1;
>
> if (first_time) {
> all_i_need = alloc_bootmem(NR_CPUS * xxx);
> first_time = 0;
> }
> ... use smp_processor_id() to use pre-allocated memory ...
> }
>
>
> Now this is safe, since the first call to foo is made when alloc_bootmem
> is still available. But it kicks out a "Section mismatch" warning since
> a non __init routine (foo) is calling an __init one.
>
> Any suggestions on how to tell modpost that this is safe?
Best way is to use __init_refok like this:
/*
* Call an __init function only first time as guarded by first_time.
* Teach modpost that this is OK.
*/
void __init_refok foo()
{
if (first_time) {
all_i_need = alloc_bootmem(NR_CPUS * xxx);
first_time = 0;
}
}
Sam
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-23 16:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-23 16:22 Section mismatch warnings for early memory allocations Luck, Tony
2007-07-23 16:43 ` Sam Ravnborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome