mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] KVM: selftests: Fix incremental build dependencies
@ 2026-09-22  7:19 Fuad Tabba
  2026-09-22  7:19 ` [PATCH v2 1/2] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
  2026-09-22  7:19 ` [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite Fuad Tabba
  0 siblings, 2 replies; 4+ messages in thread
From: Fuad Tabba @ 2026-09-22  7:19 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Shuah Khan, Oliver Upton
  Cc: Tejun Heo, Johannes Weiner, Michal Koutný,
	James Houghton, Will Deacon, Fuad Tabba, kvm, kvmarm, cgroups,
	linux-kselftest, linux-kernel

Hi folks,

Changes since v1 [1]:
  - Use FORCE for the sysreg header rule instead of duplicating the
    generator's inputs. (Oliver)
  - Added patch 2, the same class of bug in libcgroup.mk, found while
    testing patch 1.

Two fixes for Makefile rules that name a directory where a file's mtime
is what matters. The first is arm64-only: the sysreg header isn't
regenerated on an incremental build when the sysreg table changes. The
second is arch-independent: cgroup_util.o recompiles, and every test
relinks, on the run after any rebuild in lib/. The two patches are
independent.

I'd suggested v1 go through kvmarm as it was arm64-only. With patch 2
being generic, this one is addressed to kvm with kvmarm on Cc. Since the
patches are independent, they can also go through separate trees if
that's easier.

Based on Linux 7.3-rc1 (cee9395acd804).

Cheers,
/fuad

[1] https://lore.kernel.org/all/20260902134118.2718200-1-fuad.tabba@linux.dev/

Fuad Tabba (2):
  KVM: selftests: Fix arm64 sysreg header dependencies
  selftests/cgroup: Make the object directory an order-only prerequisite

 tools/testing/selftests/cgroup/lib/libcgroup.mk |  2 +-
 tools/testing/selftests/kvm/Makefile.kvm        | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)


base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] KVM: selftests: Fix arm64 sysreg header dependencies
  2026-09-22  7:19 [PATCH v2 0/2] KVM: selftests: Fix incremental build dependencies Fuad Tabba
@ 2026-09-22  7:19 ` Fuad Tabba
  2026-09-22  7:19 ` [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite Fuad Tabba
  1 sibling, 0 replies; 4+ messages in thread
From: Fuad Tabba @ 2026-09-22  7:19 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Shuah Khan, Oliver Upton
  Cc: Tejun Heo, Johannes Weiner, Michal Koutný,
	James Houghton, Will Deacon, Fuad Tabba, kvm, kvmarm, cgroups,
	linux-kselftest, linux-kernel

The rule generating the arm64 sysreg header targets the generated
directory, and its only prerequisite is tools/arch/arm64/tools/*,
which expands to the inner Makefile. An existing directory looks up
to date, so an incremental build never regenerates sysreg-defs.h for
a change to the sysreg table. A selftest referencing a register added
to the table since then fails with undeclared SYS_* identifiers. Clean
builds are unaffected.

Always recurse into tools/arch/arm64/tools, whose Makefile already
tracks the generator's inputs, and target the header rather than its
directory. The recursion leaves the header untouched when nothing
changed, so the dependents rebuild only when the header does.

Fixes: 70c7b704ca725 ("KVM: selftests: Avoid using forced target for generating arm64 headers")
Link: https://lore.kernel.org/r/arGRhHgP_izSwW4T@kernel.org
Assisted-by: LLM
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
 tools/testing/selftests/kvm/Makefile.kvm | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
index 96bab7002d39e..81dca3dbc16b4 100644
--- a/tools/testing/selftests/kvm/Makefile.kvm
+++ b/tools/testing/selftests/kvm/Makefile.kvm
@@ -303,10 +303,16 @@ arm64_hdr_outdir := $(tools_dir)/
 endif
 
 GEN_HDRS := $(arm64_hdr_outdir)arch/arm64/include/generated/
+GEN_SYSREG_DEFS := $(GEN_HDRS)asm/sysreg-defs.h
 CFLAGS += -I$(GEN_HDRS)
 
-$(GEN_HDRS): $(wildcard $(arm64_tools_dir)/*)
+# The inner Makefile tracks the generator's inputs and leaves the header
+# untouched when nothing changed, so dependents rebuild only when it does.
+$(GEN_SYSREG_DEFS): FORCE
 	$(MAKE) -C $(arm64_tools_dir) OUTPUT=$(arm64_hdr_outdir)
+
+FORCE:
+.PHONY: FORCE
 endif
 
 no-pie-option := $(call try-run, echo 'int main(void) { return 0; }' | \
@@ -359,10 +365,10 @@ EXTRA_CLEAN += $(GEN_HDRS) \
 	       $(TEST_GEN_OBJ) \
 	       cscope.*
 
-$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_HDRS)
+$(LIBKVM_C_OBJ): $(OUTPUT)/%.o: %.c $(GEN_SYSREG_DEFS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
-$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_HDRS)
+$(LIBKVM_S_OBJ): $(OUTPUT)/%.o: %.S $(GEN_SYSREG_DEFS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
 # Compile the string overrides as freestanding to prevent the compiler from
@@ -372,10 +378,10 @@ $(LIBKVM_STRING_OBJ): $(OUTPUT)/%.o: %.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -ffreestanding $< -o $@
 
 $(shell mkdir -p $(sort $(dir $(TEST_GEN_PROGS))))
-$(SPLIT_TEST_GEN_OBJ): $(GEN_HDRS)
+$(SPLIT_TEST_GEN_OBJ): $(GEN_SYSREG_DEFS)
 $(TEST_GEN_PROGS): $(LIBKVM_OBJS)
 $(TEST_GEN_PROGS_EXTENDED): $(LIBKVM_OBJS)
-$(TEST_GEN_OBJ): $(GEN_HDRS)
+$(TEST_GEN_OBJ): $(GEN_SYSREG_DEFS)
 
 cscope: include_paths = $(LINUX_TOOL_INCLUDE) $(LINUX_HDR_PATH) include lib ..
 cscope:
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite
  2026-09-22  7:19 [PATCH v2 0/2] KVM: selftests: Fix incremental build dependencies Fuad Tabba
  2026-09-22  7:19 ` [PATCH v2 1/2] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
@ 2026-09-22  7:19 ` Fuad Tabba
  2026-09-22 13:44   ` Michal Koutný
  1 sibling, 1 reply; 4+ messages in thread
From: Fuad Tabba @ 2026-09-22  7:19 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Shuah Khan, Oliver Upton
  Cc: Tejun Heo, Johannes Weiner, Michal Koutný,
	James Houghton, Will Deacon, Fuad Tabba, kvm, kvmarm, cgroups,
	linux-kselftest, linux-kernel

libcgroup.mk names $(LIBCGROUP_O_DIRS) as a regular prerequisite of
cgroup_util.o. The directory's mtime moves whenever an object is
created or replaced in it, so an incremental KVM selftests build that
rebuilt anything in lib/ recompiles cgroup_util.o and relinks every
test on the following run. Make the directory order-only, as
libvfio.mk does.

Fixes: 2c754a84ff16a ("cgroup: selftests: Move cgroup_util into its own library")
Assisted-by: LLM
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
 tools/testing/selftests/cgroup/lib/libcgroup.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/cgroup/lib/libcgroup.mk b/tools/testing/selftests/cgroup/lib/libcgroup.mk
index 7a73007204c39..bcf6fe2516223 100644
--- a/tools/testing/selftests/cgroup/lib/libcgroup.mk
+++ b/tools/testing/selftests/cgroup/lib/libcgroup.mk
@@ -13,7 +13,7 @@ EXTRA_HDRS := $(selfdir)/clone3/clone3_selftests.h
 $(LIBCGROUP_O_DIRS):
 	mkdir -p $@
 
-$(LIBCGROUP_O): $(OUTPUT)/%.o : $(CGROUP_DIR)/%.c $(EXTRA_HDRS) $(LIBCGROUP_O_DIRS)
+$(LIBCGROUP_O): $(OUTPUT)/%.o : $(CGROUP_DIR)/%.c $(EXTRA_HDRS) | $(LIBCGROUP_O_DIRS)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
 
 EXTRA_CLEAN += $(LIBCGROUP_O)
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite
  2026-09-22  7:19 ` [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite Fuad Tabba
@ 2026-09-22 13:44   ` Michal Koutný
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Koutný @ 2026-09-22 13:44 UTC (permalink / raw)
  To: Fuad Tabba
  Cc: Paolo Bonzini, Sean Christopherson, Shuah Khan, Oliver Upton,
	Tejun Heo, Johannes Weiner, James Houghton, Will Deacon,
	Fuad Tabba, kvm, kvmarm, cgroups, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 997 bytes --]

On Tue, Sep 22, 2026 at 08:19:45AM +0100, Fuad Tabba <fuad.tabba@linux.dev> wrote:
> libcgroup.mk names $(LIBCGROUP_O_DIRS) as a regular prerequisite of
> cgroup_util.o. The directory's mtime moves whenever an object is
> created or replaced in it, so an incremental KVM selftests build that
> rebuilt anything in lib/ recompiles cgroup_util.o and relinks every
> test on the following run.

I'd expect the other test would recompile stuff in lib/ but not in
cgroup/lib/, however that distinction is likely lost when $(OUTPUT) is
expanded from the included *.mk file.

> Make the directory order-only, as libvfio.mk does.

Sensible approach given that vfio.

> 
> Fixes: 2c754a84ff16a ("cgroup: selftests: Move cgroup_util into its own library")
> Assisted-by: LLM
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> ---
>  tools/testing/selftests/cgroup/lib/libcgroup.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Michal Koutný <mkoutny@suse.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-22 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22  7:19 [PATCH v2 0/2] KVM: selftests: Fix incremental build dependencies Fuad Tabba
2026-09-22  7:19 ` [PATCH v2 1/2] KVM: selftests: Fix arm64 sysreg header dependencies Fuad Tabba
2026-09-22  7:19 ` [PATCH v2 2/2] selftests/cgroup: Make the object directory an order-only prerequisite Fuad Tabba
2026-09-22 13:44   ` Michal Koutný

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®