lkl: fix incremental build via tools/lkl#635
Open
clingfei wants to merge 1 commit into
Open
Conversation
`make -C tools/lkl` had two related problems: 1. Correctness: modifying any kernel source file did not trigger a rebuild. tools/lkl/Makefile's lib/lkl.o rule depended only on bin/stat and $(DOT_CONFIG), so the recursive kernel make was never invoked when only kernel sources changed. Host libraries got relinked over a stale lib/lkl.o, masking the failure. 2. Performance: even with no source changes, several pipeline stages unconditionally bumped output mtimes, causing the whole chain (objcopy -> install -> all ~200 LKL headers -> every host .o -> liblkl.a -> every .so) to fire on every make. The patch consists of following modifications: tools/lkl/Makefile: add FORCE to lib/lkl.o so the recursive make is always entered; kbuild's own incremental check then decides what to rebuild from source timestamps. arch/lkl/include/uapi/asm/Kbuild: declare syscall_defs.h as generated-y. Without this, scripts/Makefile.asm-generic treats the file as a stale wrapper and REMOVEs it on every build, forcing arch/lkl/Makefile to re-extract it via objcopy. arch/lkl/Makefile: rewrite the lkl.o and syscall_defs.h rules to objcopy to a tmp file and cmp before replacing $@. vmlinux is PHONY in the top-level Makefile so its recipe always runs; if_changed cannot be used here (newer-prereqs filters out PHONY prereqs and would silently skip real vmlinux content changes), so an in-recipe cmp preserves mtime on no-op rebuilds while still updating on real changes. Pass -p to the install cp so the preserved mtime propagates to tools/lkl/lib/lkl.o. arch/lkl/scripts/headers_install.py: stage the two-pass install. The first pass writes scripts/headers_install.sh output to dst.raw. The second pass (update_header) reads dst.raw, produces the final lkl_-prefixed content, and only writes dst when the content differs from the existing destination. After applying this patch, editing any kernel source correctly propagates to the final libraries, and a no-op `make` in tools/lkl performs no host-side work -- only the two unavoidable OBJCOPY invocations against the PHONY vmlinux target. A no-op make would run as follows: ``` make -C tools/lkl MMU=1 -j128 make: Entering directory '/path/to/linux/tools/lkl' CALL scripts/checksyscalls.sh OBJCOPY lkl.o OBJCOPY arch/lkl/include/generated/uapi/asm/syscall_defs.h make -C ../.. ARCH=lkl install INSTALL_PATH=/path/to/linux/tools/lkl/ INSTALL linux/tools/lkl//lib/lkl.o make: Leaving directory '/path/to/linux/tools/lkl' ``` Signed-off-by: Cheng Lingfei <1599101385@qq.com>
Author
Test Results106 files ±0 106 suites ±0 7m 9s ⏱️ +12s Results for commit 0ad6b8b. ± Comparison against base commit 0d3712a. This pull request removes 64 and adds 64 tests. Note that renamed tests count towards both. |
clingfei
added a commit
to clingfei/linux
that referenced
this pull request
May 20, 2026
Same issue commit 8b61f60 ("lkl tests: avoid variable test names") fixed for disk.sh: lklfuse.sh passes the random mktemp paths $file/$dir /$lock_file as arguments to lkl_test_run, which embeds them into the test name. The GitHub test reporter then sees 64 "removed" and 64 "added" tests on every CI run because the temp paths differ run to run. See lkl#635 (comment). Drop the random-path arguments from lkl_test_run calls and reference the outer-scope $file/$dir/$lock_file directly inside each function. $fstype stays as an argument since it is stable across runs. Also update the commented-out stress-ng call so a future uncomment does not re-introduce the issue. Signed-off-by: Cheng Lingfei <1599101385@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make -C tools/lklhad two related problems:Correctness: modifying any kernel source file did not trigger a rebuild. tools/lkl/Makefile's lib/lkl.o rule depended only on bin/stat and $(DOT_CONFIG), so the recursive kernel make was never invoked when only kernel sources changed. Host libraries got relinked over a stale lib/lkl.o, masking the failure.
Performance: even with no source changes, several pipeline stages unconditionally bumped output mtimes, causing the whole chain (objcopy -> install -> all ~200 LKL headers -> every host .o -> liblkl.a -> every .so) to fire on every make.
The patch consists of following modifications:
tools/lkl/Makefile: add FORCE to lib/lkl.o so the recursive make is always entered; kbuild's own incremental check then decides what to rebuild from source timestamps.
arch/lkl/include/uapi/asm/Kbuild: declare syscall_defs.h as generated-y. Without this, scripts/Makefile.asm-generic treats the file as a stale wrapper and REMOVEs it on every build, forcing arch/lkl/Makefile to re-extract it via objcopy.
arch/lkl/Makefile: rewrite the lkl.o and syscall_defs.h rules to objcopy to a tmp file and cmp before replacing $@. vmlinux is PHONY in the top-level Makefile so its recipe always runs; if_changed cannot be used here (newer-prereqs filters out PHONY prereqs and would silently skip real vmlinux content changes), so an in-recipe cmp preserves mtime on no-op rebuilds while still updating on real changes. Pass -p to the install cp so the preserved mtime propagates to tools/lkl/lib/lkl.o.
arch/lkl/scripts/headers_install.py: stage the two-pass install. The first pass writes scripts/headers_install.sh output to dst.raw. The second pass (update_header) reads dst.raw, produces the final lkl_-prefixed content, and only writes dst when the content differs from the existing destination.
After applying this patch, editing any kernel source correctly propagates to the final libraries, and a no-op
makein tools/lkl performs no host-side work -- only the two unavoidable OBJCOPY invocations against the PHONY vmlinux target. A no-op make would run as follows: