Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/mm: run all tests from run_vmtests.sh

It is very unclear to me how one is supposed to run all the mm selftests
consistently and get clear results.

Most of the test programs are launched by both run_vmtests.sh and
run_kselftest.sh:

hugepage-mmap
hugepage-shm
map_hugetlb
hugepage-mremap
hugepage-vmemmap
hugetlb-madvise
map_fixed_noreplace
gup_test
gup_longterm
uffd-unit-tests
uffd-stress
compaction_test
on-fault-limit
map_populate
mlock-random-test
mlock2-tests
mrelease_test
mremap_test
thuge-gen
virtual_address_range
va_high_addr_switch
mremap_dontunmap
hmm-tests
madv_populate
memfd_secret
ksm_tests
ksm_functional_tests
soft-dirty
cow

However, of this set, when launched by run_vmtests.sh, some of the
programs are invoked multiple times with different arguments. When
invoked by run_kselftest.sh, they are invoked without arguments (and as
a consequence, some fail immediately).

Some test programs are only launched by run_vmtests.sh:

test_vmalloc.sh

And some test programs and only launched by run_kselftest.sh:

khugepaged
migration
mkdirty
transhuge-stress
split_huge_page_test
mdwe_test
write_to_hugetlbfs

Furthermore, run_vmtests.sh is invoked by run_kselftest.sh, so in this
case all the test programs invoked by both scripts are run twice!

Needless to say, this is a bit of a mess. In the absence of fully
understanding the history here, it looks to me like the best solution is
to launch ALL test programs from run_vmtests.sh, and ONLY invoke
run_vmtests.sh from run_kselftest.sh. This way, we get full control over
the parameters, each program is only invoked the intended number of
times, and regardless of which script is used, the same tests get run in
the same way.

The only drawback is that if using run_kselftest.sh, it's top-level tap
result reporting reports only a single test and it fails if any of the
contained tests fail. I don't see this as a big deal though since we
still see all the nested reporting from multiple layers. The other issue
with this is that all of run_vmtests.sh must execute within a single
kselftest timeout period, so let's increase that to something more
suitable.

In the Makefile, TEST_GEN_PROGS will compile and install the tests and
will add them to the list of tests that run_kselftest.sh will run.
TEST_GEN_FILES will compile and install the tests but will not add them
to the test list. So let's move all the programs from TEST_GEN_PROGS to
TEST_GEN_FILES so that they are built but not executed by
run_kselftest.sh. Note that run_vmtests.sh is added to TEST_PROGS, which
means it ends up in the test list. (the lack of "_GEN" means it won't be
compiled, but simply copied).

Link: https://lkml.kernel.org/r/20230724082522.1202616-9-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Peter Xu <peterx@redhat.com>
Cc: Florent Revest <revest@chromium.org>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ryan Roberts and committed by
Andrew Morton
05f1edac e1706210

+64 -40
+40 -39
tools/testing/selftests/mm/Makefile
··· 35 35 CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) 36 36 LDLIBS = -lrt -lpthread 37 37 38 - TEST_GEN_PROGS = cow 39 - TEST_GEN_PROGS += compaction_test 40 - TEST_GEN_PROGS += gup_longterm 41 - TEST_GEN_PROGS += gup_test 42 - TEST_GEN_PROGS += hmm-tests 43 - TEST_GEN_PROGS += hugetlb-madvise 44 - TEST_GEN_PROGS += hugetlb-read-hwpoison 45 - TEST_GEN_PROGS += hugepage-mmap 46 - TEST_GEN_PROGS += hugepage-mremap 47 - TEST_GEN_PROGS += hugepage-shm 48 - TEST_GEN_PROGS += hugepage-vmemmap 49 - TEST_GEN_PROGS += khugepaged 50 - TEST_GEN_PROGS += madv_populate 51 - TEST_GEN_PROGS += map_fixed_noreplace 52 - TEST_GEN_PROGS += map_hugetlb 53 - TEST_GEN_PROGS += map_populate 54 - TEST_GEN_PROGS += memfd_secret 55 - TEST_GEN_PROGS += migration 56 - TEST_GEN_PROGS += mkdirty 57 - TEST_GEN_PROGS += mlock-random-test 58 - TEST_GEN_PROGS += mlock2-tests 59 - TEST_GEN_PROGS += mrelease_test 60 - TEST_GEN_PROGS += mremap_dontunmap 61 - TEST_GEN_PROGS += mremap_test 62 - TEST_GEN_PROGS += on-fault-limit 63 - TEST_GEN_PROGS += thuge-gen 64 - TEST_GEN_PROGS += transhuge-stress 65 - TEST_GEN_PROGS += uffd-stress 66 - TEST_GEN_PROGS += uffd-unit-tests 67 - TEST_GEN_PROGS += split_huge_page_test 68 - TEST_GEN_PROGS += ksm_tests 69 - TEST_GEN_PROGS += ksm_functional_tests 70 - TEST_GEN_PROGS += mdwe_test 38 + TEST_GEN_FILES = cow 39 + TEST_GEN_FILES += compaction_test 40 + TEST_GEN_FILES += gup_longterm 41 + TEST_GEN_FILES += gup_test 42 + TEST_GEN_FILES += hmm-tests 43 + TEST_GEN_FILES += hugetlb-madvise 44 + TEST_GEN_FILES += hugetlb-read-hwpoison 45 + TEST_GEN_FILES += hugepage-mmap 46 + TEST_GEN_FILES += hugepage-mremap 47 + TEST_GEN_FILES += hugepage-shm 48 + TEST_GEN_FILES += hugepage-vmemmap 49 + TEST_GEN_FILES += khugepaged 50 + TEST_GEN_FILES += madv_populate 51 + TEST_GEN_FILES += map_fixed_noreplace 52 + TEST_GEN_FILES += map_hugetlb 53 + TEST_GEN_FILES += map_populate 54 + TEST_GEN_FILES += memfd_secret 55 + TEST_GEN_FILES += migration 56 + TEST_GEN_FILES += mkdirty 57 + TEST_GEN_FILES += mlock-random-test 58 + TEST_GEN_FILES += mlock2-tests 59 + TEST_GEN_FILES += mrelease_test 60 + TEST_GEN_FILES += mremap_dontunmap 61 + TEST_GEN_FILES += mremap_test 62 + TEST_GEN_FILES += on-fault-limit 63 + TEST_GEN_FILES += thuge-gen 64 + TEST_GEN_FILES += transhuge-stress 65 + TEST_GEN_FILES += uffd-stress 66 + TEST_GEN_FILES += uffd-unit-tests 67 + TEST_GEN_FILES += split_huge_page_test 68 + TEST_GEN_FILES += ksm_tests 69 + TEST_GEN_FILES += ksm_functional_tests 70 + TEST_GEN_FILES += mdwe_test 71 71 72 72 ifneq ($(ARCH),arm64) 73 73 TEST_GEN_PROGS += soft-dirty ··· 87 87 endif 88 88 89 89 ifeq ($(CAN_BUILD_I386),1) 90 - TEST_GEN_PROGS += $(BINARIES_32) 90 + TEST_GEN_FILES += $(BINARIES_32) 91 91 endif 92 92 93 93 ifeq ($(CAN_BUILD_X86_64),1) 94 - TEST_GEN_PROGS += $(BINARIES_64) 94 + TEST_GEN_FILES += $(BINARIES_64) 95 95 endif 96 96 else 97 97 98 98 ifneq (,$(findstring $(ARCH),ppc64)) 99 - TEST_GEN_PROGS += protection_keys 99 + TEST_GEN_FILES += protection_keys 100 100 endif 101 101 102 102 endif 103 103 104 104 ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64)) 105 - TEST_GEN_PROGS += va_high_addr_switch 106 - TEST_GEN_PROGS += virtual_address_range 107 - TEST_GEN_PROGS += write_to_hugetlbfs 105 + TEST_GEN_FILES += va_high_addr_switch 106 + TEST_GEN_FILES += virtual_address_range 107 + TEST_GEN_FILES += write_to_hugetlbfs 108 108 endif 109 109 110 110 TEST_PROGS := run_vmtests.sh ··· 116 116 include ../lib.mk 117 117 118 118 $(TEST_GEN_PROGS): vm_util.c 119 + $(TEST_GEN_FILES): vm_util.c 119 120 120 121 $(OUTPUT)/uffd-stress: uffd-common.c 121 122 $(OUTPUT)/uffd-unit-tests: uffd-common.c
+23
tools/testing/selftests/mm/run_vmtests.sh
··· 58 58 test soft dirty page bit semantics 59 59 - cow 60 60 test copy-on-write semantics 61 + - thp 62 + test transparent huge pages 63 + - migration 64 + invoke move_pages(2) to exercise the migration entry code 65 + paths in the kernel 66 + - mkdirty 67 + test handling of code that might set PTE/PMD dirty in 68 + read-only VMAs 69 + - mdwe 70 + test prctl(PR_SET_MDWE, ...) 71 + 61 72 example: ./run_vmtests.sh -t "hmm mmap ksm" 62 73 EOF 63 74 exit 0 ··· 340 329 341 330 # COW tests 342 331 CATEGORY="cow" run_test ./cow 332 + 333 + CATEGORY="thp" run_test ./khugepaged 334 + 335 + CATEGORY="thp" run_test ./transhuge-stress -d 20 336 + 337 + CATEGORY="thp" run_test ./split_huge_page_test 338 + 339 + CATEGORY="migration" run_test ./migration 340 + 341 + CATEGORY="mkdirty" run_test ./mkdirty 342 + 343 + CATEGORY="mdwe" run_test ./mdwe_test 343 344 344 345 echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" 345 346
+1 -1
tools/testing/selftests/mm/settings
··· 1 - timeout=90 1 + timeout=180