Re: [PATCH] x86/syscalls: shrink entry/syscall_32.i via IWYU

From: Tanzir Hasan
Date: Wed Dec 27 2023 - 19:18:21 EST


On Wed, Dec 27, 2023 at 3:34 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Dec 27, 2023 at 10:38:41PM +0000, Tanzir Hasan wrote:
> > This diff uses an open source tool include-what-you-use (IWYU) to modify
> > the include list, changing indirect includes to direct includes. IWYU is
> > implemented using the IWYUScripts github repository which is a tool that
> > is currently undergoing development. These changes seek to improve build
> > times.
> >
> > This change to entry/syscall_32.c resulted in a preprocessed size of
> > entry/syscall_32.i from 64002 lines to 47986 lines (-25%) for the x86
> > defconfig.
> >
> > Signed-off-by: Tanzir Hasan <tanzirh@xxxxxxxxxx>
> > ---
> > arch/x86/entry/syscall_32.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/entry/syscall_32.c b/arch/x86/entry/syscall_32.c
> > index 8cfc9bc73e7f..66db11fe8a1c 100644
> > --- a/arch/x86/entry/syscall_32.c
> > +++ b/arch/x86/entry/syscall_32.c
> > @@ -4,7 +4,7 @@
> > #include <linux/linkage.h>
> > #include <linux/sys.h>
> > #include <linux/cache.h>
> > -#include <linux/syscalls.h>
> > +#include <linux/ptrace.h>
> > #include <asm/syscall.h>
>
> Really? What do we need linux/ptrace.h for? Because if it's
> struct pt_regs for the generated externs, we might as well have
> just said
> struct pt_regs;
> and that would be it.
>
> <digs around a bit>
>
> As the matter of fact, all you need out of those includes is this:
>
> struct pt_regs;
> typedef long (*sys_call_ptr_t)(const struct pt_regs *);
> extern const sys_call_ptr_t sys_call_table[];
> #if defined(CONFIG_X86_32)
> #define ia32_sys_call_table sys_call_table
> #else
> /*
> * These may not exist, but still put the prototypes in so we
> * can use IS_ENABLED().
> */
> extern const sys_call_ptr_t ia32_sys_call_table[];
> extern const sys_call_ptr_t x32_sys_call_table[];
> #endif

I see that only pt_regs is necessary and I understand this approach.
I was wondering if using this approach would reduce readability.
Once we add the snippet, the file builds even after removing the
following lines:
#include <linux/linkage.h>
#include <linux/sys.h>
#include <linux/cache.h>
#include <linux/ptrace.h>
#include <asm/syscall.h>

It is possible to remove them all, but do you think any should be kept?

Best,
Tanzir