* [PATCH] x86/syscalls: shrink entry/syscall_64.i via IWYU
@ 2024-01-04 0:13 Tanzir Hasan
2024-01-04 21:00 ` Nick Desaulniers
2024-01-05 18:11 ` Nick Desaulniers
0 siblings, 2 replies; 3+ messages in thread
From: Tanzir Hasan @ 2024-01-04 0:13 UTC (permalink / raw)
To: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin
Cc: linux-kernel, Nick Desaulniers, Al Viro, Tanzir Hasan
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_64.c resulted in a preprocessed size of
entry/syscall_64.i from 64003 lines to 24509 lines (-62%) for the x86
defconfig.
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Tanzir Hasan <tanzirh@google.com>
---
arch/x86/entry/syscall_64.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/arch/x86/entry/syscall_64.c b/arch/x86/entry/syscall_64.c
index be120eec1fc9..9e4a3d8957f3 100644
--- a/arch/x86/entry/syscall_64.c
+++ b/arch/x86/entry/syscall_64.c
@@ -1,12 +1,22 @@
// SPDX-License-Identifier: GPL-2.0
/* System call table for x86-64. */
-#include <linux/linkage.h>
-#include <linux/sys.h>
-#include <linux/cache.h>
-#include <linux/syscalls.h>
#include <asm/syscall.h>
+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
+
#define __SYSCALL(nr, sym) extern long __x64_##sym(const struct pt_regs *);
#include <asm/syscalls_64.h>
#undef __SYSCALL
---
base-commit: f5837722ffecbbedf1b1dbab072a063565f0dad1
change-id: 20231228-syscall_64-30ba68440a85
Best regards,
--
Tanzir Hasan <tanzirh@google.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/syscalls: shrink entry/syscall_64.i via IWYU
2024-01-04 0:13 [PATCH] x86/syscalls: shrink entry/syscall_64.i via IWYU Tanzir Hasan
@ 2024-01-04 21:00 ` Nick Desaulniers
2024-01-05 18:11 ` Nick Desaulniers
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2024-01-04 21:00 UTC (permalink / raw)
To: Tanzir Hasan
Cc: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, linux-kernel, Nick Desaulniers,
Al Viro
On Wed, Jan 3, 2024 at 4:13 PM Tanzir Hasan <tanzirh@google.com> 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_64.c resulted in a preprocessed size of
> entry/syscall_64.i from 64003 lines to 24509 lines (-62%) for the x86
> defconfig.
>
> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Tanzir Hasan <tanzirh@google.com>
> ---
> arch/x86/entry/syscall_64.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/entry/syscall_64.c b/arch/x86/entry/syscall_64.c
> index be120eec1fc9..9e4a3d8957f3 100644
> --- a/arch/x86/entry/syscall_64.c
> +++ b/arch/x86/entry/syscall_64.c
> @@ -1,12 +1,22 @@
> // SPDX-License-Identifier: GPL-2.0
> /* System call table for x86-64. */
>
> -#include <linux/linkage.h>
> -#include <linux/sys.h>
> -#include <linux/cache.h>
> -#include <linux/syscalls.h>
> #include <asm/syscall.h>
>
> +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
> +
arch/x86/include/asm/syscall.h (which you retained) already includes
the typedef for sys_call_ptr_t, and the declaration of sys_call_table,
and everything else.
Was there some additional refactoring that Al mentioned or intended
for you to do here? Perhaps as part of a series so it's more obvious
to reviewers? You can include a Link: tag (see `git log` for examples)
in a commit message to link back to discussions on lore.kernel.org.
Doing so can help provide more context to reviewers as to //why// or
justification for a change.
Otherwise I'm not sure you need any of these additions (other than
maybe pt_regs).
> #define __SYSCALL(nr, sym) extern long __x64_##sym(const struct pt_regs *);
> #include <asm/syscalls_64.h>
> #undef __SYSCALL
>
> ---
> base-commit: f5837722ffecbbedf1b1dbab072a063565f0dad1
> change-id: 20231228-syscall_64-30ba68440a85
>
> Best regards,
> --
> Tanzir Hasan <tanzirh@google.com>
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/syscalls: shrink entry/syscall_64.i via IWYU
2024-01-04 0:13 [PATCH] x86/syscalls: shrink entry/syscall_64.i via IWYU Tanzir Hasan
2024-01-04 21:00 ` Nick Desaulniers
@ 2024-01-05 18:11 ` Nick Desaulniers
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2024-01-05 18:11 UTC (permalink / raw)
Cc: Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, linux-kernel, Al Viro
On Wed, Jan 3, 2024 at 4:13 PM Tanzir Hasan <tanzirh@google.com> 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_64.c resulted in a preprocessed size of
> entry/syscall_64.i from 64003 lines to 24509 lines (-62%) for the x86
> defconfig.
>
> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Tanzir Hasan <tanzirh@google.com>
> ---
> arch/x86/entry/syscall_64.c | 18 ++++++++++++++----
Generally question to the CC list. Does anyone know //why//
sys_call_table is defined as asmlinkage?
I don't see why `extern "C"` or __attribute__((regparm(0))) would be
necessary here, but maybe I'm missing something?
I don't think that's necessary to refer to //data// defined in C from
inline asm. Nothing in Documentation mentions this.
And honestly those two seem conflated IMO. UAPI headers make sense to
use extern C.
assembler defined functions called from C should have regparm set so C
callers know about the i386 calling convention change.
Those seem orthogonal to me; do we ever have cases where BOTH make sense?
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-05 18:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04 0:13 [PATCH] x86/syscalls: shrink entry/syscall_64.i via IWYU Tanzir Hasan
2024-01-04 21:00 ` Nick Desaulniers
2024-01-05 18:11 ` Nick Desaulniers
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.