From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D2A4C43334 for ; Mon, 25 Jul 2022 16:18:17 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Ls4w76fM9z3c3N for ; Tue, 26 Jul 2022 02:18:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.crashing.org (client-ip=63.228.1.57; helo=gate.crashing.org; envelope-from=segher@kernel.crashing.org; receiver=) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lists.ozlabs.org (Postfix) with ESMTP id 4Ls4vf2sQ2z306K for ; Tue, 26 Jul 2022 02:17:49 +1000 (AEST) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 26PGDQiC023484; Mon, 25 Jul 2022 11:13:26 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 26PGDNOE023478; Mon, 25 Jul 2022 11:13:23 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 25 Jul 2022 11:13:23 -0500 From: Segher Boessenkool To: Michael Ellerman Subject: Re: [PATCH] powerpc: Remove the static variable initialisations to 0 Message-ID: <20220725161323.GT25951@gate.crashing.org> References: <20220723092436.7149-1-wangborong@cdjrlc.com> <20220723133405.GF17705@kitsune.suse.cz> <20220723192211.GP25951@gate.crashing.org> <87fsipdg7b.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87fsipdg7b.fsf@mpe.ellerman.id.au> User-Agent: Mutt/1.4.2.3i X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lkp@intel.com, linux-kernel@vger.kernel.org, npiggin@gmail.com, Julia.Lawall@inria.fr, paulus@samba.org, Jason Wang , Michal =?iso-8859-1?Q?Such=E1nek?= , linuxppc-dev@lists.ozlabs.org, hbathini@linux.ibm.com, joel@jms.id.au Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Jul 25, 2022 at 01:27:52PM +1000, Michael Ellerman wrote: > Segher Boessenkool 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