support kselftest on nommu platform
Subsystems (7)
v2 cover support kselftest on nommu platform
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.
The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2). timeout command used in runner.sh never works for nommu platform as it uses fork(2).
nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (Documentation/admin-guide/mm/nommu-mmap.rst).
So, for the first step, nommu targets only support low-level API of kselftests (kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.
The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/
Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior tests
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++ 8 files changed, 659 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/mm/nommu/Makefile create mode 100644 tools/testing/selftests/mm/nommu/nommu_mmap_test.c create mode 100644 tools/testing/selftests/mm/nommu/nommu_mremap_test.c
base-commit: 55b50d965aee5f66cefe4dde3907a0e272f96b91
Signature · 1 line
2.43.0
PATCH v2 1/2 selftests: run tests on nommu architecture
Architectures lacks MMU doesn't support fork(2) syscall and only vfork(2) is available with limitations. Thus, we cannot run kselftest on nommu architecture as is.
This commit addresses this issue with the following changes:
- on build stage, add -DCONFIG_NOMMU to CFLAGS when NOMMU=1 variable added to the build/make argument.
- on test run stage, avoid calling timeout command when NOMMU=1 variable added to environmental variable, since timeout command uses fork syscall which nommu platform doesn't support.
- kselftest_harness.h: skip the tests if the file is include when executing on NOMMU platform, as there is no fork(2) syscall.
- replace "cd -" use as it is not available a shell supported on nommu (e.g., busybox hush), use cd "$OLDDIR" instead.
- describe the difference of nommu tests in the document.
So command line to build/execute tests for nommu should be like below:
$ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=mm/nommu $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=mm/nommu $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p \ -c mm/nommu
--
rfc => v2
- reformat ktap header, reported by Sashiko review
rfc: https://lore.kernel.org/linux-mm/[email protected]/
--- Documentation/dev-tools/kselftest.rst | 14 ++++++++++++++ tools/testing/selftests/kselftest/runner.sh | 9 +++++++-- tools/testing/selftests/kselftest_harness.h | 4 ++++ tools/testing/selftests/lib.mk | 8 ++++++++ 4 files changed, 33 insertions(+), 2 deletions(-)
Documentation/dev-tools/kselftest.rst +14 -0
@@ -230,6 +230,20 @@ section:: .. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress +Build and test on nommu target +============================== + +If you (cross-)build kselftests for nommu targets, or run tests on nommu targets, use +``NOMMU=1`` as a make variable/environment setting to tell build system to do the additional +checks. These nommu targets may differ in several ways, such as not supporting fork(2) or +using musl or another libc. Set this variable to apply the necessary build and test adjustments. + +:: + + $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=mm/nommu # <= build-only + $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=mm/nommu + $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p -c mm/nommu + Contributing new tests ======================
tools/testing/selftests/kselftest/runner.sh +7 -2
@@ -38,8 +38,12 @@ tap_prefix() tap_timeout() { + # nommu doesn't support timeout command (missing fork(2)) + if [ "$NOMMU" = "1" ] ; then + echo "timeout isn't supported for nommu" + $1 # Make sure tests will time out if utility is available. - if [ -x /usr/bin/timeout ] ; then + elif [ -x /usr/bin/timeout ] ; then /usr/bin/timeout --foreground "$kselftest_timeout" \ /usr/bin/timeout "$kselftest_timeout" $1 else
@@ -130,6 +134,7 @@ run_one() return $KSFT_FAIL fi fi + OLDDIR=$(pwd) cd `dirname $TEST` > /dev/null (((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) |
@@ -147,7 +152,7 @@ run_one() *) ktap_test_fail "$TEST_HDR_MSG # exit=$rc";; esac - cd - >/dev/null + cd "$OLDDIR" >/dev/null fi return $rc
tools/testing/selftests/kselftest_harness.h +4 -0
@@ -1274,6 +1274,10 @@ static int test_harness_run(int argc, char **argv)unsigned int count =0 ;unsigned int pass_count =0 ; +#ifdef CONFIG_NOMMU +ksft_print_header (); +ksft_exit_skip ("kselftest harness requires fork(2), unavailable on NOMMU\n" ); +#endif /* CONFIG_NOMMU */ ret =test_harness_argv_check (argc, argv);if (ret !=KSFT_PASS )return ret;
tools/testing/selftests/lib.mk +8 -0
@@ -97,6 +97,14 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +# detect if users request NOMMU build or not +# User can set NOMMU to 1 to build/test for NOMMU platforms +NOMMU ?= 0 +ifeq ($(NOMMU),1) +CFLAGS += -DCONFIG_NOMMU +export NOMMU +endif + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \ $(if $(TEST_GEN_MODS_DIR),gen_mods_dir)
Signature · 1 line
2.43.0
Lorenzo Stoakes (ARM)
reviewerRe: [PATCH v2 1/2] selftests: run tests on nommu architecture
Quoted 24 lines · Hajime Tazaki
Architectures lacks MMU doesn't support fork(2) syscall and only vfork(2) is available with limitations. Thus, we cannot run kselftest on nommu architecture as is.
This commit addresses this issue with the following changes:
- on build stage, add -DCONFIG_NOMMU to CFLAGS when NOMMU=1 variable added to the build/make argument.
- on test run stage, avoid calling timeout command when NOMMU=1 variable added to environmental variable, since timeout command uses fork syscall which nommu platform doesn't support.
-kselftest_harness.h: skip the tests if the file is include when executing on NOMMU platform, as there is no fork(2) syscall.
- replace "cd -" use as it is not available a shell supported on nommu (e.g., busybox hush), use cd "$OLDDIR" instead.
- describe the difference of nommu tests in the document.So command line to build/execute tests for nommu should be like below:
$ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=mm/nommu $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=mm/nommu $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p \ -c mm/nommu
Quoted 15 lines
Cc Shuah Khan <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Kees Cook <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Will Drewry <[email protected]>Cc Mark Brown <[email protected]>Cc Brendan Jackman <[email protected]>Cc Hangbin Liu <[email protected]>Cc "Ricardo B. Marliere" <[email protected]>Signed-off-by Hajime Tazaki <[email protected]>
Doesn't seem too crazy, but some nitty comments below.
Quoted 66 lines
--
rfc => v2
- reformat ktap header, reported by Sashiko reviewrfc: https://lore.kernel.org/linux-mm/[email protected]/
--- Documentation/dev-tools/kselftest.rst | 14 ++++++++++++++ tools/testing/selftests/kselftest/runner.sh | 9 +++++++-- tools/testing/selftests/kselftest_harness.h | 4 ++++ tools/testing/selftests/lib.mk | 8 ++++++++ 4 files changed, 33 insertions(+), 2 deletions(-)Documentation/dev-tools/kselftest.rst +14
-0@@ -230,6 +230,20 @@ section:: .. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress +Build and test on nommu target +============================== + +If you (cross-)build kselftests for nommu targets, or run tests on nommu targets, use +``NOMMU=1`` as a make variable/environment setting to tell build system to do the additional +checks. These nommu targets may differ in several ways, such as not supporting fork(2) or +using musl or another libc. Set this variable to apply the necessary build and test adjustments. + +:: + + $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=mm/nommu # <= build-only + $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=mm/nommu + $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p -c mm/nommu + Contributing new tests ======================tools/testing/selftests/kselftest/runner.sh +6
-1@@ -38,8 +38,12 @@ tap_prefix() tap_timeout() { + # nommu doesn't support timeout command (missing fork(2)) + if [ "$NOMMU" = "1" ] ; then + echo "timeout isn't supported for nommu" + $1 # Make sure tests will time out if utility is available. - if [ -x /usr/bin/timeout ] ; then + elif [ -x /usr/bin/timeout ] ; then /usr/bin/timeout --foreground "$kselftest_timeout" \ /usr/bin/timeout "$kselftest_timeout" $1 else@@ -130,6 +134,7 @@ run_one() return $KSFT_FAIL fi fi + OLDDIR=$(pwd) cd `dirname $TEST` > /dev/null (((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) |
tools/testing/selftests/kselftest/runner.sh run_one() · line 155
Quoted 5 lines
tools/testing/selftests/kselftest/runner.sh +1
-1@@ -147,7 +152,7 @@ run_one() *) ktap_test_fail "$TEST_HDR_MSG # exit=$rc";; esac - cd - >/dev/null + cd "$OLDDIR" >/dev/null
Hmm, why are you changing this bit?
tools/testing/selftests/kselftest_harness.h static int test_harness_run(int argc, char **argv) · line 1277
Quoted 12 lines
tools/testing/selftests/kselftest/runner.sh +0
-0fi return $rctools/testing/selftests/kselftest_harness.h +1
-0@@ -1274,6 +1274,10 @@ static int test_harness_run(int argc, char **argv)unsigned int count =0 ;unsigned int pass_count =0 ; +#ifdef CONFIG_NOMMU
Let's not prefix with CONFIG_ :) I think this is pretty confusing vs. the kernel CONFIG_xxx flags, esp. as this obviously inverts CONFIG_MMU.
maybe just 'NOMMU'?
Quoted 12 lines
tools/testing/selftests/kselftest_harness.h +3
-0+ksft_print_header (); +ksft_exit_skip ("kselftest harness requires fork(2), unavailable on NOMMU\n" ); +#endif /* CONFIG_NOMMU */ ret =test_harness_argv_check (argc, argv);if (ret !=KSFT_PASS )return ret;tools/testing/selftests/lib.mk +0
-0@@ -97,6 +97,14 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
tools/testing/selftests/lib.mk TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) · line 107
Quoted 10 lines
tools/testing/selftests/lib.mk +8
-0TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +# detect if users request NOMMU build or not +# User can set NOMMU to 1 to build/test for NOMMU platforms +NOMMU ?= 0 +ifeq ($(NOMMU),1) +CFLAGS += -DCONFIG_NOMMU +export NOMMU +endif +
I wonder if this could be put into testing/selftests/nommu/something.mk? Though I guess would have to be included for all builds to account for nommu trying to build any kind of tests.
Quoted 6 lines
tools/testing/selftests/lib.mk +0
-1all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) \ $(if $(TEST_GEN_MODS_DIR),gen_mods_dir) --2.43.0
--
Cheers, Lorenzo
Re: [PATCH v2 1/2] selftests: run tests on nommu architecture
Hello,
Quoted 26 lines · Lorenzo Stoakes (ARM)
Quoted 26 lines
tools/testing/selftests/kselftest/runner.sh +6
-1@@ -38,8 +38,12 @@ tap_prefix() tap_timeout() { + # nommu doesn't support timeout command (missing fork(2)) + if [ "$NOMMU" = "1" ] ; then + echo "timeout isn't supported for nommu" + $1 # Make sure tests will time out if utility is available. - if [ -x /usr/bin/timeout ] ; then + elif [ -x /usr/bin/timeout ] ; then /usr/bin/timeout --foreground "$kselftest_timeout" \ /usr/bin/timeout "$kselftest_timeout" $1 else@@ -130,6 +134,7 @@ run_one() return $KSFT_FAIL fi fi + OLDDIR=$(pwd) cd `dirname $TEST` > /dev/null (((( tap_timeout "$cmd" 2>&1; echo $? >&3) | tap_prefix >&4) 3>&1) |
Quoted 8 lines
tools/testing/selftests/kselftest/runner.sh run_one() · line 155
Quoted 6 lines
tools/testing/selftests/kselftest/runner.sh +1
-1@@ -147,7 +152,7 @@ run_one() *) ktap_test_fail "$TEST_HDR_MSG # exit=$rc";; esac - cd - >/dev/null + cd "$OLDDIR" >/dev/nullHmm, why are you changing this bit?
on nommu we cannot use /bin/bash (i.e., no fork(2) so, we use /bin/hash, a busybox-offered shell with vfork.
with this cd - (standards specified) isn't implemented due to slim requirement of that shell (I suppose, miserable...).
thus this workaround.
Quoted 11 lines
Quoted 11 lines
tools/testing/selftests/kselftest/runner.sh +0
-0fi return $rctools/testing/selftests/kselftest_harness.h +0
-0@@ -1274,6 +1274,10 @@ static int test_harness_run(int argc, char **argv)unsigned int count =0 ;unsigned int pass_count =0 ;
Quoted 6 lines
tools/testing/selftests/kselftest_harness.h static int test_harness_run(int argc, char **argv) · line 1277
Quoted 1 line
tools/testing/selftests/kselftest_harness.h +1
-0+#ifdef CONFIG_NOMMU Let's not prefix with
CONFIG_:) I think this is pretty confusing vs. the kernelCONFIG_xxxflags, esp. as this obviously invertsCONFIG_MMU.maybe just 'NOMMU'?
thanks, I will remove CONFIG_ part.
initially I was trying to pull generated/autoconf.h into kselftest but it doesn't do much compared to many modifications (run_kselftest.sh needs to run independently from build tree) so, I used this macro but, yes, it's confusing.
Quoted 14 lines
Quoted 14 lines
tools/testing/selftests/kselftest_harness.h +3
-0+ksft_print_header (); +ksft_exit_skip ("kselftest harness requires fork(2), unavailable on NOMMU\n" ); +#endif /* CONFIG_NOMMU */ ret =test_harness_argv_check (argc, argv);if (ret !=KSFT_PASS )return ret;tools/testing/selftests/lib.mk +0
-0@@ -97,6 +97,14 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
Quoted 12 lines
tools/testing/selftests/lib.mk TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) · line 107
Quoted 8 lines
tools/testing/selftests/lib.mk +8
-0+# detect if users request NOMMU build or not +# User can set NOMMU to 1 to build/test for NOMMU platforms +NOMMU ?= 0 +ifeq ($(NOMMU),1) +CFLAGS += -DCONFIG_NOMMU +export NOMMU +endif +I wonder if this could be put into
testing/selftests/nommu/something.mk? Though I guess would have to be included for all builds to account for nommu trying to build any kind of tests.
yes, in addition to moving to selftests/nommu this can be more cleaner initial introduction of this target.
thanks for reviewing.
-- Hajime
Re: [PATCH v2 1/2] selftests: run tests on nommu architecture
Quoted 8 lines · Hajime Tazaki
Quoted 5 lines · Lorenzo Stoakes (ARM)
tools/testing/selftests/kselftest/runner.sh run_one() · line 155
Quoted 3 lines
tools/testing/selftests/kselftest/runner.sh +1
-1esac - cd - >/dev/null + cd "$OLDDIR" >/dev/nullHmm, why are you changing this bit?
Quoted 6 lines
on nommu we cannot use
/bin/bash(i.e., no fork(2) so, we use/bin/hash, a busybox-offered shell with vfork.
with thiscd -(standards specified) isn't implemented due to slim requirement of that shell (I suppose, miserable...).thus this workaround.
It'd probably be good to have this as a separate commit with a changelog explaining what's going on, it'll make review easier if nothing else.
PATCH v2 2/2 selftests/mm: add nommu mmap and mremap behavior tests
In reply to Hajime TazakiIntroduce a kselftest utility to validate memory mapping capabilities under nommu kernels, aligned with Documentation/admin-guide/mm/nommu-mmap.rst.
The test implements basic checks into a generic architecture-agnostic test matrix applicable across nommu targets. It evaluates:
1. MAP_FIXED allocation rejections.
2. Standard MAP_PRIVATE and MAP_ANONYMOUS allocation resilience.
3. Regular file mappings via standard filesystem storage.
4. Block device subsystem mappings (gracefully skipping if node is missing).
5. Shared vs Private backing discrepancies under nommu conditions.
6. mremap limits, ensuring non-expandable restrictions behave properly.
--
rfc => v2
- prepare a different TARGETS for tests (mm/nommu)
- drop shrink fix tests
- drop mmap /dev/zero tests
rfc:
- https://lore.kernel.org/linux-mm/[email protected]/
--- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++ 4 files changed, 626 insertions(+) create mode 100644 tools/testing/selftests/mm/nommu/Makefile create mode 100644 tools/testing/selftests/mm/nommu/nommu_mmap_test.c create mode 100644 tools/testing/selftests/mm/nommu/nommu_mremap_test.c
tools/testing/selftests/Makefile +1 -0
@@ -135,6 +135,7 @@ TARGETS += uevent TARGETS += user_events TARGETS += vDSO TARGETS += mm +TARGETS += mm/nommu TARGETS += vfio TARGETS += x86 TARGETS += x86/bugs
tools/testing/selftests/mm/nommu/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for mm/nommu selftests + +TEST_GEN_PROGS += nommu_mmap_test +TEST_GEN_PROGS += nommu_mremap_test + +include ../../lib.mk
tools/testing/selftests/mm/nommu/nommu_mmap_test.c new file +265 -0
265 lines not on this page · raw message
tools/testing/selftests/mm/nommu/nommu_mremap_test.c new file +353 -0
353 lines not on this page · raw message
Signature · 1 line
2.43.0
David Hildenbrand (Arm)
maintainerQuoted 43 lines · Hajime Tazaki
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (
kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2).timeoutcommand used inrunner.shnever works for nommu platform as it uses fork(2).nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (
Documentation/admin-guide/mm/nommu-mmap.rst).So, for the first step, nommu targets only support low-level API of kselftests (
kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior tests
Quoted 8 lines
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++
That's odd.
tools/testing/selftests/mm
itself should know which tests can be built and ran on nommu. nommu-only tests can be placed in mm/nommu, but I would expect tools/testing/selftests/mm's Makefile and run script to compile and run only selftests that are supported on the given platform.
Signature · 3 lines
Cheers, David
Lorenzo Stoakes (ARM)
reviewerQuoted 53 lines · David Hildenbrand (Arm)
Quoted 43 lines · Hajime Tazaki
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (
kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2).timeoutcommand used inrunner.shnever works for nommu platform as it uses fork(2).nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (
Documentation/admin-guide/mm/nommu-mmap.rst).So, for the first step, nommu targets only support low-level API of kselftests (
kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior testsQuoted 8 lines
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++
Quoted 8 lines
That's odd.
tools/testing/selftests/mmitself should know which tests can be built and ran on nommu. nommu-only tests can be placed in mm/nommu, but I would expect tools/testing/selftests/mm's
Makefileand run script to compile and run only selftests that are supported on the given platform.
I mean I think at this point with mm/nommu/nommu_xxx.c it'd make more sense to simply have selftests/nommu/ + update the mm makefile to not build stuff that's broken on nommu there.
That way positively nommu-stuff is put in its own place and what's broken on mm specific to nommu can be fixed there.
I'd rather isolate them clearly rather than having them live in a subdirectory of mm.
Quoted 5 lines
--
Cheers,David
--
Cheers, Lorenzo
David Hildenbrand (Arm)
maintainerQuoted 67 lines · Lorenzo Stoakes (ARM)
Quoted 53 lines · David Hildenbrand (Arm)
Quoted 43 lines · Hajime Tazaki
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (
kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2).timeoutcommand used inrunner.shnever works for nommu platform as it uses fork(2).nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (
Documentation/admin-guide/mm/nommu-mmap.rst).So, for the first step, nommu targets only support low-level API of kselftests (
kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior testsQuoted 8 lines
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++Quoted 8 lines
That's odd.
tools/testing/selftests/mmitself should know which tests can be built and ran on nommu. nommu-only tests can be placed in mm/nommu, but I would expect tools/testing/selftests/mm's
Makefileand run script to compile and run only selftests that are supported on the given platform.I mean I think at this point with
mm/nommu/nommu_xxx.cit'd make more sense to simply have selftests/nommu/ + update the mm makefile to not build stuff that's broken on nommu there.
Quoted 5 lines
That way positively nommu-stuff is put in its own place and what's broken on mm specific to nommu can be fixed there.
I'd rather isolate them clearly rather than having them live in a subdirectory of mm.
My understanding is that some MM tests could be enabled/changed in the future that support both MMU and NOMMU. Not sure how to best handle that.
So wiring up mm/nommu as a separate thing did sound wrong to me. So it should either be integrated or the tests in fact completely moved out of mm/
Signature · 3 lines
Cheers, David
Lorenzo Stoakes (ARM)
reviewerQuoted 68 lines · David Hildenbrand (Arm)
Quoted 67 lines · Lorenzo Stoakes (ARM)
Quoted 53 lines · David Hildenbrand (Arm)
Quoted 43 lines · Hajime Tazaki
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (
kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2).timeoutcommand used inrunner.shnever works for nommu platform as it uses fork(2).nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (
Documentation/admin-guide/mm/nommu-mmap.rst).So, for the first step, nommu targets only support low-level API of kselftests (
kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior testsQuoted 8 lines
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++Quoted 8 lines
That's odd.
tools/testing/selftests/mmitself should know which tests can be built and ran on nommu. nommu-only tests can be placed in mm/nommu, but I would expect tools/testing/selftests/mm's
Makefileand run script to compile and run only selftests that are supported on the given platform.I mean I think at this point with
mm/nommu/nommu_xxx.cit'd make more sense to simply have selftests/nommu/ + update the mm makefile to not build stuff that's broken on nommu there.
Quoted 8 lines
Quoted 5 lines
That way positively nommu-stuff is put in its own place and what's broken on mm specific to nommu can be fixed there.
I'd rather isolate them clearly rather than having them live in a subdirectory of mm.
My understanding is that some MM tests could be enabled/changed in the future that support both MMU and NOMMU. Not sure how to best handle that.
Well by default won't everything run? And it becomes a list of what doesn't work with nommu?
I really don't want to see any maintainership burden or extra work added for nommu as it's afaic deprecated.
Quoted 3 lines
So wiring up mm/nommu as a separate thing did sound wrong to me. So it should either be integrated or the tests in fact completely moved out of
mm/
Not integrated, because then it starts adding work for people. I'd rather have separate nommu tests, any mm tests that aren't compatible with nommu can just be somehow excluded.
Having a 'don't run on nommu' or even just some means of setting which tests to skip (I think Mark Brown suggested as much in reply to an earlier version of the series) seems a good idea.
But yeah, tools/testing/selftests/nommu seems the best place for the nommu-specific stuff.
Can maybe do some ../mm/ horror show thing for reducing duplication as needed...
Quoted 5 lines
--
Cheers,David
--
Cheers, Lorenzo
Hello David, Lorenzo,
Quoted 97 lines · Lorenzo Stoakes (ARM)
Quoted 68 lines · David Hildenbrand (Arm)
Quoted 67 lines · Lorenzo Stoakes (ARM)
Quoted 53 lines · David Hildenbrand (Arm)
Quoted 43 lines · Hajime Tazaki
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (
kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2).timeoutcommand used inrunner.shnever works for nommu platform as it uses fork(2).nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (
Documentation/admin-guide/mm/nommu-mmap.rst).So, for the first step, nommu targets only support low-level API of kselftests (
kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior testsQuoted 8 lines
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++Quoted 8 lines
That's odd.
tools/testing/selftests/mmitself should know which tests can be built and ran on nommu. nommu-only tests can be placed in mm/nommu, but I would expect tools/testing/selftests/mm's
Makefileand run script to compile and run only selftests that are supported on the given platform.I mean I think at this point with
mm/nommu/nommu_xxx.cit'd make more sense to simply have selftests/nommu/ + update the mm makefile to not build stuff that's broken on nommu there.Quoted 8 lines
Quoted 5 lines
That way positively nommu-stuff is put in its own place and what's broken on mm specific to nommu can be fixed there.
I'd rather isolate them clearly rather than having them live in a subdirectory of mm.
My understanding is that some MM tests could be enabled/changed in the future that support both MMU and NOMMU. Not sure how to best handle that.
Well by default won't everything run? And it becomes a list of what doesn't work with nommu?
I really don't want to see any maintainership burden or extra work added for nommu as it's afaic deprecated.
Quoted 3 lines
So wiring up mm/nommu as a separate thing did sound wrong to me. So it should either be integrated or the tests in fact completely moved out of
mm/Not integrated, because then it starts adding work for people. I'd rather have separate nommu tests, any mm tests that aren't compatible with nommu can just be somehow excluded.
Having a 'don't run on nommu' or even just some means of setting which tests to skip (I think Mark Brown suggested as much in reply to an earlier version of the series) seems a good idea.
Quoted 5 lines
But yeah,
tools/testing/selftests/nommuseems the best place for the nommu-specific stuff.Can maybe do some ../mm/ horror show thing for reducing duplication as needed...
As David mentioned my goal is to run all selftests/mm tests on nommu, but as I explained situation to Lorenzo, it currently doesn't any tests of mm/ on nommu platform (plus cannot build).
so I'd like to start as minimum as possible for this patchset, thus creating different TARGET at mm/nommu, which I thought it should no harm to the parent directory.
But I can move from selftests/mm/nommu to selftests/nommu for now, and will propose to move into mm/nommu once it will be more meaningful to do so.
# btw, I started to looking at code toward virtual mmu; I cannot tell
how it'll be tho now.
-- Hajime
Lorenzo Stoakes (ARM)
reviewerQuoted 112 lines · Hajime Tazaki
Hello David, Lorenzo,
Quoted 97 lines · Lorenzo Stoakes (ARM)
Quoted 68 lines · David Hildenbrand (Arm)
Quoted 67 lines · Lorenzo Stoakes (ARM)
Quoted 53 lines · David Hildenbrand (Arm)
Quoted 43 lines · Hajime Tazaki
We add an ability to execute kselftest on nommu platforms.
Currently there are several issues if we wish to run kselftests on nommu targets:
- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.
The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (
kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2).timeoutcommand used inrunner.shnever works for nommu platform as it uses fork(2).nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (
Documentation/admin-guide/mm/nommu-mmap.rst).So, for the first step, nommu targets only support low-level API of kselftests (
kselftest.h), and implement tests in a new target, TARGETS=mm/nommu. Other targets are currently not even able to build due to toolchain issues but will be addressed once the initial introduction which mainly focuses on nommu test will be settled.The patch was initially combined with other patches but is decoupled to only focus on test framework and testcases.
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/Hajime Tazaki (2):
selftests: run tests on nommu architecture selftests/mm: add nommu mmap and mremap behavior testsQuoted 8 lines
Documentation/dev-tools/kselftest.rst | 14 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/kselftest/runner.sh | 9 +- tools/testing/selftests/kselftest_harness.h | 4 + tools/testing/selftests/lib.mk | 8 + tools/testing/selftests/mm/nommu/Makefile | 7 + .../selftests/mm/nommu/nommu_mmap_test.c | 265 +++++++++++++ .../selftests/mm/nommu/nommu_mremap_test.c | 353 ++++++++++++++++++Quoted 8 lines
That's odd.
tools/testing/selftests/mmitself should know which tests can be built and ran on nommu. nommu-only tests can be placed in mm/nommu, but I would expect tools/testing/selftests/mm's
Makefileand run script to compile and run only selftests that are supported on the given platform.I mean I think at this point with
mm/nommu/nommu_xxx.cit'd make more sense to simply have selftests/nommu/ + update the mm makefile to not build stuff that's broken on nommu there.Quoted 8 lines
Quoted 5 lines
That way positively nommu-stuff is put in its own place and what's broken on mm specific to nommu can be fixed there.
I'd rather isolate them clearly rather than having them live in a subdirectory of mm.
My understanding is that some MM tests could be enabled/changed in the future that support both MMU and NOMMU. Not sure how to best handle that.
Well by default won't everything run? And it becomes a list of what doesn't work with nommu?
I really don't want to see any maintainership burden or extra work added for nommu as it's afaic deprecated.
Quoted 3 lines
So wiring up mm/nommu as a separate thing did sound wrong to me. So it should either be integrated or the tests in fact completely moved out of
mm/Not integrated, because then it starts adding work for people. I'd rather have separate nommu tests, any mm tests that aren't compatible with nommu can just be somehow excluded.
Having a 'don't run on nommu' or even just some means of setting which tests to skip (I think Mark Brown suggested as much in reply to an earlier version of the series) seems a good idea.
Quoted 5 lines
But yeah,
tools/testing/selftests/nommuseems the best place for the nommu-specific stuff.Can maybe do some ../mm/ horror show thing for reducing duplication as needed...
As David mentioned my goal is to run all selftests/mm tests on nommu, but as I explained situation to Lorenzo, it currently doesn't any tests of
mm/on nommu platform (plus cannot build).
Quoted 7 lines
so I'd like to start as minimum as possible for this patchset, thus creating different TARGET at mm/nommu, which I thought it should no harm to the parent directory.
But I can move from selftests/mm/nommu to selftests/nommu for now, and will propose to move into mm/nommu once it will be more meaningful to do so.
OK ack I will look for the respin! Thanks for the work on this!
Hopefully the push back is clear in that it's motivated by technical and architectural concerns, your contributions are all appreciated and thank you for doing the actual work rather than just talking about nommu, this is great :)
Quoted 3 lines
# btw, I started to looking at code toward virtual mmu; I cannot tell
how it'll be tho now.
Oh nice thanks :)
BTW did
https://lore.kernel.org/all/[email protected]/
go upstream? Or another UML nommu mode? I've not been keeping track of all that.
Quoted 3 lines
-- Hajime
--
Cheers, Lorenzo
Quoted 4 lines · Lorenzo Stoakes (ARM)
BTW did
https://lore.kernel.org/all/[email protected]/
go upstream? Or another UML nommu mode? I've not been keeping track of all that.
The current consensus (IIUC) is above Johannes's patches are in progress. Another mode which I was originally proposed is postponed in order to minimize the impact to UM tree.
-- Hajime
Lorenzo Stoakes (ARM)
reviewerQuoted 4 lines · Hajime Tazaki
On Thu, 27 Aug 2026 17:49:58 +0900,
Lorenzo Stoakes (ARM) wrote:
Quoted 8 lines
Quoted 4 lines
BTW did
https://lore.kernel.org/all/[email protected]/
go upstream? Or another UML nommu mode? I've not been keeping track of all that.The current consensus (IIUC) is above Johannes's patches are in progress. Another mode which I was originally proposed is postponed in order to minimize the impact to UM tree.
Ah ok cool, thanks! Is that headed to 7.3 or more like 7.4?
Quoted 3 lines
-- Hajime
--
Cheers, Lorenzo
Johannes Berg
maintainerQuoted 2 lines · Lorenzo Stoakes (ARM)
Ah ok cool, thanks! Is that headed to 7.3 or more like 7.4?
Seems everyone was on vacation (I just got back) so I believe it missed 7.3 since -rc1 is just out.
I hope to have enough time in this development period to the merge window to figure out all of these things and get stuff merged - UM wasn't on my priority list with all the (LLM) security(-ish) stuff going on in wireless.
johannes
Lorenzo Stoakes (ARM)
reviewerQuoted 6 lines · Johannes Berg
Quoted 2 lines · Lorenzo Stoakes (ARM)
Ah ok cool, thanks! Is that headed to 7.3 or more like 7.4?
Seems everyone was on vacation (I just got back) so I believe it missed 7.3 since -rc1 is just out.
Ah damn! But understood.
Quoted 3 lines
I hope to have enough time in this development period to the merge window to figure out all of these things and get stuff merged - UM
Ah that'd be great!
Quoted 2 lines
wasn't on my priority list with all the (LLM) security(-ish) stuff going on in wireless.
Yeah entirely understandable, I think we're all being pummelled by AI lately :)
Quoted 2 lines
johannes
--
Cheers, Lorenzo