mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yuan Tan <tanyuan@tinylab.org>
To: falcon@tinylab.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux@weissschuh.net, palmer@rivosinc.com,
	paul.walmsley@sifive.com, paulburton@kernel.org,
	paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de,
	w@1wt.eu
Subject: Re: [PATCH v1 2/7] DCE/DSE: add unused syscalls elimination configure support
Date: Sat,  7 Oct 2023 18:01:39 +0800	[thread overview]
Message-ID: <20231007100139.3501-1-tanyuan@tinylab.org> (raw)
In-Reply-To: <3f0eaf5fcb19f1c70cab075a97f067846f36f736.1695679700.git.falcon@tinylab.org>

Hi Zhangjin,
 
> A minimal embedded Linux system may only has a very few of functions and
> only uses a minimal subset of the posix syscalls, the unused syscalls
> will never be used and eventually in a dead status, that also means disk
> storage and memory footprint waste.
> 
> Based on dead code elimination support, it is able to further eliminate
> the above dead or unused syscalls.
> 
> Firstly, both a new common CONFIG_TRIM_UNUSED_SYSCALLS option and a new
> architecture specific HAVE_TRIM_UNUSED_SYSCALLS are added to enable or
> disable such feature.
> 
> Secondly, a new CONFIG_USED_SYSCALLS option is added to allow configure
> the syscalls used in a target system. CONFIG_USED_SYSCALLS can be a list
> of the used syscalls or a file to store such a list.
> 
> Based on the above options, it is able to only reserve the used syscalls
> and let CONFIG_LD_DEAD_CODE_DATA_ELIMINATION trim the unused ones for us
> automatically.
> 
> Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> ---
>  init/Kconfig | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/init/Kconfig b/init/Kconfig
> index 4350d8ba7db4..aa648ce8bca1 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1457,6 +1457,11 @@ config BPF
>  	bool
>  	select CRYPTO_LIB_SHA1
>  
> +config HAVE_TRIM_UNUSED_SYSCALLS
> +	bool
> +	depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> +	default n
> +
>  menuconfig EXPERT
>  	bool "Configure standard kernel features (expert users)"
>  	# Unhide debug options, to make the on-by-default options visible
> @@ -1683,6 +1688,43 @@ config MEMBARRIER
>  
>  	  If unsure, say Y.
>  
> +config TRIM_UNUSED_SYSCALLS
> +	bool "Trim unused syscalls (EXPERIMENTAL)" if EXPERT
> +	default n
> +	depends on HAVE_TRIM_UNUSED_SYSCALLS
> +	depends on HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> +	select LD_DEAD_CODE_DATA_ELIMINATION
> +	help
> +	  Say Y here to trim all of the unused syscalls for a target system.

I think changing this sentence to "Say Y here to trim all of the unused
syscalls, excluding those defined in USED_SYSCALLS." would be clearer.

By the way, consider adding the three files syscall_table_used.c,
compat_syscall_table_used.c, and traps_used.c to the .gitignore file.

> +
> +	  Note, this is only for minimal embedded systems, please don't use it
> +	  for generic Linux distributions.
> +
> +	  If unsure, say N.
> +
> +config USED_SYSCALLS
> +	string "Configure used syscalls (EXPERIMENTAL)" if EXPERT
> +	depends on TRIM_UNUSED_SYSCALLS
> +	default ""
> +	help
> +	  This option allows to configure the syscalls used in a target system,
> +	  the unused ones will be disabled and trimmed by TRIM_UNUSED_SYSCALLS.
> +
> +	  The used syscalls should be listed one by one like this:
> +
> +	      write exit reboot
> +
> +	  Or put them into a file specified by this option, one syscall per
> +	  line is recommended for such a config file:
> +
> +	      write
> +	      exit
> +	      reboot
> +
> +	  Note, If keep this empty, all of the syscalls will be trimmed.
> +
> +	  If unsure, please disable TRIM_UNUSED_SYSCALLS.
> +
>  config KALLSYMS
>  	bool "Load all symbols for debugging/ksymoops" if EXPERT
>  	default y
> -- 

  reply	other threads:[~2023-10-07 10:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25 22:33 [PATCH v1 0/7] DCE/DSE: Add Dead Syscalls Elimination support, part1 Zhangjin Wu
2023-09-25 22:35 ` [PATCH v1 1/7] DCE: add debug support Zhangjin Wu
2023-09-25 22:36 ` [PATCH v1 2/7] DCE/DSE: add unused syscalls elimination configure support Zhangjin Wu
2023-10-07 10:01   ` Yuan Tan [this message]
2023-09-25 22:38 ` [PATCH v1 3/7] DCE/DSE: Add a new scripts/Makefile.syscalls Zhangjin Wu
2023-09-26  5:55   ` Arnd Bergmann
2023-09-25 22:40 ` [PATCH v1 4/7] DCE/DSE: mips: add HAVE_TRIM_UNUSED_SYSCALLS support Zhangjin Wu
2023-09-26  6:07   ` Arnd Bergmann
2023-10-07 12:58     ` Zhangjin Wu
2023-09-25 22:41 ` [PATCH v1 5/7] DCE/DSE: riscv: move syscall tables to syscalls/ Zhangjin Wu
2023-09-25 22:42 ` [PATCH v1 6/7] DCE/DSE: riscv: add HAVE_TRIM_UNUSED_SYSCALLS support Zhangjin Wu
2023-09-26  6:10   ` Arnd Bergmann
2023-10-07 13:29     ` Zhangjin Wu
2023-10-07 20:43       ` Arnd Bergmann
2023-09-25 22:43 ` [PATCH v1 7/7] DCE/DSE: riscv: trim syscall tables Zhangjin Wu
2023-09-26  6:01   ` Arnd Bergmann
2023-10-07 13:35     ` Zhangjin Wu
2023-09-26  7:14 ` [PATCH v1 0/7] DCE/DSE: Add Dead Syscalls Elimination support, part1 Arnd Bergmann
2023-09-26 11:24   ` Arnd Bergmann
2023-09-26 14:07     ` Arnd Bergmann
2023-09-26 20:49     ` Nicolas Pitre
2023-09-27 10:21       ` Arnd Bergmann
2023-09-30  9:31 ` Yuan Tan
2023-10-03 16:43 ` Yuan Tan

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=20231007100139.3501-1-tanyuan@tinylab.org \
    --to=tanyuan@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@weissschuh.net \
    --cc=palmer@rivosinc.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulburton@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=tim.bird@sony.com \
    --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

all inboxes | Powered by JetHome®