From: Michael Ellerman <mpe@ellerman.id.au>
To: "Segher Boessenkool" <segher@kernel.crashing.org>,
"Michal Suchánek" <msuchanek@suse.de>
Cc: lkp@intel.com, linux-kernel@vger.kernel.org,
Jason Wang <wangborong@cdjrlc.com>,
Julia.Lawall@inria.fr, paulus@samba.org, npiggin@gmail.com,
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 13:27:52 +1000 [thread overview]
Message-ID: <87fsipdg7b.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20220723192211.GP25951@gate.crashing.org>
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.
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.
cheers
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: "Segher Boessenkool" <segher@kernel.crashing.org>,
"Michal Suchánek" <msuchanek@suse.de>
Cc: lkp@intel.com, linux-kernel@vger.kernel.org, npiggin@gmail.com,
Julia.Lawall@inria.fr, paulus@samba.org,
Jason Wang <wangborong@cdjrlc.com>,
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 13:27:52 +1000 [thread overview]
Message-ID: <87fsipdg7b.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20220723192211.GP25951@gate.crashing.org>
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.
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.
cheers
next prev parent reply other threads:[~2022-07-25 3:28 UTC|newest]
Thread overview: 10+ 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 9:24 ` Jason Wang
2022-07-23 13:34 ` Michal Suchánek
2022-07-23 13:34 ` Michal Suchánek
2022-07-23 19:22 ` Segher Boessenkool
2022-07-23 19:22 ` Segher Boessenkool
2022-07-25 3:27 ` Michael Ellerman [this message]
2022-07-25 3:27 ` Michael Ellerman
2022-07-25 16:13 ` Segher Boessenkool
2022-07-25 16:13 ` Segher Boessenkool
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=87fsipdg7b.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--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=msuchanek@suse.de \
--cc=npiggin@gmail.com \
--cc=paulus@samba.org \
--cc=segher@kernel.crashing.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.