tools-testing-vma-separate-vma-userland-tests-into-separate-files.patch removed from -mm tree
The quilt patch titled
Subject: tools/testing/vma: separate VMA userland tests into separate files
has been removed from the -mm tree. Its filename was
tools-testing-vma-separate-vma-userland-tests-into-separate-files.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Lorenzo Stoakes <[email protected]>
Subject: tools/testing/vma: separate VMA userland tests into separate files
Date: Thu, 22 Jan 2026 16:06:20 +0000
So far the userland VMA tests have been established as a rough expression of what's been possible.
Adapt it into a more usable form by separating out tests and shared helper functions.
Since we test functions that are declared statically in mm/vma.c, we make use of the trick of #include'ing kernel C files directly.
In order for the tests to continue to function, we must therefore also this way into the tests/ directory.
We try to keep as much shared logic actually modularised into a separate compilation unit in shared.c, however the merge_existing() and attach_vma() helpers rely on statically declared mm/vma.c functions so these must be declared in main.c.
---
tools/testing/vma/Makefile | 4 tools/testing/vma/main.c | 55 tools/testing/vma/shared.c | 131 ++ tools/testing/vma/shared.h | 114 + tools/testing/vma/tests/merge.c | 1469 +++++++++++++++++++++++ tools/testing/vma/tests/mmap.c | 57 tools/testing/vma/tests/vma.c | 39 tools/testing/vma/vma.c | 1785 ----------------------------- tools/testing/vma/vma_internal.h | 9 9 files changed, 1867 insertions(+), 1796 deletions(-)
tools/testing/vma/main.c new file +55 -0
@@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "shared.h" +/* +* Directly import the VMA implementation here. Our vma_internal.h wrapper +* provides userland-equivalent functionality for everything vma.c uses. +*/ +#include "../../../mm/vma_init.c" +#include "../../../mm/vma_exec.c" +#include "../../../mm/vma.c" + +/* Tests are included directly so they can test static functions in mm/vma.c. */ +#include "tests/merge.c" +#include "tests/mmap.c" +#include "tests/vma.c" + +/* Helper functions which utilise static kernel functions. */ + +struct vm_area_struct *merge_existing (struct vma_merge_struct *vmg) +{ +struct vm_area_struct *vma; + + vma =vma_merge_existing_range (vmg); +if (vma) +vma_assert_attached (vma); +return vma; +} + +int attach_vma (struct mm_struct *mm,struct vm_area_struct *vma) +{ +int res; + + res =vma_link (mm, vma); +if (!res) +vma_assert_attached (vma); +return res; +} + +/* Main test running which invokes tests/ *.c runners. */ +int main (void ) +{ +int num_tests =0 , num_fail =0 ; + +maple_tree_init (); +vma_state_init (); + +run_merge_tests (&num_tests, &num_fail); +run_mmap_tests (&num_tests, &num_fail); +run_vma_tests (&num_tests, &num_fail); + +printf ("%d tests run, %d passed, %d failed.\n" , + num_tests, num_tests - num_fail, num_fail); + +return num_fail ==0 ?EXIT_SUCCESS :EXIT_FAILURE ; +}
tools/testing/vma/Makefile renamed from tools/testing/vma/Makefile~tools-testing-vma-separate-vma-userland-tests-into-separate-files +2 -2
@@ -6,10 +6,10 @@ default: vma include ../shared/shared.mk -OFILES = $(SHARED_OFILES) vma.o maple-shim.o +OFILES = $(SHARED_OFILES) main.o shared.o maple-shim.o TARGETS = vma -vma.o: vma.c vma_internal.h ../../../mm/vma.c ../../../mm/vma_init.c ../../../mm/vma_exec.c ../../../mm/vma.h +main.o: main.c shared.c shared.h vma_internal.h tests/merge.c tests/mmap.c tests/vma.c ../../../mm/vma.c ../../../mm/vma_init.c ../../../mm/vma_exec.c ../../../mm/vma.h vma: $(OFILES) $(CC) $(CFLAGS) -o $@ $(OFILES) $(LDLIBS)
tools/testing/vma/shared.c new file +131 -0
131 lines not on this page · raw message
tools/testing/vma/shared.h new file +114 -0
114 lines not on this page · raw message
tools/testing/vma/tests/merge.c new file +1469 -0
1,469 lines not on this page · raw message
tools/testing/vma/tests/mmap.c new file +57 -0
57 lines not on this page · raw message
tools/testing/vma/tests/vma.c new file +39 -0
@@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +static bool test_copy_vma (void ) +{ +vm_flags_t vm_flags =VM_READ |VM_WRITE |VM_MAYREAD |VM_MAYWRITE ; +struct mm_struct mm = {}; +bool need_locks = false; +VMA_ITERATOR (vmi, &mm,0 ); +struct vm_area_struct *vma, *vma_new, *vma_next; + +/* Move backwards and do not merge. */ + + vma =alloc_and_link_vma (&mm,0x3000 ,0x5000 ,3 , vm_flags); + vma_new =copy_vma (&vma,0 ,0x2000 ,0 , &need_locks); +ASSERT_NE (vma_new, vma); +ASSERT_EQ (vma_new->vm_start,0 ); +ASSERT_EQ (vma_new->vm_end,0x2000 ); +ASSERT_EQ (vma_new->vm_pgoff,0 ); +vma_assert_attached (vma_new); + +cleanup_mm (&mm, &vmi); + +/* Move a VMA into position next to another and merge the two. */ + + vma =alloc_and_link_vma (&mm,0 ,0x2000 ,0 , vm_flags); + vma_next =alloc_and_link_vma (&mm,0x6000 ,0x8000 ,6 , vm_flags); + vma_new =copy_vma (&vma,0x4000 ,0x2000 ,4 , &need_locks); +vma_assert_attached (vma_new); + +ASSERT_EQ (vma_new, vma_next); + +cleanup_mm (&mm, &vmi); +return true; +} + +static void run_vma_tests (int *num_tests,int *num_fail) +{ +TEST (copy_vma); +}
tools/testing/vma/vma.c deleted +0 -1785
1,123 lines not on this page · raw message
tools/testing/vma/vma_internal.h renamed from tools/testing/vma/vma_internal.h~tools-testing-vma-separate-vma-userland-tests-into-separate-files +0 -9
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
_
Patches currently in -mm which might be from [email protected] are
Part of the diff is not shown here. View the raw message.