* [PATCH] powerpc: Remove the static variable initialisations to 0 @ 2022-07-23 9:24 Jason Wang 2022-07-23 13:34 ` Michal Suchánek 0 siblings, 1 reply; 5+ messages in thread From: Jason Wang @ 2022-07-23 9:24 UTC (permalink / raw) To: paulus Cc: lkp, linux-kernel, npiggin, Julia.Lawall, joel, Jason Wang, linuxppc-dev, hbathini Initialise global and static variable to 0 is always unnecessary. Remove the unnecessary initialisations. Signed-off-by: Jason Wang <wangborong@cdjrlc.com> --- arch/powerpc/kexec/core_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c index c2bea9db1c1e..2407214e3f41 100644 --- a/arch/powerpc/kexec/core_64.c +++ b/arch/powerpc/kexec/core_64.c @@ -135,7 +135,7 @@ notrace void kexec_copy_flush(struct kimage *image) #ifdef CONFIG_SMP -static int kexec_all_irq_disabled = 0; +static int kexec_all_irq_disabled; static void kexec_smp_down(void *arg) { -- 2.35.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc: Remove the static variable initialisations to 0 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 0 siblings, 1 reply; 5+ messages in thread From: Michal Suchánek @ 2022-07-23 13:34 UTC (permalink / raw) To: Jason Wang Cc: lkp, linux-kernel, npiggin, Julia.Lawall, paulus, joel, linuxppc-dev, hbathini 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. The current code is slightly easier to understand. And changing the code introduces history noise for na gain. Thanks Michal > > Signed-off-by: Jason Wang <wangborong@cdjrlc.com> > --- > arch/powerpc/kexec/core_64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c > index c2bea9db1c1e..2407214e3f41 100644 > --- a/arch/powerpc/kexec/core_64.c > +++ b/arch/powerpc/kexec/core_64.c > @@ -135,7 +135,7 @@ notrace void kexec_copy_flush(struct kimage *image) > > #ifdef CONFIG_SMP > > -static int kexec_all_irq_disabled = 0; > +static int kexec_all_irq_disabled; > > static void kexec_smp_down(void *arg) > { > -- > 2.35.1 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc: Remove the static variable initialisations to 0 2022-07-23 13:34 ` Michal Suchánek @ 2022-07-23 19:22 ` Segher Boessenkool 2022-07-25 3:27 ` Michael Ellerman 0 siblings, 1 reply; 5+ messages in thread From: Segher Boessenkool @ 2022-07-23 19:22 UTC (permalink / raw) To: Michal Suchánek Cc: lkp, linux-kernel, npiggin, Julia.Lawall, paulus, Jason Wang, linuxppc-dev, hbathini, joel 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 current code is slightly easier to understand. > > And changing the code introduces history noise for na gain. Yup. This does give you some code golf points of course ;-) Segher ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc: Remove the static variable initialisations to 0 2022-07-23 19:22 ` Segher Boessenkool @ 2022-07-25 3:27 ` Michael Ellerman 2022-07-25 16:13 ` Segher Boessenkool 0 siblings, 1 reply; 5+ messages in thread From: Michael Ellerman @ 2022-07-25 3:27 UTC (permalink / raw) To: Segher Boessenkool, Michal Suchánek Cc: lkp, linux-kernel, Jason Wang, Julia.Lawall, paulus, npiggin, linuxppc-dev, hbathini, joel 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc: Remove the static variable initialisations to 0 2022-07-25 3:27 ` Michael Ellerman @ 2022-07-25 16:13 ` Segher Boessenkool 0 siblings, 0 replies; 5+ messages in thread From: Segher Boessenkool @ 2022-07-25 16:13 UTC (permalink / raw) To: Michael Ellerman Cc: lkp, linux-kernel, npiggin, Julia.Lawall, paulus, Jason Wang, Michal Suchánek, linuxppc-dev, hbathini, joel 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-25 16:18 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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).