Skip to content

Commit c47174f

Browse files
aagittorvalds
authored andcommitted
userfaultfd: selftest
This test allocates two virtual areas and bounces the physical memory across the two virtual areas using only userfaultfd. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Shuah Khan <shuah.kh@samsung.com> Cc: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2c5b7e1 commit c47174f

File tree

3 files changed

+650
-0
lines changed

3 files changed

+650
-0
lines changed

tools/testing/selftests/vm/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ BINARIES += hugetlbfstest
88
BINARIES += map_hugetlb
99
BINARIES += thuge-gen
1010
BINARIES += transhuge-stress
11+
BINARIES += userfaultfd
1112

1213
all: $(BINARIES)
1314
%: %.c
1415
$(CC) $(CFLAGS) -o $@ $^ -lrt
16+
userfaultfd: userfaultfd.c
17+
$(CC) $(CFLAGS) -O2 -o $@ $^ -lpthread
1518

1619
TEST_PROGS := run_vmtests
1720
TEST_FILES := $(BINARIES)

tools/testing/selftests/vm/run_vmtests

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ else
8686
echo "[PASS]"
8787
fi
8888

89+
echo "--------------------"
90+
echo "running userfaultfd"
91+
echo "--------------------"
92+
./userfaultfd 128 32
93+
if [ $? -ne 0 ]; then
94+
echo "[FAIL]"
95+
exitcode=1
96+
else
97+
echo "[PASS]"
98+
fi
99+
89100
#cleanup
90101
umount $mnt
91102
rm -rf $mnt

0 commit comments

Comments
 (0)