Skip to contentSkip to conversation

checksyscalls: only run when necessary

PATCH In review Thomas Weißschuh 2 participants 5 messages Apr 2

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover checksyscalls: only run when necessary

Currently checksyscalls.sh is unconditionally executed during each build. Most of these executions are unnecessary.

Only run checksyscalls.sh if one of its inputs have changed.

---
Changes in v3:
- Use $(addprefix) to print instance identification
- Link to v2: https://patch.msgid.link/20260324-kbuild-missing-syscalls-v2-0-651b8beb0bfd@weissschuh.net

Changes in v2:
- Also send to kbuild maintainers
- Link to v1: https://patch.msgid.link/20260303-kbuild-missing-syscalls-v1-0-3b4d69b68c75@weissschuh.net

---
Thomas Weißschuh (3):
checksyscalls: move path to reference table to a variable
checksyscalls: only run when necessary
checksyscalls: move instance functionality into generic code

 Kbuild                   | 14 ++++++++++----
 arch/mips/Makefile       |  6 ++----
 scripts/checksyscalls.sh |  9 ++++++++-
 3 files changed, 20 insertions(+), 9 deletions(-)

---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20260212-kbuild-missing-syscalls-e328de3c4b54

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#1 lore raw

PATCH v3 1/3 checksyscalls: move path to reference table to a variable

An upcoming patch will need to reuse this path.

Move it into a reusable variable.

---
 scripts/checksyscalls.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checksyscalls.sh +3 -1
index 1e5d2eeb726d..9becaf8d7b78 100755
@@ -10,6 +10,8 @@
 # checksyscalls.sh gcc gcc-options
 #
 
+reference_table="$(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl"
+
 ignore_list() {
 cat << EOF
 #include <asm/types.h>
@@ -269,5 +271,5 @@ syscall_list() {
 	done
 }
 
-(ignore_list && syscall_list $(dirname $0)/../arch/x86/entry/syscalls/syscall_32.tbl) | \
+(ignore_list && syscall_list ${reference_table}) | \
 $* -Wno-error -Wno-unused-macros -E -x c - > /dev/null
Signature · 1 line
2.53.0
#2 lore raw

PATCH v3 2/3 checksyscalls: only run when necessary

In reply to Thomas Weißschuh

Currently checksyscalls.sh is unconditionally executed during each build. Most of these executions are unnecessary.

Only run checksyscalls.sh if one of its inputs have changed.

This new logic does not work for the multiple invocations done for MIPS. The effect is that checksyscalls.sh is still executed unconditionally. However this is not worse than before.

---
 Kbuild                   | 12 +++++++++---
 scripts/checksyscalls.sh |  5 +++++
 2 files changed, 14 insertions(+), 3 deletions(-)
Kbuild +9 -3
index 13324b4bbe23..515cc6a27477 100644
@@ -47,12 +47,18 @@ $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE
 
 # Check for missing system calls
 
+missing-syscalls-file := .tmp_missing-syscalls
+
+targets += $(missing-syscalls-file)
+
 quiet_cmd_syscalls = CALL    $<
-      cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
+      cmd_syscalls = DEPFILE=$(depfile) $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags); touch $@
+
+$(missing-syscalls-file): scripts/checksyscalls.sh $(rq-offsets-file) FORCE
+	$(call if_changed_dep,syscalls)
 
 PHONY += missing-syscalls
-missing-syscalls: scripts/checksyscalls.sh $(rq-offsets-file)
-	$(call cmd,syscalls)
+missing-syscalls: $(missing-syscalls-file)
 
 # Check the manual modification of atomic headers
 
scripts/checksyscalls.sh +5 -0
index 9becaf8d7b78..a6d0882f07e1 100755
@@ -273,3 +273,8 @@ syscall_list() {
 
 (ignore_list && syscall_list ${reference_table}) | \
 $* -Wno-error -Wno-unused-macros -E -x c - > /dev/null
+
+# For fixdep
+if [ -n "${DEPFILE}" ]; then
+	echo "${0}: ${0} ${reference_table}" >> "${DEPFILE}"
+fi
Signature · 1 line
2.53.0
#3 lore raw

PATCH v3 3/3 checksyscalls: move instance functionality into generic code

In reply to Thomas Weißschuh

On MIPS the checksyscalls.sh script may be executed multiple times. Currently these multiple executions are executed on each build as kbuild see that the commands have changed each time.

Use a dedicated stamp file for each different invocation to avoid the spurious executions.

---
 Kbuild             | 4 ++--
 arch/mips/Makefile | 6 ++----
 2 files changed, 4 insertions(+), 6 deletions(-)
Kbuild +2 -2
index 515cc6a27477..a6a0192dea08 100644
@@ -47,11 +47,11 @@ $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE
 
 # Check for missing system calls
 
-missing-syscalls-file := .tmp_missing-syscalls
+missing-syscalls-file := .tmp_missing-syscalls$(missing_syscalls_instance)
 
 targets += $(missing-syscalls-file)
 
-quiet_cmd_syscalls = CALL    $<
+quiet_cmd_syscalls = CALL    $< $(addprefix for ,$(missing_syscalls_instance))
       cmd_syscalls = DEPFILE=$(depfile) $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags); touch $@
 
 $(missing-syscalls-file): scripts/checksyscalls.sh $(rq-offsets-file) FORCE
arch/mips/Makefile +2 -4
index d9057e29bc62..6705fa5d9211 100644
@@ -421,12 +421,10 @@ CLEAN_FILES += vmlinux.32 vmlinux.64
 
 archprepare:
 ifdef CONFIG_MIPS32_N32
-	@$(kecho) '  Checking missing-syscalls for N32'
-	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32"
+	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_instance="N32" missing_syscalls_flags="-mabi=n32"
 endif
 ifdef CONFIG_MIPS32_O32
-	@$(kecho) '  Checking missing-syscalls for O32'
-	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32"
+	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_instance="O32" missing_syscalls_flags="-mabi=32"
 endif
 
 install:
Signature · 1 line
2.53.0
maintainer
#4 lore raw
In reply to Thomas Weißschuh
Quoted 8 lines · Thomas Weißschuh

checksyscalls: only run when necessary

Currently checksyscalls.sh is unconditionally executed during each build. Most of these executions are unnecessary.

Only run checksyscalls.sh if one of its inputs have changed.

[...]

Applied to kbuild/linux.git (kbuild-next-unstable), thanks!

[1/3] checksyscalls: move path to reference table to a variable

      https://git.kernel.org/kbuild/c/263246f2
[2/3] checksyscalls: only run when necessary
      https://git.kernel.org/kbuild/c/a414e4ba
[3/3] checksyscalls: move instance functionality into generic code
      https://git.kernel.org/kbuild/c/a46f42c3

Please look out for regression or issue reports or other follow up comments, as they may result in the patch/series getting dropped, reverted or modified (e.g. trailers). Patches applied to the kbuild-next-unstable branch are accepted pending wider testing in linux-next and any post-commit review; they will generally be moved to the kbuild-next branch in about a week if no issues are found.

Best regards,

Signature · 1 line
Nicolas