The mm selftests generate both local_config.mk and local_config.h from
check_config.sh. With high parallelism (-jN), this can race and lead to
incomplete target builds (e.g. only a few binaries get built after
'make -j100', while 'make -j1' builds everything).

Switch to a stamp-based dependency:

  local_config.stamp: check_config.sh
        ... run check_config.sh ...
        touch local_config.stamp

and make local_config.mk/local_config.h depend on the stamp.

This ensures check_config.sh is executed once per update decision and
removes the parallel race window. Also hook local_config.stamp into
EXTRA_CLEAN.

No functional change intended for non-parallel builds.

Reported-by: Andrew Morton <[email protected]>
Signed-off-by: Li Wang <[email protected]>
---
 tools/testing/selftests/mm/Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/Makefile 
b/tools/testing/selftests/mm/Makefile
index 3b222cd6a048..78496f705386 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -261,10 +261,14 @@ $(OUTPUT)/migration: LDLIBS += -lnuma
 
 $(OUTPUT)/rmap: LDLIBS += -lnuma
 
-local_config.mk local_config.h: check_config.sh
-       CC="$(CC)" CFLAGS="$(CFLAGS)" ./check_config.sh
+local_config.stamp: check_config.sh
+       $(call msg,CHK,config,$@)
+       $(Q)CC="$(CC)" CFLAGS="$(CFLAGS)" ./check_config.sh
+       $(Q)touch $@
 
-EXTRA_CLEAN += local_config.mk local_config.h
+local_config.mk local_config.h: local_config.stamp
+
+EXTRA_CLEAN += local_config.mk local_config.h local_config.stamp
 
 ifeq ($(IOURING_EXTRA_LIBS),)
 all: warn_missing_liburing
-- 
2.53.0


Reply via email to