Skip to contentSkip to conversation

mm/hmm/test: add self tests for HMM

PATCH Applied Ralph Campbell 3 participants 6 messages Apr 22, 2020 – May 6, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v10 cover mm/hmm/test: add self tests for HMM

This series adds basic self tests for HMM and are intended for Jason Gunthorpe's rdma tree since he is making some HMM related changes that this can help test.

Changes v9 -> v10:
Patches 1 & 2 include Jason's changes from his cover letter:
https://lkml.org/lkml/2020/4/21/1320
Patch 3 now adds the files alphbetically and removed the outdated reference to include/uapi/linux.

Changes v8 -> v9:
Rebased to linux-5.7.0-rc1.
Moved include/uapi/linux/test_hmm.h to lib/test_hmm_uapi.h Added calls to release_mem_region() to free device private addresses Applied Jason's suggested changes for v8.
Added a check for no VMA read access before migrating to device private
memory.

Changes v7 -> v8:
Rebased to Jason's rdma/hmm tree, plus Jason's 6 patch series
"Small hmm_range_fault() cleanups".
Applied a number of changes from Jason's comments.

Changes v6 -> v7:
Rebased to linux-5.6.0-rc6
Reverted back to just using mmu_interval_notifier_insert() and making
this series only introduce HMM self tests.

Changes v5 -> v6:
Rebased to linux-5.5.0-rc6
Refactored mmu interval notifier patches Converted nouveau to use the new mmu interval notifier API

Changes v4 -> v5:
Added mmu interval notifier insert/remove/update callable from the
invalidate() callback
Updated HMM tests to use the new core interval notifier API

Changes v1 -> v4:
https://lore.kernel.org/linux-mm/[email protected]

Ralph Campbell (3):
mm/hmm/test: add selftest driver for HMM
mm/hmm/test: add selftests for HMM
MAINTAINERS: add HMM selftests

 MAINTAINERS                            |    2 +
 lib/Kconfig.debug                      |   13 +
 lib/Makefile                           |    1 +
 lib/test_hmm.c                         | 1149 ++++++++++++++++++++
 lib/test_hmm_uapi.h                    |   59 +
 tools/testing/selftests/vm/.gitignore  |    1 +
 tools/testing/selftests/vm/Makefile    |    3 +
 tools/testing/selftests/vm/config      |    2 +
 tools/testing/selftests/vm/hmm-tests.c | 1359 ++++++++++++++++++++++++
 tools/testing/selftests/vm/run_vmtests |   16 +
 tools/testing/selftests/vm/test_hmm.sh |   97 ++
 11 files changed, 2702 insertions(+)
 create mode 100644 lib/test_hmm.c
 create mode 100644 lib/test_hmm_uapi.h
 create mode 100644 tools/testing/selftests/vm/hmm-tests.c
 create mode 100755 tools/testing/selftests/vm/test_hmm.sh
Signature · 1 line
2.25.2
#1 lore raw

PATCH v10 1/3 mm/hmm/test: add selftest driver for HMM

This driver is for testing device private memory migration and devices which use hmm_range_fault() to access system memory via device page tables.

---
 lib/Kconfig.debug   |   13 +
 lib/Makefile        |    1 +
 lib/test_hmm.c      | 1149 +++++++++++++++++++++++++++++++++++++++++++
 lib/test_hmm_uapi.h |   59 +++
 4 files changed, 1222 insertions(+)
 create mode 100644 lib/test_hmm.c
 create mode 100644 lib/test_hmm_uapi.h
lib/Kconfig.debug +13 -0
index 21d9c5f6e7ec..609dae2e9317 100644
@@ -2201,6 +2201,19 @@ config TEST_MEMINIT
 
 	  If unsure, say N.
 
+config TEST_HMM
+	tristate "Test HMM (Heterogeneous Memory Management)"
+	depends on TRANSPARENT_HUGEPAGE
+	select DEVICE_PRIVATE
+	select HMM_MIRROR
+	select MMU_NOTIFIER
+	help
+	  This is a pseudo device driver solely for testing HMM.
+	  Say M here if you want to build the HMM test module.
+	  Doing so will allow you to run tools/testing/selftest/vm/hmm-tests.
+
+	  If unsure, say N.
+
 endif # RUNTIME_TESTING_MENU
 
 config MEMTEST
lib/Makefile +1 -0
index 685aee60de1d..93d8ad358b44 100644
@@ -92,6 +92,7 @@ obj-$(CONFIG_TEST_STACKINIT) += test_stackinit.o
 obj-$(CONFIG_TEST_BLACKHOLE_DEV) += test_blackhole_dev.o
 obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o
 obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o
+obj-$(CONFIG_TEST_HMM) += test_hmm.o
 
 obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/
 
lib/test_hmm.c new file +1149 -0

1,149 lines not on this page · raw message

lib/test_hmm_uapi.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.25.2
#2 lore raw

PATCH v10 2/3 mm/hmm/test: add selftests for HMM

In reply to Ralph Campbell

Add some basic stand alone self tests for HMM.
The test program and shell scripts use the test_hmm.ko driver to exercise HMM functionality in the kernel.

---
 tools/testing/selftests/vm/.gitignore  |    1 +
 tools/testing/selftests/vm/Makefile    |    3 +
 tools/testing/selftests/vm/config      |    2 +
 tools/testing/selftests/vm/hmm-tests.c | 1359 ++++++++++++++++++++++++
 tools/testing/selftests/vm/run_vmtests |   16 +
 tools/testing/selftests/vm/test_hmm.sh |   97 ++
 6 files changed, 1478 insertions(+)
 create mode 100644 tools/testing/selftests/vm/hmm-tests.c
 create mode 100755 tools/testing/selftests/vm/test_hmm.sh
tools/testing/selftests/vm/.gitignore +1 -0
index 0edb6d900e8d..f25208eca5ff 100644
@@ -16,3 +16,4 @@ gup_benchmark
 va_128TBswitch
 map_fixed_noreplace
 write_to_hugetlbfs
+hmm-tests
tools/testing/selftests/vm/Makefile +3 -0
index d31db052dff6..4dd6689157bc 100644
@@ -7,6 +7,7 @@ CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS)
 LDLIBS = -lrt
 TEST_GEN_FILES = compaction_test
 TEST_GEN_FILES += gup_benchmark
+TEST_GEN_FILES += hmm-tests
 TEST_GEN_FILES += hugepage-mmap
 TEST_GEN_FILES += hugepage-shm
 TEST_GEN_FILES += map_hugetlb
@@ -33,6 +34,8 @@ TEST_FILES := test_vmalloc.sh
 KSFT_KHDR_INSTALL := 1
 include ../lib.mk
 
+$(OUTPUT)/hmm-tests: LDLIBS += -lhugetlbfs -lpthread
+
 $(OUTPUT)/userfaultfd: LDLIBS += -lpthread
 
 $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
tools/testing/selftests/vm/config +2 -0
index 93b90a9b1eeb..3ba674b64fa9 100644
@@ -1,3 +1,5 @@
 CONFIG_SYSVIPC=y
 CONFIG_USERFAULTFD=y
 CONFIG_TEST_VMALLOC=m
+CONFIG_DEVICE_PRIVATE=y
+CONFIG_TEST_HMM=m
tools/testing/selftests/vm/hmm-tests.c new file +1359 -0

1,359 lines not on this page · raw message

tools/testing/selftests/vm/run_vmtests +16 -0
index 665009ebfba4..4f0e272285d9 100755
@@ -307,4 +307,20 @@ else
 	echo "[FAIL]"
 	exitcode=1
 fi
+
+echo "running HMM smoke test"
+echo "------------------------------------"
+./test_hmm.sh smoke
+ret_val=$?
+
+if [ $ret_val -eq 0 ]; then
+	echo "[PASS]"
+elif [ $ret_val -eq $ksft_skip ]; then
+	echo "[SKIP]"
+	exitcode=$ksft_skip
+else
+	echo "[FAIL]"
+	exitcode=1
+fi
+
 exit $exitcode
tools/testing/selftests/vm/test_hmm.sh new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.25.2
#3 lore raw

PATCH v10 3/3 MAINTAINERS: add HMM selftests

In reply to Ralph Campbell

Add files for HMM selftests.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index b816a453b10e..96fc44d0f5f2 100644
@@ -7732,7 +7732,9 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/vm/hmm.rst
 F:	include/linux/hmm*
+F:	lib/test_hmm*
 F:	mm/hmm*
+F:	tools/testing/selftests/vm/*hmm*
 
 HOST AP DRIVER
 M:	Jouni Malinen <[email protected]>
Signature · 1 line
2.25.2
#4 lore raw
In reply to Ralph Campbell
Quoted 3 lines · Ralph Campbell

This series adds basic self tests for HMM and are intended for Jason Gunthorpe's rdma tree since he is making some HMM related changes that this can help test.

This all seems pretty fine to me, if nobody from the selftest world has remarks I will apply it after the api change to hmm_range_fault()

Jason

#5 lore raw
In reply to Ralph Campbell
Quoted 9 lines · Ralph Campbell

This series adds basic self tests for HMM and are intended for Jason Gunthorpe's rdma tree since he is making some HMM related changes that this can help test.

Changes v9 -> v10:
Patches 1 & 2 include Jason's changes from his cover letter:
https://lkml.org/lkml/2020/4/21/1320
Patch 3 now adds the files alphbetically and removed the outdated reference to include/uapi/linux.

Applied to hmm.git, thanks

Jason