Skip to contentSkip to conversation

selftests: use "$(MAKE)" instead of "make"

PATCH In review Ilya Leoshkevich 2 participants 2 messages Aug 16, 2019 – Aug 19, 2019

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

PATCH 1/1 selftests: use "$(MAKE)" instead of "make"

When doing "make kselftest TARGETS=bpf -j12", bpf progs end up being compiled sequentially and thus slowly.

The reason is that parent make (tools/testing/selftests/Makefile) does not share its jobserver with child make (tools/testing/selftests/bpf/Makefile), therefore the latter runs with -j1.

Change all instances of "make" to "$(MAKE)", so that the whole make hierarchy runs using a single jobserver.

---
I tested this with:

make kselftest
make -C tools/testing/selftests
make -C tools/testing/selftests/bpf

Unfortunately, in my setup a lot of tests fail for a number of reasons. However, this change does not make it worse.

tools/testing/selftests/Makefile | 22 +++++++++++-----------

 1 file changed, 11 insertions(+), 11 deletions(-)
tools/testing/selftests/Makefile +11 -11
index 25b43a8c2b15..c3feccb99ff5 100644
@@ -126,9 +126,9 @@ endif
 # in the default INSTALL_HDR_PATH usr/include.
 khdr:
 ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
-	make --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
+	$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
 else
-	make --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
+	$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
 		ARCH=$(ARCH) -C $(top_srcdir) headers_install
 endif
 
@@ -136,35 +136,35 @@ all: khdr
 	@for TARGET in $(TARGETS); do		\
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
 		mkdir $$BUILD_TARGET  -p;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\
 	done;
 
 run_tests: all
 	@for TARGET in $(TARGETS); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
 	done;
 
 hotplug:
 	@for TARGET in $(TARGETS_HOTPLUG); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\
 	done;
 
 run_hotplug: hotplug
 	@for TARGET in $(TARGETS_HOTPLUG); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
 	done;
 
 clean_hotplug:
 	@for TARGET in $(TARGETS_HOTPLUG); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
 	done;
 
 run_pstore_crash:
-	make -C pstore run_crash
+	$(MAKE) -C pstore run_crash
 
 # Use $BUILD as the default install root. $BUILD points to the
 # right output location for the following cases:
@@ -184,7 +184,7 @@ ifdef INSTALL_PATH
 	install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/
 	@for TARGET in $(TARGETS); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
 	done;
 
 	@# Ask all targets to emit their test scripts
@@ -203,7 +203,7 @@ ifdef INSTALL_PATH
 		echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
 		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
 		echo -n "run_many" >> $(ALL_SCRIPT); \
-		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
+		$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
 		echo "" >> $(ALL_SCRIPT);	    \
 		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
 	done;
@@ -216,7 +216,7 @@ endif
 clean:
 	@for TARGET in $(TARGETS); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
 	done;
 
 .PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean
Signature · 1 line
2.21.0
maintainer
#1 lore raw
Quoted 103 lines · Ilya Leoshkevich

When doing "make kselftest TARGETS=bpf -j12", bpf progs end up being compiled sequentially and thus slowly.

The reason is that parent make (tools/testing/selftests/Makefile) does not share its jobserver with child make (tools/testing/selftests/bpf/Makefile), therefore the latter runs with -j1.

Change all instances of "make" to "$(MAKE)", so that the whole make hierarchy runs using a single jobserver.

---
I tested this with:

make kselftest
make -C tools/testing/selftests
make -C tools/testing/selftests/bpf

Unfortunately, in my setup a lot of tests fail for a number of reasons. However, this change does not make it worse.

tools/testing/selftests/Makefile | 22 +++++++++++-----------

  1 file changed, 11 insertions(+), 11 deletions(-)
tools/testing/selftests/Makefile +10 -10
index 25b43a8c2b15..c3feccb99ff5 100644
@@ -126,9 +126,9 @@ endif
  # in the default INSTALL_HDR_PATH usr/include.
  khdr:
  ifeq (1,$(DEFAULT_INSTALL_HDR_PATH))
-	make --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
+	$(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install
  else
-	make --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
+	$(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \
  		ARCH=$(ARCH) -C $(top_srcdir) headers_install
  endif
 
@@ -136,35 +136,35 @@ all: khdr
  	@for TARGET in $(TARGETS); do		\
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
  		mkdir $$BUILD_TARGET  -p;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\
  	done;
 
  run_tests: all
  	@for TARGET in $(TARGETS); do \
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\
  	done;
 
  hotplug:
  	@for TARGET in $(TARGETS_HOTPLUG); do \
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET;\
  	done;
 
  run_hotplug: hotplug
  	@for TARGET in $(TARGETS_HOTPLUG); do \
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\
  	done;
 
  clean_hotplug:
  	@for TARGET in $(TARGETS_HOTPLUG); do \
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
  	done;
 
  run_pstore_crash:
-	make -C pstore run_crash
+	$(MAKE) -C pstore run_crash
 
  # Use $BUILD as the default install root. $BUILD points to the
  # right output location for the following cases:
@@ -184,7 +184,7 @@ ifdef INSTALL_PATH
  	install -m 744 kselftest/prefix.pl $(INSTALL_PATH)/kselftest/
  	@for TARGET in $(TARGETS); do \
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
  	done;
 
  	@# Ask all targets to emit their test scripts
@@ -203,7 +203,7 @@ ifdef INSTALL_PATH
  		echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
  		echo "cd $$TARGET" >> $(ALL_SCRIPT); \
  		echo -n "run_many" >> $(ALL_SCRIPT); \
-		make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
+		$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
  		echo "" >> $(ALL_SCRIPT);	    \
  		echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
  	done;

tools/testing/selftests/Makefile endif · line 222

Quoted 8 lines
tools/testing/selftests/Makefile +1 -1
@@ -216,7 +216,7 @@ endif
  clean:
  	@for TARGET in $(TARGETS); do \
  		BUILD_TARGET=$$BUILD/$$TARGET;	\
-		make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
+		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\
  	done;
 
  .PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean

Thanks. I will apply this for 5.4-rc1

thanks,
-- Shuah