public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>, Andi Kleen <ak@suse.de>,
	Ian Campbell <ijc@hellion.org.uk>, Matt Mackall <mpm@selenic.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] x86 : relocate uninitialized variable in init DATA section into init BSS section
Date: Fri, 22 Feb 2008 10:38:00 +0800	[thread overview]
Message-ID: <1203647880.4707.39.camel@caritas-dev.intel.com> (raw)
In-Reply-To: <20080221095301.GA29361@elte.hu>

On Thu, 2008-02-21 at 10:53 +0100, Ingo Molnar wrote:
> * Huang, Ying <ying.huang@intel.com> wrote:
> 
> > > > -int __initdata early_ioremap_debug;
> > > > +int __initbss early_ioremap_debug;
> > > 
> > > will we get some sort of build error if we accidentally do:
> > > 
> > >    int __initbss early_ioremap_debug = 1;
> > > 
> > > ?
> > 
> > I tested it just now, and there is no build error.
> 
> well, that's bad. We'd silently ignore the " = 1" and boot up with that 
> value at 0, right? At minimum we need some really prominent build-time 
> _errors_ (i.e. aborted builds) if this ever happens. But ideally, 
> shouldnt this whole thing be done at link time? Couldnt the linker sort 
> the variables that are zero initialized into the right section, and move 
> this constant maintenance pressure off the programmer's shoulder?

I think another method is to add a new attribute into GCC to prepend or
append something to section name instead of just to replace it, like the
example as follow:

#define __initdata  __attribute__((section_append(".init")))

int __initdata early_ioremap_debug_data = 1;
int __initdata early_ioremap_debug_bss;

The GCC can deduce the section (.data or .bss) of global variable based
on whether it is initialized. That is, without attribute,
early_ioremap_debug_data will be in ".data", early_ioremap_debug_bss
will be in ".bss". And with section_append attribute,
early_ioremap_debug_data will be in ".data.init" and
early_ioremap_debug_bss will be in ".bss.init".

Best Regards,
Huang Ying


  parent reply	other threads:[~2008-02-22  2:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-21  8:15 [PATCH 2/2] x86 : relocate uninitialized variable in init DATA section into init BSS section Huang, Ying
2008-02-21  9:05 ` Ingo Molnar
2008-02-21  9:28   ` Huang, Ying
2008-02-21  9:53     ` Ingo Molnar
2008-02-21 12:18       ` Matt Mackall
2008-02-21 18:34       ` H. Peter Anvin
2008-02-22  2:38       ` Huang, Ying [this message]
2008-02-22  2:42         ` H. Peter Anvin

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=1203647880.4707.39.camel@caritas-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=ak@suse.de \
    --cc=hpa@zytor.com \
    --cc=ijc@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=mpm@selenic.com \
    --cc=tglx@linutronix.de \
    /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