mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Zhangjin Wu" <falcon@tinylab.org>
Cc: linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org,
	linux-riscv@lists.infradead.org, "Tim Bird" <tim.bird@sony.com>
Subject: Re: [PATCH v1 6/7] DCE/DSE: riscv: add HAVE_TRIM_UNUSED_SYSCALLS support
Date: Sat, 07 Oct 2023 22:43:06 +0200	[thread overview]
Message-ID: <c289bdb9-a1ec-4929-9ebf-1713a0b38e33@app.fastmail.com> (raw)
In-Reply-To: <20231007132935.6276-1-falcon@tinylab.org>

On Sat, Oct 7, 2023, at 15:29, Zhangjin Wu wrote:
>> On Tue, Sep 26, 2023, at 00:42, Zhangjin Wu wrote:
>> > For HAVE_TRIM_UNUSED_SYSCALLS, the syscall tables are hacked with the
>> > inputing unused_syscalls.
>> >
>> > Firstly, the intermediate preprocessed .i files are generated from the
>> > original C version of syscall tables respectively, and named with a
>> > 'used' suffix: syscall_table_used.i, compat_syscall_table_used.i.
>> >
>> > Secondly, all of the unused syscalls are commented.
>> >
>> > At last, two new objective files sufixed with 'used' are generated from
>> > the hacked .i files and they are linked into the eventual kernel image.
>> >
>> > Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
>> 
>> As mentioned in my comment on the mips patch, hacking the preprocessed
>> file here is too much strain on the old infrastructure, the
>> asm-generic/unistd.h file is already too hard to understand for
>> anyone and in need of an overhaul, so let's work together on fixing
>> it up first.
>>
>
> Ok, I was thinking about using asm/syscall_table.h instead of 
> asm/unistd.h like mips.
>
>     void * const sys_call_table[NR_syscalls] = {
>     	[0 ... NR_syscalls - 1] = __riscv_sys_ni_syscall,
>     #include <asm/syscall_table.h>
>     };
>
> Therefore, we can generate syscall_table.h from asm/unist.h with a tool 
> like scripts/syscallused.sh
>
> Another solution may be firstly generate a list of `#define __USED_NR_##call 1`
> for the used syscalls from Kconfig symbol, and then change __SYSCALL() macro
> to:
>
>    #define __SYSCALL(nr, call)     [nr] = 
> __is_defined(__USED_NR_##call) ? __riscv_##call : 
> __riscv_sys_ni_syscall,
>
> `include/linux/kconfig.h` defined the '__is_defined'.
>
> This method may work for the archs with .tbl files too.

Right, either way would be much better than than your first
approach. For the mips version (and all the other
traditional architectures that use the syscall.tbl method)
I think I'd integrate the filtering in scripts/syscalltbl.sh
if we decide to go that way. For the riscv version
(and all the others using asm-generic/unistd.h), the
__USED_NR_## macro would be fine as an intermediate
step, until we manage to convert those to syscall.tbl
parsing.

On the other hand, based on the earlier findings, my
overall feeling is that we're better off not adding
the extra indirection at all, but instead add the
more Kconfig symbols to control the largest groups
of syscalls, with the hope of conditionally removing
additional code for each of these symbols beyond the
automatic gc-section logic.

      Arnd

  reply	other threads:[~2023-10-07 20:43 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
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 [this message]
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=c289bdb9-a1ec-4929-9ebf-1713a0b38e33@app.fastmail.com \
    --to=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=tim.bird@sony.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

all inboxes | Powered by JetHome®