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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4896C433DB for ; Wed, 10 Mar 2021 22:10:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F02764FC1 for ; Wed, 10 Mar 2021 22:10:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F02764FC1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fluxnic.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:Message-ID:In-Reply-To: Subject:cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+uH7fM7PAiYyIoAv8OzNMlx9sIOsEsVs3EcOEiH8ygk=; b=NTHgcYtyVY5ZzKET3kzZLIP6a 36Z221fNdaH1D5LI4i/uU9IKeihH900pvThAvs7IMpd2gemzG4ZRzEdgkYNa0DbqdaAqUPwYUYhbI 2/NH02NWwKrB23R9J3ssPfkKgnewZ6cn1JzbLIpacu0hw6eeN8ukji27grNFV6jxXM8catUhB3BFR xpgtTgpW+bhLikgTjVwcWJJRCaTxcvnZF6ohADEI9BWAzC6YdNHxM3JJd0zL/wELd/CgWycbYvgp5 nLLg+y/uH6xq9KnZ2quAfXMT5N97QhpP6ElCP8wQDtV1742TdAT67KphNj5ZYD2mqgZpYcBcuWJm5 wFsxyF53g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK70V-007t0Z-Ei; Wed, 10 Mar 2021 22:08:43 +0000 Received: from pb-sasl-trial2.pobox.com ([64.147.108.86]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK70R-007t0D-80 for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 22:08:41 +0000 Received: from pb-sasl-trial2.pobox.com (localhost.local [127.0.0.1]) by pb-sasl-trial2.pobox.com (Postfix) with ESMTP id EB027364A1; Wed, 10 Mar 2021 17:08:37 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=Ug9o/CNDr8Sdv0PtCWP+/W5LLys=; b=YzueOr RXeO+d0hkA3aB22fLKuAuVW+6xCxMKgJ36LaUGfu6wKS0QHG6mCTTuj4xSarEzy/ tcfTLGRsN8Mcv4mSu3s0fscIHpBIc8kCxhWzR7JfocZuVEqCfbfHGeBjNadig8Cf LyjreeRbxSxNu4idNAFfChoMccFtTOQgUzDpg= Received: from pb-smtp2.nyi.icgroup.com (pb-smtp2.pobox.com [10.90.30.54]) by pb-sasl-trial2.pobox.com (Postfix) with ESMTP id CD0C53649E; Wed, 10 Mar 2021 17:08:37 -0500 (EST) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=x4HMzILFvvyEh61HaVAZo3iq7tjd/ZgNnUzJbrp7ba4=; b=R4OnUqYuF8FypRdz9+ryCiO5dK8WcX4T1DnDxapiRHsEgc36uxSzCbKiOoCELEOjxPoVZ9nDlG/5XqVyNoyWCUhnU8iAOb5mI0cmXXiJ8Cy5r0KGKcf0mFopQ5S6hD4SHUONJ5tZfF5fyXF+NqMk8XzLjRr1Um+4/zPJDScf46M= Received: from yoda.home (unknown [24.203.50.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 3F050ACB8D; Wed, 10 Mar 2021 17:08:37 -0500 (EST) (envelope-from nico@fluxnic.net) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 522552DA004F; Wed, 10 Mar 2021 17:08:36 -0500 (EST) Date: Wed, 10 Mar 2021 17:08:36 -0500 (EST) From: Nicolas Pitre To: Nick Desaulniers cc: kernel-toolchains@vger.kernel.org, Masahiro Yamada , Nicholas Piggin , Fangrui Song , Ard Biesheuvel , Andrew Scull , Mark Brown , Catalin Marinas , clang-built-linux , David Brazdil , Geert Uytterhoeven , Ionela Voinescu , Kees Cook , Kristina Martsenko , Linux ARM , "linux-kernel@vger.kernel.org" , Mark Rutland , Marc Zyngier , Nathan Chancellor , Vincenzo Frascino , Will Deacon , Arnd Bergmann Subject: Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION In-Reply-To: Message-ID: <2npq25ps-q960-795-96s5-rq6736pq693q@syhkavp.arg> References: <20210225112122.2198845-1-arnd@kernel.org> <20210226211323.arkvjnr4hifxapqu@google.com> <1614559739.p25z5x88wl.astroid@bobo.none> MIME-Version: 1.0 X-Pobox-Relay-ID: 29C36E84-81ED-11EB-B246-74DE23BA3BAF-78420484!pb-smtp2.pobox.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_220839_487649_E17A8E91 X-CRM114-Status: GOOD ( 25.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 10 Mar 2021, Nick Desaulniers wrote: > On Wed, Mar 10, 2021 at 1:08 PM Arnd Bergmann wrote: > > > > On Wed, Mar 10, 2021 at 9:50 PM Masahiro Yamada wrote: > > > On Mon, Mar 1, 2021 at 10:11 AM Nicholas Piggin wrote: > > > > Excerpts from Arnd Bergmann's message of February 27, 2021 7:49 pm: > > > > > > > > masahiro@oscar:~/ref/linux$ echo 'void this_func_is_unused(void) {}' > > > >> kernel/cpu.c > > > masahiro@oscar:~/ref/linux$ export > > > CROSS_COMPILE=/home/masahiro/tools/powerpc-10.1.0/bin/powerpc-linux- > > > masahiro@oscar:~/ref/linux$ make ARCH=powerpc defconfig > > > masahiro@oscar:~/ref/linux$ ./scripts/config -e EXPERT > > > masahiro@oscar:~/ref/linux$ ./scripts/config -e LD_DEAD_CODE_DATA_ELIMINATION > > > masahiro@oscar:~/ref/linux$ > > > ~/tools/powerpc-10.1.0/bin/powerpc-linux-nm -n vmlinux | grep > > > this_func > > > c000000000170560 T .this_func_is_unused > > > c000000001d8d560 D this_func_is_unused > > > masahiro@oscar:~/ref/linux$ grep DEAD_CODE_ .config > > > CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y > > > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y > > > > > > > > > If I remember correctly, > > > LD_DEAD_CODE_DATA_ELIMINATION dropped unused functions > > > when I tried it last time. > > > > > > > > > I also tried arm64 with a HAVE_LD_DEAD_CODE_DATA_ELIMINATION hack. > > > The result was the same. > > > > > > > > > > > > Am I missing something? > > > > It's possible that it only works in combination with CLANG_LTO now > > because something broke. I definitely saw a reduction in kernel > > size when both options are enabled, but did not try a simple test > > case like you did. > > > > Maybe some other reference gets created that prevents the function > > from being garbage-collected unless that other option is removed > > as well? > > I wish the linker had a debug flag that could let developers discover > the decisions it made during --gc-sections as to why certain symbols > were retained/kept or not. The GNU LD has --print-gc-sections to list those sections that were dropped. And normally you should be able to find why a section wasn't dropped by looking for dependencies in the linker map file. Nicolas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel