Commit fee9f6d1 authored by Ralph Campbell's avatar Ralph Campbell Committed by Jason Gunthorpe

mm/hmm/test: add selftests for HMM

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.

Link: https://lore.kernel.org/r/20200422195028.3684-3-rcampbell@nvidia.comSigned-off-by: default avatarRalph Campbell <rcampbell@nvidia.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent b2ef9f5a
......@@ -16,3 +16,4 @@ gup_benchmark
va_128TBswitch
map_fixed_noreplace
write_to_hugetlbfs
hmm-tests
......@@ -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
CONFIG_SYSVIPC=y
CONFIG_USERFAULTFD=y
CONFIG_TEST_VMALLOC=m
CONFIG_DEVICE_PRIVATE=y
CONFIG_TEST_HMM=m
This diff is collapsed.
......@@ -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
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
#
# This is a test script for the kernel test driver to analyse vmalloc
# allocator. Therefore it is just a kernel module loader. You can specify
# and pass different parameters in order to:
# a) analyse performance of vmalloc allocations;
# b) stressing and stability check of vmalloc subsystem.
TEST_NAME="test_hmm"
DRIVER="test_hmm"
# 1 if fails
exitcode=1
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
check_test_requirements()
{
uid=$(id -u)
if [ $uid -ne 0 ]; then
echo "$0: Must be run as root"
exit $ksft_skip
fi
if ! which modprobe > /dev/null 2>&1; then
echo "$0: You need modprobe installed"
exit $ksft_skip
fi
if ! modinfo $DRIVER > /dev/null 2>&1; then
echo "$0: You must have the following enabled in your kernel:"
echo "CONFIG_TEST_HMM=m"
exit $ksft_skip
fi
}
load_driver()
{
modprobe $DRIVER > /dev/null 2>&1
if [ $? == 0 ]; then
major=$(awk "\$2==\"HMM_DMIRROR\" {print \$1}" /proc/devices)
mknod /dev/hmm_dmirror0 c $major 0
mknod /dev/hmm_dmirror1 c $major 1
fi
}
unload_driver()
{
modprobe -r $DRIVER > /dev/null 2>&1
rm -f /dev/hmm_dmirror?
}
run_smoke()
{
echo "Running smoke test. Note, this test provides basic coverage."
load_driver
$(dirname "${BASH_SOURCE[0]}")/hmm-tests
unload_driver
}
usage()
{
echo -n "Usage: $0"
echo
echo "Example usage:"
echo
echo "# Shows help message"
echo "./${TEST_NAME}.sh"
echo
echo "# Smoke testing"
echo "./${TEST_NAME}.sh smoke"
echo
exit 0
}
function run_test()
{
if [ $# -eq 0 ]; then
usage
else
if [ "$1" = "smoke" ]; then
run_smoke
else
usage
fi
fi
}
check_test_requirements
run_test $@
exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment