Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp52518imn; Mon, 25 Jul 2022 09:58:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uESRpn5ioacvTTScZWfYQgsvJXGCXCwT2n3KFkZy+t/qmx98GRtOtz8QbMZVHI4F8XoRIp X-Received: by 2002:a17:90b:1e4c:b0:1f2:c00f:5630 with SMTP id pi12-20020a17090b1e4c00b001f2c00f5630mr5127555pjb.208.1658768318015; Mon, 25 Jul 2022 09:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658768318; cv=none; d=google.com; s=arc-20160816; b=kPkDaPHDSO3f9dcB6T+OUtnRwoYKdAjoz8c1CTW20jggDWdXp5//sizejPxlbzeCUA BCxr0FLo2b+v+FWJvepdsODfzxg+IJISujx2kVmcQ+U4/14jInjwo3AyKvCiidGe37Y3 e9TJm2tASZ07PEQmYF/9n7w+xDaqe6pBXV6ybj/JDrz12SbZM7oFw3R8OnLNLT5/aKkl yyiYcYdtzaDKPjhn7FG9L0gLF0yYx9SO4kr15Jc2cU2UqAXwv311C3H0u+9vbz02PfK7 xzV2AbVd2gFPF9sqIGNEzuH5p+hQQTXSO8Sv5MHb/XQZQIlAwOp3y+Bkz3xrKJ972UIu gKtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gwAeatzr8L8EeWNbdF9kHgGkWoN25+shvuoroRPn+B4=; b=Rb5MNVwj/CpuAOxVAbUeiLAOMqrv0TgtI2Qndhb2Sydsqk7dBBLx2sIoSOlUb55LHJ DkU+aOi4BW//y8x7QR6ArDJ6MTntrVOJEXzfc3imsyCoCm0mNZI2fA186tgd5NRy3RCf ReFQLaqxVmpFKDvPQKwTqbrJ+bqHk+KdIz3jqa+R120Rmkq8glnvbFZJfYvr2xYRJ6iW r4KGylIQWwYNszSthAlY6cr0GBpmgqrOuLPhyO/QCmLtZDi2mQfD1bMWR//wXYOg+r3F getsjSvnjqhBFnJdiKdQdplP61e7pX7VDDnxOLRyroHd4SwcUSQuM6hCpv7Q3QMjVraz Q5nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a63b641000000b00415c6084bbcsi16274729pgt.739.2022.07.25.09.58.23; Mon, 25 Jul 2022 09:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235958AbiGYQWG (ORCPT + 99 others); Mon, 25 Jul 2022 12:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbiGYQWE (ORCPT ); Mon, 25 Jul 2022 12:22:04 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B3FD64CA for ; Mon, 25 Jul 2022 09:22:03 -0700 (PDT) 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 Cc: Michal =?iso-8859-1?Q?Such=E1nek?= , lkp@intel.com, linux-kernel@vger.kernel.org, npiggin@gmail.com, Julia.Lawall@inria.fr, paulus@samba.org, Jason Wang , linuxppc-dev@lists.ozlabs.org, hbathini@linux.ibm.com, joel@jms.id.au 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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