From: Hajime Tazaki <thehajime@gmail.com>
To: linux-mm@kvack.org
Cc: geert@linux-m68k.org, daniel@thingy.jp,
Hajime Tazaki <thehajime@gmail.com>
Subject: [RFC PATCH 0/6] fix nommu mmap and add nommu kselftests
Date: Thu, 13 Aug 2026 15:33:55 +0900 [thread overview]
Message-ID: <20260813063401.1786548-1-thehajime@gmail.com> (raw)
This patchset fixes several issues on nommu mmap, munmap, and mremap
syscalls and add test cases on kselftests framework, which currently not
runnable on nommu platform.
Fixes for nommu is to correctly handle error cases when vma shrink
happens, and add calling .mmap_prepare callback on private mapping
requests to fix the issue which we cannot MAP_PRIVATE /dev/zero file.
One thing that I'd like to broadly ask you (thus this marks as RFC) is:
this fix contains a dirty check of /dev/zero using device type number.
Since mmap_zero_prepare() should be called before actual mapping, but
some of the .mmap_prepare handler should be called _after_
determine_vm_flags() as the .mmap_prepare handler checks the shared
flags, we cannot use vma_is_anonymous() in determine_vm_flags() to
check the file is /dev/zero or not. So we introduced
is_file_anonymous() for that purpose, which I'd like to ask your inputs.
And we add test cases to introduce kselftest for 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 can be simply avoided, at a glance, by globally
replacing the symbol `fork` with `vfork`, which is available on nommu
targets. Especially the test harness helper (kselftest_harness.h) uses
fork(2). But the issue is not simple: for instance, in vfork(2) case
parent process has to wait until children has done jobs, parent and
children share the memory and children may corrupt parent memory which
is never happened with fork(2) syscall. `timeout` command used in
`runner.sh` never works for nommu platform as it uses fork(2).
Additionally, the lack of test cases for nommu environment will (or
already) become serious issues to maintain the codebase in the future.
The test cases is implemented based on the document
(Documentation/admin-guide/mm/nommu-mmap.rst). The test programs is
implemented with the assist of LLM.
So, for the first step, nommu targets only support low-level API of
kselftests (kselftest.h), and not supporting the harness tests since it
uses fork(2) syscall. This partially address the second issue; in the
future we can refactor the harness test framework to be able to run with
vfork(2) syscall but this is not the part of this patchset.
Hajime Tazaki (6):
mm: nommu: fix do_mremap() to correctly update internal states
mm: nommu: use vma_is_anonymous() to check if vmas are anonymous
mm: nommu: fix an issue on map request to /dev/zero
selftests: fix build errors on alpine linux
selftests: run tests on nommu architecture
selftests/mm: add nommu mmap and mremap behavior tests
Documentation/dev-tools/kselftest.rst | 12 +
drivers/char/mem.c | 5 +-
mm/filemap.c | 6 +-
mm/nommu.c | 235 ++++++-
tools/testing/selftests/kselftest.h | 43 ++
tools/testing/selftests/kselftest/runner.sh | 9 +-
tools/testing/selftests/kselftest_harness.h | 4 +
tools/testing/selftests/lib.mk | 10 +-
tools/testing/selftests/mm/Makefile | 3 +
tools/testing/selftests/mm/hugetlb_dio.c | 8 +-
tools/testing/selftests/mm/mdwe_test.c | 4 +-
tools/testing/selftests/mm/nommu_mmap_test.c | 294 +++++++++
.../testing/selftests/mm/nommu_mremap_test.c | 583 ++++++++++++++++++
13 files changed, 1174 insertions(+), 42 deletions(-)
create mode 100644 tools/testing/selftests/mm/nommu_mmap_test.c
create mode 100644 tools/testing/selftests/mm/nommu_mremap_test.c
--
2.43.0
next reply other threads:[~2026-08-13 6:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 6:33 Hajime Tazaki [this message]
2026-08-13 6:33 ` [RFC PATCH 1/6] mm: nommu: fix do_mremap() to correctly update internal states Hajime Tazaki
2026-08-13 6:33 ` [RFC PATCH 2/6] mm: nommu: use vma_is_anonymous() to check if vmas are anonymous Hajime Tazaki
2026-08-13 6:33 ` [RFC PATCH 3/6] mm: nommu: fix an issue on map request to /dev/zero Hajime Tazaki
2026-08-13 12:19 ` Greg Kroah-Hartman
2026-08-13 12:43 ` Daniel Palmer
2026-08-13 13:29 ` Lorenzo Stoakes (ARM)
2026-08-13 13:51 ` Daniel Palmer
2026-08-13 13:58 ` Lorenzo Stoakes (ARM)
2026-08-13 14:06 ` Greg Kroah-Hartman
2026-08-13 14:02 ` Greg Kroah-Hartman
2026-08-13 14:10 ` Lorenzo Stoakes (ARM)
2026-08-13 13:22 ` Matthew Wilcox
2026-08-13 13:32 ` Lorenzo Stoakes (ARM)
2026-08-13 13:43 ` Lorenzo Stoakes (ARM)
2026-08-13 14:04 ` Greg Kroah-Hartman
2026-08-13 6:33 ` [RFC PATCH 4/6] selftests: fix build errors on alpine linux Hajime Tazaki
2026-08-13 6:34 ` [RFC PATCH 5/6] selftests: run tests on nommu architecture Hajime Tazaki
2026-08-13 6:34 ` [RFC PATCH 6/6] selftests/mm: add nommu mmap and mremap behavior tests Hajime Tazaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260813063401.1786548-1-thehajime@gmail.com \
--to=thehajime@gmail.com \
--cc=daniel@thingy.jp \
--cc=geert@linux-m68k.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.