linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Palmer Dabbelt <palmer@rivosinc.com>, Willy Tarreau <w@1wt.eu>,
	Paul Burton <paulburton@kernel.org>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Nicholas Mc Guire <hofrat@osadl.org>,
	Zhangjin Wu <falcon@tinylab.org>
Subject: [RFC PATCH 0/5] Add dead syscalls elimination support
Date: Fri, 17 Feb 2023 08:49:20 +0800	[thread overview]
Message-ID: <cover.1676594211.git.falcon@tinylab.org> (raw)

Hi, all

CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION allows to eliminate dead code
and data, this patchset allows to further eliminate dead syscalls which
are not used in target system.

It includes 5 patches:

- syscall: Allow configure used system calls

  This adds a new CONFIG_SYSCALLS_USED option to allow users or tools to
  tell kernel what syscalls are used in target system. A list of
  used syscalls can be passed to it.

- MIPS: Add dead syscalls elimination support

  Add CONFIG_SYSCALLS_USED support for mips, it simply adds a 'used'
  variant for the syscall*.tbl and accordingly updates the kernel apis
  and eventually the sys_call_table. The unused ones in the table are
  replaced by sys_ni_syscall and therefore if they are also not used by
  kernel itself, they will be eliminated by gc-sections.

  The old architectures use syscall*.tbl, so, they can use this method.

- RISC-V: Enable dead code elimination

  Select HAVE_LD_DEAD_CODE_DATA_ELIMINATION for riscv.

- RISC-V: Add dead syscalls elimination support

  Add CONFIG_SYSCALLS_USED support for riscv, it simply adds a 'used'
  variant for the *syscall_table.c and eventually the sys_call_table.

  The new architectures use generic unistd.h, they can use this method.

- nolibc: Record used syscalls in their own sections

  This allows to record syscalls used by a nolibc based application. It
  is possible to eliminate dead syscalls automatically while building
  the monolithic kernel+nolibc software.

Testing shows, on both mips and riscv, with a small config, gc-sections
shrinks ~10% and syscalls_used shrinks another ~5%.

This patchset is only a prototype implementation, welcome your feedback
and suggestion, Thanks.

Related emails:

- Re: Re: Kernel-only deployments
  https://lore.kernel.org/lkml/20230216130935.37976-1-falcon@tinylab.org/

- Re: Re: RISC-V: Enable dead code elimination
  https://lore.kernel.org/linux-riscv/Y+qSBu3YZH0JPY4I@spud/T/#t

Best Regards,
- Zhangjin Wu

---

Zhangjin Wu (5):
  syscall: Allow configure used system calls
  MIPS: Add dead syscalls elimination support
  RISC-V: Enable dead code elimination
  RISC-V: Add dead syscalls elimination support
  nolibc: Record used syscalls in their own sections

 arch/mips/Kconfig                   |  1 +
 arch/mips/kernel/syscalls/Makefile  | 24 ++++++++-
 arch/riscv/Kconfig                  |  2 +
 arch/riscv/kernel/Makefile          |  5 +-
 arch/riscv/kernel/syscalls/Makefile | 38 ++++++++++++++
 arch/riscv/kernel/vmlinux.lds.S     |  2 +-
 init/Kconfig                        | 22 +++++++++
 tools/include/nolibc/Makefile       |  2 +-
 tools/include/nolibc/arch-aarch64.h | 17 ++++---
 tools/include/nolibc/arch-arm.h     | 15 +++---
 tools/include/nolibc/arch-i386.h    | 17 ++++---
 tools/include/nolibc/arch-mips.h    | 15 +++---
 tools/include/nolibc/arch-riscv.h   | 17 ++++---
 tools/include/nolibc/arch-x86_64.h  | 17 ++++---
 tools/include/nolibc/arch.h         |  2 +
 tools/include/nolibc/record.h       | 77 +++++++++++++++++++++++++++++
 16 files changed, 226 insertions(+), 47 deletions(-)
 create mode 100644 arch/riscv/kernel/syscalls/Makefile
 create mode 100644 tools/include/nolibc/record.h

-- 
2.25.1


             reply	other threads:[~2023-02-17  0:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17  0:49 Zhangjin Wu [this message]
2023-02-17  0:49 ` [RFC PATCH 1/5] syscall: Allow configure used system calls Zhangjin Wu
2023-02-17  0:49 ` [RFC PATCH 2/5] MIPS: Add dead syscalls elimination support Zhangjin Wu
2023-02-17  0:49 ` [RFC PATCH 3/5] RISC-V: Enable dead code elimination Zhangjin Wu
2023-02-17  0:49 ` [RFC PATCH 4/5] RISC-V: Add dead syscalls elimination support Zhangjin Wu
2023-02-17  0:49 ` [RFC PATCH 5/5] nolibc: Record used syscalls in their own sections Zhangjin Wu

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=cover.1676594211.git.falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=hofrat@osadl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulburton@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=w@1wt.eu \
    /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).