From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: lkp@intel.com, linux-kernel@vger.kernel.org, npiggin@gmail.com,
Julia.Lawall@inria.fr, paulus@samba.org,
"Jason Wang" <wangborong@cdjrlc.com>,
"Michal Suchánek" <msuchanek@suse.de>,
linuxppc-dev@lists.ozlabs.org, hbathini@linux.ibm.com,
joel@jms.id.au
Subject: Re: [PATCH] powerpc: Remove the static variable initialisations to 0
Date: Mon, 25 Jul 2022 11:13:23 -0500 [thread overview]
Message-ID: <20220725161323.GT25951@gate.crashing.org> (raw)
In-Reply-To: <87fsipdg7b.fsf@mpe.ellerman.id.au>
On Mon, Jul 25, 2022 at 01:27:52PM +1000, Michael Ellerman wrote:
> Segher Boessenkool <segher@kernel.crashing.org> writes:
> > On Sat, Jul 23, 2022 at 03:34:05PM +0200, Michal Suchánek wrote:
> >> Hello,
> >>
> >> On Sat, Jul 23, 2022 at 05:24:36PM +0800, Jason Wang wrote:
> >> > Initialise global and static variable to 0 is always unnecessary.
> >> > Remove the unnecessary initialisations.
> >>
> >> Isn't this change also unnecessary?
> >>
> >> Initializing to 0 does not affect correctness, or even any kind of
> >> semantics in any way.
> >
> > It did make a difference when the kernel was still compiled with
> > -fcommon (which used to be the GCC default on most configurations, it is
> > traditional on Unix). No explicit initialiser puts an object in .bss if
> > you use -fcommon. This matters a bit for data layout.
>
> The kernel has built with -fno-common since ~2002.
2001, yes (255649c18287). And before that it was important to
initialise everything with static storage duration explicitly in the
source code. It was part of the collective memory, I wondered if this
patch originated that way?
> I think the belief is that an explicit initialiser of 0 forces the
> variable into .data, but AFAICS that is not true with any compiler we
> support.
Exactly, you get identical code either way, if you use -fno-common.
People will still see this difference if they use a compiler before
GCC 10 for compiling most other things though.
Segher
prev parent reply other threads:[~2022-07-25 16:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-23 9:24 [PATCH] powerpc: Remove the static variable initialisations to 0 Jason Wang
2022-07-23 13:34 ` Michal Suchánek
2022-07-23 19:22 ` Segher Boessenkool
2022-07-25 3:27 ` Michael Ellerman
2022-07-25 16:13 ` Segher Boessenkool [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=20220725161323.GT25951@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=Julia.Lawall@inria.fr \
--cc=hbathini@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lkp@intel.com \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=wangborong@cdjrlc.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;
as well as URLs for NNTP newsgroup(s).