public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets
@ 2026-03-31  4:01 Li Wang
  2026-03-31  4:01 ` [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds Li Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Li Wang @ 2026-03-31  4:01 UTC (permalink / raw)
  To: akpm, david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	shuah
  Cc: linux-mm, linux-kselftest, linux-kernel

The 32-bit and 64-bit compilation rules invoke $(CC) directly, bypassing
the $(Q) quiet prefix and $(call msg,...) helper used by the rest of the
selftests build system. This causes these rules to always print the full
compiler command line, even when V=0 (the default).

Wrap the commands with $(Q) and $(call msg,CC,,$@) to match the
convention used by lib.mk, so that quiet and verbose builds behave
consistently across all targets.

==== Build logs ====
  ...
  CC       merge
  CC       rmap
  CC       soft-dirty
  gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..
                -isystem /usr/src/25/tools/testing/selftests/../../../usr/include
                -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi
                -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE=
                -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests
                -m32 -mxsave  protection_keys.c vm_util.c thp_settings.c pkey_util.c
                -lrt -lpthread -lm -lrt -ldl -lm
                -o /usr/src/25/tools/testing/selftests/mm/protection_keys_32
  gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..
                -isystem /usr/src/25/tools/testing/selftests/../../../usr/include
                -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi
                -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE=
                -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests
                -m32 -mxsave  pkey_sighandler_tests.c vm_util.c thp_settings.c pkey_util.c
                -lrt -lpthread -lm -lrt -ldl -lm
                -o /usr/src/25/tools/testing/selftests/mm/pkey_sighandler_tests_32
  ...

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 tools/testing/selftests/mm/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 7a5de4e9bf52..3b222cd6a048 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -215,7 +215,8 @@ ifeq ($(CAN_BUILD_I386),1)
 $(BINARIES_32): CFLAGS += -m32 -mxsave
 $(BINARIES_32): LDLIBS += -lrt -ldl -lm
 $(BINARIES_32): $(OUTPUT)/%_32: %.c
-	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
+	$(call msg,CC,,$@)
+	$(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
 $(foreach t,$(VMTARGETS),$(eval $(call gen-target-rule-32,$(t))))
 endif
 
@@ -223,7 +224,8 @@ ifeq ($(CAN_BUILD_X86_64),1)
 $(BINARIES_64): CFLAGS += -m64 -mxsave
 $(BINARIES_64): LDLIBS += -lrt -ldl
 $(BINARIES_64): $(OUTPUT)/%_64: %.c
-	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
+	$(call msg,CC,,$@)
+	$(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
 $(foreach t,$(VMTARGETS),$(eval $(call gen-target-rule-64,$(t))))
 endif
 
-- 
2.53.0


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

* [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds
  2026-03-31  4:01 [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Li Wang
@ 2026-03-31  4:01 ` Li Wang
  2026-03-31  5:29   ` Andrew Morton
  2026-03-31  4:01 ` [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path Li Wang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Li Wang @ 2026-03-31  4:01 UTC (permalink / raw)
  To: akpm, david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	shuah
  Cc: linux-mm, linux-kselftest, linux-kernel

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 <akpm@linux-foundation.org>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 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


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

* [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path
  2026-03-31  4:01 [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Li Wang
  2026-03-31  4:01 ` [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds Li Wang
@ 2026-03-31  4:01 ` Li Wang
  2026-03-31  5:30   ` Andrew Morton
  2026-03-31  4:01 ` [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing Li Wang
  2026-03-31  5:29 ` [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Andrew Morton
  3 siblings, 1 reply; 12+ messages in thread
From: Li Wang @ 2026-03-31  4:01 UTC (permalink / raw)
  To: akpm, david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	shuah
  Cc: linux-mm, linux-kselftest, linux-kernel

When running selftests from the kernel top-level (e.g. make kselftest-all),
sub-makes might still inherit the caller's PWD from the environment.

Some selftests use $(PWD) in recursive kbuild invocations, which can
then incorrectly resolve to the kernel top directory instead of the
current test directory.

In that case, kbuild may generate an external-module wrapper Makefile in
the wrong location, potentially clobbering the top-level Makefile and
causing recursive include failures ("Too many open files").

Export PWD := $(CURDIR) in selftests/lib.mk so $(PWD) always matches the
actual current selftest directory.

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 tools/testing/selftests/lib.mk                | 2 ++
 tools/testing/selftests/mm/local_config.stamp | 0
 2 files changed, 2 insertions(+)
 create mode 100644 tools/testing/selftests/mm/local_config.stamp

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index f02cc8a2e4ae..2840e98c225c 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -60,6 +60,8 @@ endif
 selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
 top_srcdir = $(selfdir)/../../..
 
+export PWD := $(CURDIR)
+
 # msg: emit succinct information message describing current building step
 # $1 - generic step name (e.g., CC, LINK, etc);
 # $2 - optional "flavor" specifier; if provided, will be emitted as [flavor];
diff --git a/tools/testing/selftests/mm/local_config.stamp b/tools/testing/selftests/mm/local_config.stamp
new file mode 100644
index 000000000000..e69de29bb2d1
-- 
2.53.0


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

* [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing
  2026-03-31  4:01 [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Li Wang
  2026-03-31  4:01 ` [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds Li Wang
  2026-03-31  4:01 ` [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path Li Wang
@ 2026-03-31  4:01 ` Li Wang
  2026-03-31  7:13   ` Li Wang
  2026-03-31  5:29 ` [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Andrew Morton
  3 siblings, 1 reply; 12+ messages in thread
From: Li Wang @ 2026-03-31  4:01 UTC (permalink / raw)
  To: akpm, david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	shuah
  Cc: linux-mm, linux-kselftest, linux-kernel

mm selftests rely on IOURING_EXTRA_LIBS (typically from local_config.mk)
to link io_uring-based tests (cow and gup_longterm). On some systems
with liburing installed, IOURING_EXTRA_LIBS can still be empty, causing
link failures with unresolved io_uring symbols.

Add a fallback detection:

  IOURING_EXTRA_LIBS := $(shell pkg-config --libs liburing)

when IOURING_EXTRA_LIBS was not set by local_config.mk.

Also gate io_uring-dependent test binaries (cow and gup_longterm) on
IOURING_EXTRA_LIBS being non-empty, so missing liburing support cleanly
skips those tests instead of failing the build.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 tools/testing/selftests/mm/Makefile | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 78496f705386..01bdd25e04e4 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -10,6 +10,11 @@ LOCAL_HDRS += $(selfdir)/mm/mseal_helpers.h
 
 include local_config.mk
 
+PKG_CONFIG ?= pkg-config
+ifeq ($(IOURING_EXTRA_LIBS),)
+IOURING_EXTRA_LIBS := $(shell $(PKG_CONFIG) --libs liburing 2>/dev/null)
+endif
+
 ifeq ($(ARCH),)
 
 ifeq ($(CROSS_COMPILE),)
@@ -55,10 +60,12 @@ else
 PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first"
 endif
 
-TEST_GEN_FILES = cow
-TEST_GEN_FILES += compaction_test
-TEST_GEN_FILES += gup_longterm
+TEST_GEN_FILES = compaction_test
 TEST_GEN_FILES += gup_test
+ifneq ($(IOURING_EXTRA_LIBS),)
+TEST_GEN_FILES += cow
+TEST_GEN_FILES += gup_longterm
+endif
 TEST_GEN_FILES += hmm-tests
 TEST_GEN_FILES += hugetlb-madvise
 TEST_GEN_FILES += hugetlb-read-hwpoison
-- 
2.53.0


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

* Re: [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets
  2026-03-31  4:01 [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Li Wang
                   ` (2 preceding siblings ...)
  2026-03-31  4:01 ` [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing Li Wang
@ 2026-03-31  5:29 ` Andrew Morton
  2026-03-31  9:50   ` Li Wang
  3 siblings, 1 reply; 12+ messages in thread
From: Andrew Morton @ 2026-03-31  5:29 UTC (permalink / raw)
  To: Li Wang
  Cc: david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, shuah,
	linux-mm, linux-kselftest, linux-kernel

On Tue, 31 Mar 2026 12:01:53 +0800 Li Wang <liwang@redhat.com> wrote:

> The 32-bit and 64-bit compilation rules invoke $(CC) directly, bypassing
> the $(Q) quiet prefix and $(call msg,...) helper used by the rest of the
> selftests build system. This causes these rules to always print the full
> compiler command line, even when V=0 (the default).
> 
> Wrap the commands with $(Q) and $(call msg,CC,,$@) to match the
> convention used by lib.mk, so that quiet and verbose builds behave
> consistently across all targets.
> 
> ==== Build logs ====
>   ...
>   CC       merge
>   CC       rmap
>   CC       soft-dirty
>   gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..
>                 -isystem /usr/src/25/tools/testing/selftests/../../../usr/include
>                 -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi
>                 -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE=
>                 -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests
>                 -m32 -mxsave  protection_keys.c vm_util.c thp_settings.c pkey_util.c
>                 -lrt -lpthread -lm -lrt -ldl -lm
>                 -o /usr/src/25/tools/testing/selftests/mm/protection_keys_32
>   gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..
>                 -isystem /usr/src/25/tools/testing/selftests/../../../usr/include
>                 -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi
>                 -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE=
>                 -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests
>                 -m32 -mxsave  pkey_sighandler_tests.c vm_util.c thp_settings.c pkey_util.c
>                 -lrt -lpthread -lm -lrt -ldl -lm
>                 -o /usr/src/25/tools/testing/selftests/mm/pkey_sighandler_tests_32
>   ...
> 
> Reported-by: Andrew Morton <akpm@linux-foundation.org>

wow, thanks, do you want my credit card number?

>  tools/testing/selftests/mm/Makefile | 6 ++++--

Before: 

ts:/usr/src/25/tools/testing/selftests/mm> make -j100
CC="gcc" CFLAGS="-Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..  -isystem /usr/src/25/tools/testing/selftests/../../../usr/include -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE= -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests " ./check_config.sh
  CC       cow
  CC       compaction_test
  CC       gup_longterm
  CC       gup_test
  CC       hmm-tests
  CC       hugetlb-madvise
  CC       hugetlb-read-hwpoison
  CC       hugetlb-soft-offline
  CC       hugepage-mmap
  CC       hugepage-mremap
  CC       hugepage-shm
  CC       hugepage-vmemmap
  CC       khugepaged
  CC       madv_populate
  CC       map_fixed_noreplace
  CC       map_populate
  CC       map_hugetlb
  CC       memfd_secret
  CC       memory-failure
  CC       migration
  CC       mkdirty
  CC       mlock-random-test
  CC       mlock2-tests
  CC       mremap_dontunmap
  CC       mrelease_test
...
  CC       merge
  CC       rmap
gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..  -isystem /usr/src/25/tools/testing/selftests/../../../usr/include -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE= -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests  -m32 -mxsave  protection_keys.c vm_util.c thp_settings.c pkey_util.c -lrt -lpthread -lm -lrt -ldl -lm -o /usr/src/25/tools/testing/selftests/mm/protection_keys_32
  CC       folio_split_race_test
  CC       soft-dirty
gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..  -isystem /usr/src/25/tools/testing/selftests/../../../usr/include -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE= -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests  -m32 -mxsave  pkey_sighandler_tests.c vm_util.c thp_settings.c pkey_util.c -lrt -lpthread -lm -lrt -ldl -lm -o /usr/src/25/tools/testing/selftests/mm/pkey_sighandler_tests_32
gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..  -isystem /usr/src/25/tools/testing/selftests/../../../usr/include -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE= -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests  -m64 -mxsave  protection_keys.c vm_util.c thp_settings.c pkey_util.c -lrt -lpthread -lm -lrt -ldl -o /usr/src/25/tools/testing/selftests/mm/protection_keys_64
gcc -Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..  -isystem /usr/src/25/tools/testing/selftests/../../../usr/include -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE= -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests  -m64 -mxsave  pkey_sighandler_tests.c vm_util.c thp_settings.c pkey_util.c -lrt -lpthread -lm -lrt -ldl -o /usr/src/25/tools/testing/selftests/mm/pkey_sighandler_tests_64
  CC       write_to_hugetlbfs


after:

ts:/usr/src/25/tools/testing/selftests/mm> make clean
...
ts:/usr/src/25/tools/testing/selftests/mm> make -j100
CC="gcc" CFLAGS="-Wall -O2 -I /usr/src/25/tools/testing/selftests/../../..  -isystem /usr/src/25/tools/testing/selftests/../../../usr/include -isystem /usr/src/25/tools/testing/selftests/../../../tools/include/uapi -Wunreachable-code -U_FORTIFY_SOURCE -no-pie -D_GNU_SOURCE= -I/usr/src/25/tools/testing/selftests/../../../tools/testing/selftests " ./check_config.sh
  CC       cow
  CC       compaction_test
  CC       gup_longterm
  CC       gup_test
  CC       hmm-tests
  CC       hugetlb-madvise
  CC       hugetlb-read-hwpoison
  CC       hugetlb-soft-offline
  CC       hugepage-mmap
  CC       hugepage-mremap
  CC       hugepage-shm
  CC       hugepage-vmemmap
  CC       khugepaged
  CC       madv_populate
  CC       map_fixed_noreplace
  CC       map_hugetlb
  CC       map_populate
  CC       memfd_secret
  CC       memory-failure
  CC       migration
  CC       mkdirty
  CC       mlock-random-test
  CC       mlock2-tests
  CC       mrelease_test
  CC       mremap_dontunmap
  CC       mremap_test
  CC       mseal_test
  CC       on-fault-limit
  CC       pagemap_ioctl
  CC       pfnmap
  CC       process_madv
  CC       prctl_thp_disable
  CC       thuge-gen
  CC       transhuge-stress
  CC       uffd-stress
  CC       uffd-unit-tests
  CC       uffd-wp-mremap
  CC       split_huge_page_test
  CC       ksm_tests
  CC       ksm_functional_tests
  CC       mdwe_test
  CC       hugetlb_fault_after_madv
  CC       hugetlb_madv_vs_map
  CC       hugetlb_dio
  CC       droppable
  CC       guard-regions
  CC       merge
  CC       rmap
  CC       folio_split_race_test
  CC       soft-dirty
  CC       protection_keys_32
  CC       pkey_sighandler_tests_32
  CC       protection_keys_64
  CC       pkey_sighandler_tests_64
  CC       va_high_addr_switch
  CC       write_to_hugetlbfs

Tested-by: Andrew Morton <akpm@linux-foundation.org>


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

* Re: [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds
  2026-03-31  4:01 ` [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds Li Wang
@ 2026-03-31  5:29   ` Andrew Morton
  2026-03-31  9:16     ` Li Wang
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Morton @ 2026-03-31  5:29 UTC (permalink / raw)
  To: Li Wang
  Cc: david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, shuah,
	linux-mm, linux-kselftest, linux-kernel

On Tue, 31 Mar 2026 12:01:54 +0800 Li Wang <liwang@redhat.com> wrote:

> 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 <akpm@linux-foundation.org>

Well, the wind changed direction.  I saw this race a single time today
but now I'm trying to produce a reliable before-and-after report, it
isn't cooperating - everything is now building with -j100 with and
without this patch.

So not very helpful, sorry.



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

* Re: [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path
  2026-03-31  4:01 ` [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path Li Wang
@ 2026-03-31  5:30   ` Andrew Morton
  2026-03-31  7:19     ` Li Wang
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Morton @ 2026-03-31  5:30 UTC (permalink / raw)
  To: Li Wang
  Cc: david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, shuah,
	linux-mm, linux-kselftest, linux-kernel

On Tue, 31 Mar 2026 12:01:55 +0800 Li Wang <liwang@redhat.com> wrote:

> When running selftests from the kernel top-level (e.g. make kselftest-all),
> sub-makes might still inherit the caller's PWD from the environment.
> 
> Some selftests use $(PWD) in recursive kbuild invocations, which can
> then incorrectly resolve to the kernel top directory instead of the
> current test directory.
> 
> In that case, kbuild may generate an external-module wrapper Makefile in
> the wrong location, potentially clobbering the top-level Makefile and
> causing recursive include failures ("Too many open files").
> 
> Export PWD := $(CURDIR) in selftests/lib.mk so $(PWD) always matches the
> actual current selftest directory.
> 
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Li Wang <liwang@redhat.com>

I couldn't clearly figure out what I was doing to cause kbuild to
destroy my top-level Makefile.  It happened three times and it wasn't
fun so I Stopped Doing That.  

I tried a bunch of things *without* this patch and of course, Makefile
is still intact.  So I cannot confirm or deny, sorry.

I've switched my script so I'll henceforth be running -j100, shall keep
an eye on things.

I have no comment on [4/4] - it addresses something I haven't seen.

I'll assume this patchset will be handled via the kbuild tree.

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

* Re: [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing
  2026-03-31  4:01 ` [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing Li Wang
@ 2026-03-31  7:13   ` Li Wang
  2026-04-01 13:44     ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 12+ messages in thread
From: Li Wang @ 2026-03-31  7:13 UTC (permalink / raw)
  To: akpm, david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	shuah
  Cc: linux-mm, linux-kselftest, linux-kernel

> --- a/tools/testing/selftests/mm/Makefile
> +++ b/tools/testing/selftests/mm/Makefile
> @@ -10,6 +10,11 @@ LOCAL_HDRS += $(selfdir)/mm/mseal_helpers.h
>  
>  include local_config.mk
>  
> +PKG_CONFIG ?= pkg-config
> +ifeq ($(IOURING_EXTRA_LIBS),)
> +IOURING_EXTRA_LIBS := $(shell $(PKG_CONFIG) --libs liburing 2>/dev/null)
> +endif
> +
>  ifeq ($(ARCH),)
>  
>  ifeq ($(CROSS_COMPILE),)
> @@ -55,10 +60,12 @@ else
>  PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first"
>  endif
>  
> -TEST_GEN_FILES = cow
> -TEST_GEN_FILES += compaction_test
> -TEST_GEN_FILES += gup_longterm
> +TEST_GEN_FILES = compaction_test
>  TEST_GEN_FILES += gup_test
> +ifneq ($(IOURING_EXTRA_LIBS),)
> +TEST_GEN_FILES += cow
> +TEST_GEN_FILES += gup_longterm
> +endif

Please ignore this one, as Sashiko points:

  "The io_uring specific test cases within them are already isolated via
  #ifdef LOCAL_CONFIG_HAVE_LIBURING and do not require liburing to compile the
  rest of the tests."

I overlooked that two tests can be built without liburing-devel pkg.
Sashiko is correct here, we don't need define IOURING_EXTRA_LIBS.

The compiling error comes from a temp file in check_config.sh, and I
am not sure whether we should hide the error:

/tmp/tmp.kIIOIqwe3n.c:2:10: fatal error: liburing.h: No such file or directory
    2 | #include <liburing.h>
      |          ^~~~~~~~~~~~


-- 
Regards,
Li Wang


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

* Re: [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path
  2026-03-31  5:30   ` Andrew Morton
@ 2026-03-31  7:19     ` Li Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Li Wang @ 2026-03-31  7:19 UTC (permalink / raw)
  To: Andrew Morton
  Cc: david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, shuah,
	linux-mm, linux-kselftest, linux-kernel

On Mon, Mar 30, 2026 at 10:30:25PM -0700, Andrew Morton wrote:
> On Tue, 31 Mar 2026 12:01:55 +0800 Li Wang <liwang@redhat.com> wrote:
> 
> > When running selftests from the kernel top-level (e.g. make kselftest-all),
> > sub-makes might still inherit the caller's PWD from the environment.
> > 
> > Some selftests use $(PWD) in recursive kbuild invocations, which can
> > then incorrectly resolve to the kernel top directory instead of the
> > current test directory.
> > 
> > In that case, kbuild may generate an external-module wrapper Makefile in
> > the wrong location, potentially clobbering the top-level Makefile and
> > causing recursive include failures ("Too many open files").
> > 
> > Export PWD := $(CURDIR) in selftests/lib.mk so $(PWD) always matches the
> > actual current selftest directory.
> > 
> > Reported-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Li Wang <liwang@redhat.com>
> 
> I couldn't clearly figure out what I was doing to cause kbuild to
> destroy my top-level Makefile.  It happened three times and it wasn't
> fun so I Stopped Doing That.  
> 
> I tried a bunch of things *without* this patch and of course, Makefile
> is still intact.  So I cannot confirm or deny, sorry.
> 
> I've switched my script so I'll henceforth be running -j100, shall keep
> an eye on things.

No problem, actually I wasn't able to reproduce it, the patch just worked
out based on your description. We can kick out it from patchset unless
someone confirm it is needed.

-- 
Regards,
Li Wang


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

* Re: [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds
  2026-03-31  5:29   ` Andrew Morton
@ 2026-03-31  9:16     ` Li Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Li Wang @ 2026-03-31  9:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, shuah,
	linux-mm, linux-kselftest, linux-kernel

On Mon, Mar 30, 2026 at 10:29:48PM -0700, Andrew Morton wrote:
> On Tue, 31 Mar 2026 12:01:54 +0800 Li Wang <liwang@redhat.com> wrote:
> 
> > 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 <akpm@linux-foundation.org>
> 
> Well, the wind changed direction.  I saw this race a single time today
> but now I'm trying to produce a reliable before-and-after report, it
> isn't cooperating - everything is now building with -j100 with and
> without this patch.
> 
> So not very helpful, sorry.

No worries, we can hang this one as well.

Let me send to kbuild ML with the two valid fix (1/4, 4/4),
I will reformat them.

-- 
Regards,
Li Wang


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

* Re: [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets
  2026-03-31  5:29 ` [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Andrew Morton
@ 2026-03-31  9:50   ` Li Wang
  0 siblings, 0 replies; 12+ messages in thread
From: Li Wang @ 2026-03-31  9:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: david, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, shuah,
	linux-mm, linux-kselftest, linux-kernel, linux-kbuild

> > Reported-by: Andrew Morton <akpm@linux-foundation.org>
> 
> wow, thanks, do you want my credit card number?

Only if you want me to add a Funded-by: tag to the commit message. :)

> Tested-by: Andrew Morton <akpm@linux-foundation.org>

Thank you for testing!

-- 
Regards,
Li Wang


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

* Re: [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing
  2026-03-31  7:13   ` Li Wang
@ 2026-04-01 13:44     ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 12+ messages in thread
From: David Hildenbrand (Arm) @ 2026-04-01 13:44 UTC (permalink / raw)
  To: Li Wang, akpm, ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	shuah
  Cc: linux-mm, linux-kselftest, linux-kernel

On 3/31/26 09:13, Li Wang wrote:
>> --- a/tools/testing/selftests/mm/Makefile
>> +++ b/tools/testing/selftests/mm/Makefile
>> @@ -10,6 +10,11 @@ LOCAL_HDRS += $(selfdir)/mm/mseal_helpers.h
>>  
>>  include local_config.mk
>>  
>> +PKG_CONFIG ?= pkg-config
>> +ifeq ($(IOURING_EXTRA_LIBS),)
>> +IOURING_EXTRA_LIBS := $(shell $(PKG_CONFIG) --libs liburing 2>/dev/null)
>> +endif
>> +
>>  ifeq ($(ARCH),)
>>  
>>  ifeq ($(CROSS_COMPILE),)
>> @@ -55,10 +60,12 @@ else
>>  PAGE_FRAG_WARNING = "missing Module.symvers, please have the kernel built first"
>>  endif
>>  
>> -TEST_GEN_FILES = cow
>> -TEST_GEN_FILES += compaction_test
>> -TEST_GEN_FILES += gup_longterm
>> +TEST_GEN_FILES = compaction_test
>>  TEST_GEN_FILES += gup_test
>> +ifneq ($(IOURING_EXTRA_LIBS),)
>> +TEST_GEN_FILES += cow
>> +TEST_GEN_FILES += gup_longterm
>> +endif
> 
> Please ignore this one, as Sashiko points:

Right, this should be dropped.

-- 
Cheers,

David

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

end of thread, other threads:[~2026-04-01 13:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31  4:01 [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Li Wang
2026-03-31  4:01 ` [PATCH 2/4] selftests/mm: serialize local_config generation for parallel builds Li Wang
2026-03-31  5:29   ` Andrew Morton
2026-03-31  9:16     ` Li Wang
2026-03-31  4:01 ` [PATCH 3/4] selftests/lib.mk: set PWD from CURDIR to avoid wrong extmod path Li Wang
2026-03-31  5:30   ` Andrew Morton
2026-03-31  7:19     ` Li Wang
2026-03-31  4:01 ` [PATCH 4/4] selftests/mm: fix cow/gup_longterm link failures when liburing flags are missing Li Wang
2026-03-31  7:13   ` Li Wang
2026-04-01 13:44     ` David Hildenbrand (Arm)
2026-03-31  5:29 ` [PATCH 1/4] selftests/mm: respect build verbosity settings for 32/64-bit targets Andrew Morton
2026-03-31  9:50   ` Li Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox