mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Section mismatch warnings for early memory allocations
Date: Mon, 23 Jul 2007 18:43:31 +0200	[thread overview]
Message-ID: <20070723164331.GA7825@uranus.ravnborg.org> (raw)
In-Reply-To: <617E1C2C70743745A92448908E030B2A01FEBFA2@scsmsx411.amr.corp.intel.com>

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

      reply	other threads:[~2007-07-23 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-23 16:22 Luck, Tony
2007-07-23 16:43 ` Sam Ravnborg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070723164331.GA7825@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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