Message ID | 20230523165502.2592-1-jszhang@kernel.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2296852vqo; Tue, 23 May 2023 10:13:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lxde/iio3tbkZ2t2SXY6G1i0l1IZ85WVNam7j+LwhjX+PxqgZ623i0fEpfjLIgi4I+W5D X-Received: by 2002:a05:6a20:1445:b0:101:a459:bb0d with SMTP id a5-20020a056a20144500b00101a459bb0dmr16600499pzi.2.1684862027338; Tue, 23 May 2023 10:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684862027; cv=none; d=google.com; s=arc-20160816; b=1AyuV0FSL90kDLDqn6X3GAQqblzi65T8rjpHerLrUVUvVqjGebsaTzQol+v80h/eT9 ZFRhrtbg/9jPf7MOZKpbwOv6DnuFdT/o4pafMenzZOjxxJdtNj5+ou5jTm25cAfTKcEv MF4FcfsmrzBD8ayhsLF9TT8bWlLBoJqrOQejzg+RVJhU7puO7+v7Oh12FOGna2r306Q7 kBaPR79Gtr6Hr8HEFIhxO42VeqpSwt3ES4v0+sI5pEexYi1V8Wyp8O1M9Dz4Qb8sU6Cb 9hLLTXiyqnjJOehBSMDpZYDmjWHn2y+WVJBaiAFda+eFPVmFCy1k3WgFdjajJm4FRZ8w 8g1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=isRYn9lN6cEAqWClhe0WBzt/RxYyvB9g2enpJeYjAos=; b=yijReQPeHe9ZFhDOtbZiIabOr9aaGMPU0F8MlWYPDO4xTlh1jDSPW090PktUCB3Ifn fIeOVYwHEiREqBPWOW4E4J+Fdhmqrn6YVyezBa2FuiVGHaTdWfARNOPdRouaJn3LaE2/ YWH4mZSglMnHp3U5Gy/tDwH9Z7TksZvlp8IWkuzx0pB6TIZDcclmU29/BkN20C6z2yqj s8NadF4vzI7wBb2JS7rnE7m7ouhAUfzpwmYhfWzJ19bO9IVtMcIJ/oRcU1mkzBYXGxZK kRwLc+A9Wo8Vh772KImreJF1g4aaxZNiNDmaiw1JdUE2gJn+xJh5qQYSdN54/XwXyKDT zx5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S9susCoo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a63fa49000000b00524eef20da6si876483pgk.642.2023.05.23.10.13.32; Tue, 23 May 2023 10:13:47 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S9susCoo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237949AbjEWRGR (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 13:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237927AbjEWRGP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 13:06:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2AF8B5; Tue, 23 May 2023 10:06:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7F8F862542; Tue, 23 May 2023 17:06:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 466B5C433D2; Tue, 23 May 2023 17:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684861573; bh=O4HzR93cVyWgDZI2VtGL8GGS2znNViXwdOo0oYNScmQ=; h=From:To:Cc:Subject:Date:From; b=S9susCoorlA+c7uqs58+sjbap9DCpSH16D6qnZjnn4qMOmF9hDSX7WFNdJoytkDy+ TJAOF76W5AoLfrS0i5hCoGI/Dd1rke+vhNX0Nk8gJIVY0WlzZMymoTxgUTZfJl85+R KIyTvCf2J4alkJKeJs79j190Xw41NQJpUOQ0yA83g5p7kaFcPFUG4KbCXHat1zRwH5 nnh9lg91Ok6B44pGoWtSVRf2v4Qw4oA4czgifYOOZ6gzvb/r6dVwCe8j4qycsXvvj9 neJq4SboSHhxqkNBepoZNv0bgNBgHMVMkc5aFlw1OTddb4KX3ntcqTtic8rQ7HMZPr Sip+jFo6uxigg== From: Jisheng Zhang <jszhang@kernel.org> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Arnd Bergmann <arnd@arndb.de> Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH v2 0/4] riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Date: Wed, 24 May 2023 00:54:58 +0800 Message-Id: <20230523165502.2592-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766705885586457268?= X-GMAIL-MSGID: =?utf-8?q?1766705885586457268?= |
Series |
riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
|
|
Message
Jisheng Zhang
May 23, 2023, 4:54 p.m. UTC
When trying to run linux with various opensource riscv core on resource limited FPGA platforms, for example, those FPGAs with less than 16MB SDRAM, I want to save mem as much as possible. One of the major technologies is kernel size optimizations, I found that riscv does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which passes -fdata-sections, -ffunction-sections to CFLAGS and passes the --gc-sections flag to the linker. This not only benefits my case on FPGA but also benefits defconfigs. Here are some notable improvements from enabling this with defconfigs: nommu_k210_defconfig: text data bss dec hex 1112009 410288 59837 1582134 182436 before 962838 376656 51285 1390779 1538bb after rv32_defconfig: text data bss dec hex 8804455 2816544 290577 11911576 b5c198 before 8692295 2779872 288977 11761144 b375f8 after defconfig: text data bss dec hex 9438267 3391332 485333 13314932 cb2b74 before 9285914 3350052 483349 13119315 c82f53 after patch1 and patch2 are clean ups. patch3 fixes a typo. patch4 finally enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv. NOTE: Zhangjin Wu firstly sent out a patch to enable dead code elimination for riscv several months ago, I didn't notice it until yesterday. Although it missed some preparations and some sections's keeping, he is the first person to enable this feature for riscv. To ease merging, this series take his patch into my entire series and makes patch4 authored by him after getting his ack to reflect the above fact. Since v1: - collect Reviewed-by, Tested-by tag - Make patch4 authored by Zhangjin Wu, add my co-developed-by tag Jisheng Zhang (3): riscv: move options to keep entries sorted riscv: vmlinux-xip.lds.S: remove .alternative section vmlinux.lds.h: use correct .init.data.* section name Zhangjin Wu (1): riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION arch/riscv/Kconfig | 13 +- arch/riscv/kernel/vmlinux-xip.lds.S | 6 - arch/riscv/kernel/vmlinux.lds.S | 6 +- include/asm-generic/vmlinux.lds.h | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-)
Comments
On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: > When trying to run linux with various opensource riscv core on > resource limited FPGA platforms, for example, those FPGAs with less > than 16MB SDRAM, I want to save mem as much as possible. One of the > major technologies is kernel size optimizations, I found that riscv > does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which > passes -fdata-sections, -ffunction-sections to CFLAGS and passes the > --gc-sections flag to the linker. > > This not only benefits my case on FPGA but also benefits defconfigs. > Here are some notable improvements from enabling this with defconfigs: > > nommu_k210_defconfig: > text data bss dec hex > 1112009 410288 59837 1582134 182436 before > 962838 376656 51285 1390779 1538bb after > > rv32_defconfig: > text data bss dec hex > 8804455 2816544 290577 11911576 b5c198 before > 8692295 2779872 288977 11761144 b375f8 after > > defconfig: > text data bss dec hex > 9438267 3391332 485333 13314932 cb2b74 before > 9285914 3350052 483349 13119315 c82f53 after > > patch1 and patch2 are clean ups. > patch3 fixes a typo. > patch4 finally enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv. > > NOTE: Zhangjin Wu firstly sent out a patch to enable dead code > elimination for riscv several months ago, I didn't notice it until > yesterday. Although it missed some preparations and some sections's > keeping, he is the first person to enable this feature for riscv. To > ease merging, this series take his patch into my entire series and > makes patch4 authored by him after getting his ack to reflect > the above fact. > > Since v1: > - collect Reviewed-by, Tested-by tag > - Make patch4 authored by Zhangjin Wu, add my co-developed-by tag > > Jisheng Zhang (3): > riscv: move options to keep entries sorted > riscv: vmlinux-xip.lds.S: remove .alternative section > vmlinux.lds.h: use correct .init.data.* section name > > Zhangjin Wu (1): > riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION > > arch/riscv/Kconfig | 13 +- > arch/riscv/kernel/vmlinux-xip.lds.S | 6 - > arch/riscv/kernel/vmlinux.lds.S | 6 +- > include/asm-generic/vmlinux.lds.h | 2 +- > 4 files changed, 11 insertions(+), 16 deletions(-) Do you have a base commit for this? It's not applying to 6.4-rc1 and the patchwork bot couldn't find one either.
On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: > On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: > > When trying to run linux with various opensource riscv core on > > resource limited FPGA platforms, for example, those FPGAs with less > > than 16MB SDRAM, I want to save mem as much as possible. One of the > > major technologies is kernel size optimizations, I found that riscv > > does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which > > passes -fdata-sections, -ffunction-sections to CFLAGS and passes the > > --gc-sections flag to the linker. > > > > This not only benefits my case on FPGA but also benefits defconfigs. > > Here are some notable improvements from enabling this with defconfigs: > > > > nommu_k210_defconfig: > > text data bss dec hex > > 1112009 410288 59837 1582134 182436 before > > 962838 376656 51285 1390779 1538bb after > > > > rv32_defconfig: > > text data bss dec hex > > 8804455 2816544 290577 11911576 b5c198 before > > 8692295 2779872 288977 11761144 b375f8 after > > > > defconfig: > > text data bss dec hex > > 9438267 3391332 485333 13314932 cb2b74 before > > 9285914 3350052 483349 13119315 c82f53 after > > > > patch1 and patch2 are clean ups. > > patch3 fixes a typo. > > patch4 finally enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv. > > > > NOTE: Zhangjin Wu firstly sent out a patch to enable dead code > > elimination for riscv several months ago, I didn't notice it until > > yesterday. Although it missed some preparations and some sections's > > keeping, he is the first person to enable this feature for riscv. To > > ease merging, this series take his patch into my entire series and > > makes patch4 authored by him after getting his ack to reflect > > the above fact. > > > > Since v1: > > - collect Reviewed-by, Tested-by tag > > - Make patch4 authored by Zhangjin Wu, add my co-developed-by tag > > > > Jisheng Zhang (3): > > riscv: move options to keep entries sorted > > riscv: vmlinux-xip.lds.S: remove .alternative section > > vmlinux.lds.h: use correct .init.data.* section name > > > > Zhangjin Wu (1): > > riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION > > > > arch/riscv/Kconfig | 13 +- > > arch/riscv/kernel/vmlinux-xip.lds.S | 6 - > > arch/riscv/kernel/vmlinux.lds.S | 6 +- > > include/asm-generic/vmlinux.lds.h | 2 +- > > 4 files changed, 11 insertions(+), 16 deletions(-) > > Do you have a base commit for this? It's not applying to 6.4-rc1 and the > patchwork bot couldn't find one either. Hi Palmer, Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this series is based on 6.4-rc2. Thanks
On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: > > On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: >> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: >> > When trying to run linux with various opensource riscv core on >> > resource limited FPGA platforms, for example, those FPGAs with less >> > than 16MB SDRAM, I want to save mem as much as possible. One of the >> > major technologies is kernel size optimizations, I found that riscv >> > does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which >> > passes -fdata-sections, -ffunction-sections to CFLAGS and passes the >> > --gc-sections flag to the linker. >> > >> > This not only benefits my case on FPGA but also benefits defconfigs. >> > Here are some notable improvements from enabling this with defconfigs: >> > >> > nommu_k210_defconfig: >> > text data bss dec hex >> > 1112009 410288 59837 1582134 182436 before >> > 962838 376656 51285 1390779 1538bb after >> > >> > rv32_defconfig: >> > text data bss dec hex >> > 8804455 2816544 290577 11911576 b5c198 before >> > 8692295 2779872 288977 11761144 b375f8 after >> > >> > defconfig: >> > text data bss dec hex >> > 9438267 3391332 485333 13314932 cb2b74 before >> > 9285914 3350052 483349 13119315 c82f53 after >> > >> > patch1 and patch2 are clean ups. >> > patch3 fixes a typo. >> > patch4 finally enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv. >> > >> > NOTE: Zhangjin Wu firstly sent out a patch to enable dead code >> > elimination for riscv several months ago, I didn't notice it until >> > yesterday. Although it missed some preparations and some sections's >> > keeping, he is the first person to enable this feature for riscv. To >> > ease merging, this series take his patch into my entire series and >> > makes patch4 authored by him after getting his ack to reflect >> > the above fact. >> > >> > Since v1: >> > - collect Reviewed-by, Tested-by tag >> > - Make patch4 authored by Zhangjin Wu, add my co-developed-by tag >> > >> > Jisheng Zhang (3): >> > riscv: move options to keep entries sorted >> > riscv: vmlinux-xip.lds.S: remove .alternative section >> > vmlinux.lds.h: use correct .init.data.* section name >> > >> > Zhangjin Wu (1): >> > riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION >> > >> > arch/riscv/Kconfig | 13 +- >> > arch/riscv/kernel/vmlinux-xip.lds.S | 6 - >> > arch/riscv/kernel/vmlinux.lds.S | 6 +- >> > include/asm-generic/vmlinux.lds.h | 2 +- >> > 4 files changed, 11 insertions(+), 16 deletions(-) >> >> Do you have a base commit for this? It's not applying to 6.4-rc1 and the >> patchwork bot couldn't find one either. > > Hi Palmer, > > Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by > kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this > series is based on 6.4-rc2. Thanks. > > Thanks
On Thu, 15 Jun 2023 06:54:33 PDT (-0700), Palmer Dabbelt wrote: > On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: >> >> On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: >>> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: >>> > When trying to run linux with various opensource riscv core on >>> > resource limited FPGA platforms, for example, those FPGAs with less >>> > than 16MB SDRAM, I want to save mem as much as possible. One of the >>> > major technologies is kernel size optimizations, I found that riscv >>> > does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which >>> > passes -fdata-sections, -ffunction-sections to CFLAGS and passes the >>> > --gc-sections flag to the linker. >>> > >>> > This not only benefits my case on FPGA but also benefits defconfigs. >>> > Here are some notable improvements from enabling this with defconfigs: >>> > >>> > nommu_k210_defconfig: >>> > text data bss dec hex >>> > 1112009 410288 59837 1582134 182436 before >>> > 962838 376656 51285 1390779 1538bb after >>> > >>> > rv32_defconfig: >>> > text data bss dec hex >>> > 8804455 2816544 290577 11911576 b5c198 before >>> > 8692295 2779872 288977 11761144 b375f8 after >>> > >>> > defconfig: >>> > text data bss dec hex >>> > 9438267 3391332 485333 13314932 cb2b74 before >>> > 9285914 3350052 483349 13119315 c82f53 after >>> > >>> > patch1 and patch2 are clean ups. >>> > patch3 fixes a typo. >>> > patch4 finally enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv. >>> > >>> > NOTE: Zhangjin Wu firstly sent out a patch to enable dead code >>> > elimination for riscv several months ago, I didn't notice it until >>> > yesterday. Although it missed some preparations and some sections's >>> > keeping, he is the first person to enable this feature for riscv. To >>> > ease merging, this series take his patch into my entire series and >>> > makes patch4 authored by him after getting his ack to reflect >>> > the above fact. >>> > >>> > Since v1: >>> > - collect Reviewed-by, Tested-by tag >>> > - Make patch4 authored by Zhangjin Wu, add my co-developed-by tag >>> > >>> > Jisheng Zhang (3): >>> > riscv: move options to keep entries sorted >>> > riscv: vmlinux-xip.lds.S: remove .alternative section >>> > vmlinux.lds.h: use correct .init.data.* section name >>> > >>> > Zhangjin Wu (1): >>> > riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION >>> > >>> > arch/riscv/Kconfig | 13 +- >>> > arch/riscv/kernel/vmlinux-xip.lds.S | 6 - >>> > arch/riscv/kernel/vmlinux.lds.S | 6 +- >>> > include/asm-generic/vmlinux.lds.h | 2 +- >>> > 4 files changed, 11 insertions(+), 16 deletions(-) >>> >>> Do you have a base commit for this? It's not applying to 6.4-rc1 and the >>> patchwork bot couldn't find one either. >> >> Hi Palmer, >> >> Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by >> kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this >> series is based on 6.4-rc2. > > Thanks. Sorry to be so slow here, but I think this is causing LLD to hang on allmodconfig. I'm still getting to the bottom of it, there's a few other things I have in flight still. > >> >> Thanks
On Mon, Jun 19, 2023 at 6:06 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > > On Thu, 15 Jun 2023 06:54:33 PDT (-0700), Palmer Dabbelt wrote: > > On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: > >> > >> On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: > >>> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: > >>> > When trying to run linux with various opensource riscv core on > >>> > resource limited FPGA platforms, for example, those FPGAs with less > >>> > than 16MB SDRAM, I want to save mem as much as possible. One of the > >>> > major technologies is kernel size optimizations, I found that riscv > >>> > does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which > >>> > passes -fdata-sections, -ffunction-sections to CFLAGS and passes the > >>> > --gc-sections flag to the linker. > >>> > > >>> > This not only benefits my case on FPGA but also benefits defconfigs. > >>> > Here are some notable improvements from enabling this with defconfigs: > >>> > > >>> > nommu_k210_defconfig: > >>> > text data bss dec hex > >>> > 1112009 410288 59837 1582134 182436 before > >>> > 962838 376656 51285 1390779 1538bb after > >>> > > >>> > rv32_defconfig: > >>> > text data bss dec hex > >>> > 8804455 2816544 290577 11911576 b5c198 before > >>> > 8692295 2779872 288977 11761144 b375f8 after > >>> > > >>> > defconfig: > >>> > text data bss dec hex > >>> > 9438267 3391332 485333 13314932 cb2b74 before > >>> > 9285914 3350052 483349 13119315 c82f53 after > >>> > > >>> > patch1 and patch2 are clean ups. > >>> > patch3 fixes a typo. > >>> > patch4 finally enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv. > >>> > > >>> > NOTE: Zhangjin Wu firstly sent out a patch to enable dead code > >>> > elimination for riscv several months ago, I didn't notice it until > >>> > yesterday. Although it missed some preparations and some sections's > >>> > keeping, he is the first person to enable this feature for riscv. To > >>> > ease merging, this series take his patch into my entire series and > >>> > makes patch4 authored by him after getting his ack to reflect > >>> > the above fact. > >>> > > >>> > Since v1: > >>> > - collect Reviewed-by, Tested-by tag > >>> > - Make patch4 authored by Zhangjin Wu, add my co-developed-by tag > >>> > > >>> > Jisheng Zhang (3): > >>> > riscv: move options to keep entries sorted > >>> > riscv: vmlinux-xip.lds.S: remove .alternative section > >>> > vmlinux.lds.h: use correct .init.data.* section name > >>> > > >>> > Zhangjin Wu (1): > >>> > riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION > >>> > > >>> > arch/riscv/Kconfig | 13 +- > >>> > arch/riscv/kernel/vmlinux-xip.lds.S | 6 - > >>> > arch/riscv/kernel/vmlinux.lds.S | 6 +- > >>> > include/asm-generic/vmlinux.lds.h | 2 +- > >>> > 4 files changed, 11 insertions(+), 16 deletions(-) > >>> > >>> Do you have a base commit for this? It's not applying to 6.4-rc1 and the > >>> patchwork bot couldn't find one either. > >> > >> Hi Palmer, > >> > >> Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by > >> kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this > >> series is based on 6.4-rc2. > > > > Thanks. > > Sorry to be so slow here, but I think this is causing LLD to hang on > allmodconfig. I'm still getting to the bottom of it, there's a few > other things I have in flight still. Confirmed with v3 on mainline (linux-next is pretty red at the moment). https://lore.kernel.org/linux-riscv/20230517082936.37563-1-falcon@tinylab.org/ I was able to dump a backtrace of all of LLD's threads and all threads seemed parked in a futex wait except for one thread with a more interesting trace. 0x0000555557ea01ce in lld::elf::LinkerScript::addOrphanSections()::$_0::operator()(lld::elf::InputSectionBase*) const () (gdb) bt #0 0x0000555557ea01ce in lld::elf::LinkerScript::addOrphanSections()::$_0::operator()(lld::elf::InputSectionBase*) const () #1 0x0000555557e9fc3f in lld::elf::LinkerScript::addOrphanSections() () #2 0x0000555557dd0ca1 in lld::elf::LinkerDriver::link(llvm::opt::InputArgList&) () #3 0x0000555557dc19a8 in lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) () #4 0x0000555557dbfff9 in lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) () #5 0x0000555557c3ffcf in lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) () #6 0x0000555557c3f7aa in lld_main(int, char**, llvm::ToolContext const&) () #7 0x0000555557c41ee1 in main () Makes me wonder if there's some kind of loop adding orphan sections that aren't referenced, so they're cleaned up. Though I don't think it's a hang; IIRC dead code elimination adds a measurable amount of time to the build. As code is unreferenced and removed, I think the linker is reshuffling layout and thus recomputing relocations. Though triple checking mainline without this patch vs mainline with this patch, twice now I just got an error from LLD (in 2 minutes on my system): ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(efi-stub-entry.stub.o):(.init.bss.screen_info_offset) is being placed in '.init.bss.screen_info_offset' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(efi-stub-helper.stub.o):(.init.data.efi_nokaslr) is being placed in '.init.data.efi_nokaslr' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(efi-stub-helper.stub.o):(.init.bss.efi_noinitrd) is being placed in '.init.bss.efi_noinitrd' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(efi-stub-helper.stub.o):(.init.bss.efi_nochunk) is being placed in '.init.bss.efi_nochunk' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(efi-stub-helper.stub.o):(.init.bss.efi_novamap) is being placed in '.init.bss.efi_novamap' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(efi-stub-helper.stub.o):(.init.bss.efi_disable_pci_dma) is being placed in '.init.bss.efi_disable_pci_dma' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(file.stub.o):(.init.bss.efi_open_device_path.text_to_dp) is being placed in '.init.bss.efi_open_device_path.text_to_dp' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(gop.stub.o):(.init.bss.cmdline.0) is being placed in '.init.bss.cmdline.0' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(gop.stub.o):(.init.bss.cmdline.1) is being placed in '.init.bss.cmdline.1' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(gop.stub.o):(.init.bss.cmdline.2) is being placed in '.init.bss.cmdline.2' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(gop.stub.o):(.init.bss.cmdline.3) is being placed in '.init.bss.cmdline.3' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(gop.stub.o):(.init.bss.cmdline.4) is being placed in '.init.bss.cmdline.4' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(printk.stub.o):(.init.data.efi_loglevel) is being placed in '.init.data.efi_loglevel' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(riscv.stub.o):(.init.bss.hartid) is being placed in '.init.bss.hartid' ld.lld: error: ./drivers/firmware/efi/libstub/lib.a(systable.stub.o):(.init.bss.efi_system_table) is being placed in '.init.bss.efi_system_table' is it perhaps that these sections need placement in the linker script? This is from the orphan section warn linker command line flag. Does the EFI stub have one linker script, or one per arch? (Or am I mistaken and the EFI stub is part of vmlinux)? > > > > >> > >> Thanks >
On Tue, Jun 20, 2023 at 04:05:55PM -0400, Nick Desaulniers wrote: > On Mon, Jun 19, 2023 at 6:06 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > > On Thu, 15 Jun 2023 06:54:33 PDT (-0700), Palmer Dabbelt wrote: > > > On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: > > >> On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: > > >>> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: > > >> Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by > > >> kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this > > >> series is based on 6.4-rc2. > > > > > > Thanks. > > > > Sorry to be so slow here, but I think this is causing LLD to hang on > > allmodconfig. I'm still getting to the bottom of it, there's a few > > other things I have in flight still. > > Confirmed with v3 on mainline (linux-next is pretty red at the moment). > https://lore.kernel.org/linux-riscv/20230517082936.37563-1-falcon@tinylab.org/ Just FYI Nick, there's been some concurrent work here from different people working on the same thing & the v3 you linked (from Zhangjin) was superseded by this v2 (from Jisheng). Cheers, Conor.
On Tue, Jun 20, 2023 at 4:13 PM Conor Dooley <conor@kernel.org> wrote: > > On Tue, Jun 20, 2023 at 04:05:55PM -0400, Nick Desaulniers wrote: > > On Mon, Jun 19, 2023 at 6:06 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > > > On Thu, 15 Jun 2023 06:54:33 PDT (-0700), Palmer Dabbelt wrote: > > > > On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: > > > >> On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: > > > >>> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: > > > > >> Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by > > > >> kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this > > > >> series is based on 6.4-rc2. > > > > > > > > Thanks. > > > > > > Sorry to be so slow here, but I think this is causing LLD to hang on > > > allmodconfig. I'm still getting to the bottom of it, there's a few > > > other things I have in flight still. > > > > Confirmed with v3 on mainline (linux-next is pretty red at the moment). > > https://lore.kernel.org/linux-riscv/20230517082936.37563-1-falcon@tinylab.org/ > > Just FYI Nick, there's been some concurrent work here from different > people working on the same thing & the v3 you linked (from Zhangjin) was > superseded by this v2 (from Jisheng). Ah! I've been testing the deprecated patch set, sorry I just looked on lore for "dead code" on riscv-linux and grabbed the first thread, without noticing the difference in authors or new version numbers for distinct series. ok, nevermind my noise. I'll follow up with the correct patch set, sorry! > > Cheers, > Conor.
On Tue, 20 Jun 2023 13:32:32 PDT (-0700), ndesaulniers@google.com wrote: > On Tue, Jun 20, 2023 at 4:13 PM Conor Dooley <conor@kernel.org> wrote: >> >> On Tue, Jun 20, 2023 at 04:05:55PM -0400, Nick Desaulniers wrote: >> > On Mon, Jun 19, 2023 at 6:06 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: >> > > On Thu, 15 Jun 2023 06:54:33 PDT (-0700), Palmer Dabbelt wrote: >> > > > On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: >> > > >> On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: >> > > >>> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: >> >> > > >> Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by >> > > >> kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this >> > > >> series is based on 6.4-rc2. >> > > > >> > > > Thanks. >> > > >> > > Sorry to be so slow here, but I think this is causing LLD to hang on >> > > allmodconfig. I'm still getting to the bottom of it, there's a few >> > > other things I have in flight still. >> > >> > Confirmed with v3 on mainline (linux-next is pretty red at the moment). >> > https://lore.kernel.org/linux-riscv/20230517082936.37563-1-falcon@tinylab.org/ >> >> Just FYI Nick, there's been some concurrent work here from different >> people working on the same thing & the v3 you linked (from Zhangjin) was >> superseded by this v2 (from Jisheng). > > Ah! I've been testing the deprecated patch set, sorry I just looked on > lore for "dead code" on riscv-linux and grabbed the first thread, > without noticing the difference in authors or new version numbers for > distinct series. ok, nevermind my noise. I'll follow up with the > correct patch set, sorry! Ya, I hadn't even noticed the v3 because I pretty much only look at patchwork these days. Like we talked about in IRC, I'm going to go test the merge of this one and see what's up -- I've got it staged at <https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git/commit/?h=for-next&id=1bd2963b21758a773206a1cb67c93e7a8ae8a195>, though that won't be a stable hash if it's actually broken... > >> >> Cheers, >> Conor. > > > > -- > Thanks, > ~Nick Desaulniers
On Tue, Jun 20, 2023 at 4:41 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > > On Tue, 20 Jun 2023 13:32:32 PDT (-0700), ndesaulniers@google.com wrote: > > On Tue, Jun 20, 2023 at 4:13 PM Conor Dooley <conor@kernel.org> wrote: > >> > >> On Tue, Jun 20, 2023 at 04:05:55PM -0400, Nick Desaulniers wrote: > >> > On Mon, Jun 19, 2023 at 6:06 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > >> > > On Thu, 15 Jun 2023 06:54:33 PDT (-0700), Palmer Dabbelt wrote: > >> > > > On Wed, 14 Jun 2023 09:25:49 PDT (-0700), jszhang@kernel.org wrote: > >> > > >> On Wed, Jun 14, 2023 at 07:49:17AM -0700, Palmer Dabbelt wrote: > >> > > >>> On Tue, 23 May 2023 09:54:58 PDT (-0700), jszhang@kernel.org wrote: > >> > >> > > >> Commit 3b90b09af5be ("riscv: Fix orphan section warnings caused by > >> > > >> kernel/pi") touches vmlinux.lds.S, so to make the merge easy, this > >> > > >> series is based on 6.4-rc2. > >> > > > > >> > > > Thanks. > >> > > > >> > > Sorry to be so slow here, but I think this is causing LLD to hang on > >> > > allmodconfig. I'm still getting to the bottom of it, there's a few > >> > > other things I have in flight still. > >> > > >> > Confirmed with v3 on mainline (linux-next is pretty red at the moment). > >> > https://lore.kernel.org/linux-riscv/20230517082936.37563-1-falcon@tinylab.org/ > >> > >> Just FYI Nick, there's been some concurrent work here from different > >> people working on the same thing & the v3 you linked (from Zhangjin) was > >> superseded by this v2 (from Jisheng). > > > > Ah! I've been testing the deprecated patch set, sorry I just looked on > > lore for "dead code" on riscv-linux and grabbed the first thread, > > without noticing the difference in authors or new version numbers for > > distinct series. ok, nevermind my noise. I'll follow up with the > > correct patch set, sorry! > > Ya, I hadn't even noticed the v3 because I pretty much only look at > patchwork these days. Like we talked about in IRC, I'm going to go test > the merge of this one and see what's up -- I've got it staged at > <https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git/commit/?h=for-next&id=1bd2963b21758a773206a1cb67c93e7a8ae8a195>, > though that won't be a stable hash if it's actually broken... Ok, https://lore.kernel.org/linux-riscv/20230523165502.2592-1-jszhang@kernel.org/ built for me. If you're seeing a hang, please let me know what version of LLD you're using and I'll build that tag from source to see if I can reproduce, then bisect if so. $ ARCH=riscv LLVM=1 /usr/bin/time -v make -j128 allmodconfig vmlinux ... Elapsed (wall clock) time (h:mm:ss or m:ss): 2:35.68 ... Tested-by: Nick Desaulniers <ndesaulniers@google.com> # build > > > > >> > >> Cheers, > >> Conor. > > > > > > > > -- > > Thanks, > > ~Nick Desaulniers