linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
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 0/4] riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
Date: Thu, 11 May 2023 22:12:07 +0800	[thread overview]
Message-ID: <20230511141211.2418-1-jszhang@kernel.org> (raw)

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.

Jisheng Zhang (4):
  riscv: vmlinux-xip.lds.S: remove .alternative section
  riscv: move HAVE_RETHOOK to keep entries sorted
  riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
  vmlinux.lds.h: use correct .init.data.* section name

 arch/riscv/Kconfig                  | 3 ++-
 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, 6 insertions(+), 11 deletions(-)

-- 
2.40.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2023-05-11 14:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 14:12 Jisheng Zhang [this message]
2023-05-11 14:12 ` [PATCH 1/4] riscv: vmlinux-xip.lds.S: remove .alternative section Jisheng Zhang
2023-05-12 13:51   ` Conor Dooley
2023-05-12 15:36     ` Jisheng Zhang
2023-05-11 14:12 ` [PATCH 2/4] riscv: move HAVE_RETHOOK to keep entries sorted Jisheng Zhang
2023-05-12 13:54   ` Conor Dooley
2023-05-11 14:12 ` [PATCH 3/4] vmlinux.lds.h: use correct .init.data.* section name Jisheng Zhang
2023-06-01  4:58   ` Guo Ren
2023-05-11 14:12 ` [PATCH 4/4] riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Jisheng Zhang
2023-05-12 13:58   ` Conor Dooley
2023-05-12 15:16     ` Conor Dooley
2023-05-12 15:39       ` Jisheng Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230511141211.2418-1-jszhang@kernel.org \
    --to=jszhang@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).