-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mm: move hugepage test examples to tools/testing/selftests/vm
hugepage-mmap.c, hugepage-shm.c and map_hugetlb.c in Documentation/vm are simple pass/fail tests, It's better to promote them to tools/testing/selftests. Thanks suggestion of Andrew Morton about this. They all need firstly setting up proper nr_hugepages and hugepage-mmap need to mount hugetlbfs. So I add a shell script run_vmtests to do such work which will call the three test programs and check the return value of them. Changes to original code including below: a. add run_vmtests script b. return error when read_bytes mismatch with writed bytes. c. coding style fixes: do not use assignment in if condition [akpm@linux-foundation.org: build the targets before trying to execute them] [akpm@linux-foundation.org: Documentation/vm/ no longer has a Makefile. Fixes "make clean"] Signed-off-by: Dave Young <dyoung@redhat.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- Loading branch information
Dave Young
authored and
Linus Torvalds
committed
Mar 29, 2012
1 parent
63e3155
commit f0f57b2
Showing
8 changed files
with
112 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
obj-m := DocBook/ accounting/ auxdisplay/ connector/ \ | ||
filesystems/ filesystems/configfs/ ia64/ laptops/ networking/ \ | ||
pcmcia/ spi/ timers/ vm/ watchdog/src/ | ||
pcmcia/ spi/ timers/ watchdog/src/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
TARGETS = breakpoints | ||
TARGETS = breakpoints vm | ||
|
||
all: | ||
for TARGET in $(TARGETS); do \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Makefile for vm selftests | ||
|
||
CC = $(CROSS_COMPILE)gcc | ||
CFLAGS = -Wall -Wextra | ||
|
||
all: hugepage-mmap hugepage-shm map_hugetlb | ||
%: %.c | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
|
||
run_tests: all | ||
/bin/sh ./run_vmtests | ||
|
||
clean: | ||
$(RM) hugepage-mmap hugepage-shm map_hugetlb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
#please run as root | ||
|
||
#we need 256M, below is the size in kB | ||
needmem=262144 | ||
mnt=./huge | ||
|
||
#get pagesize and freepages from /proc/meminfo | ||
while read name size unit; do | ||
if [ "$name" = "HugePages_Free:" ]; then | ||
freepgs=$size | ||
fi | ||
if [ "$name" = "Hugepagesize:" ]; then | ||
pgsize=$size | ||
fi | ||
done < /proc/meminfo | ||
|
||
#set proper nr_hugepages | ||
if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then | ||
nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` | ||
needpgs=`expr $needmem / $pgsize` | ||
if [ $freepgs -lt $needpgs ]; then | ||
lackpgs=$(( $needpgs - $freepgs )) | ||
echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages | ||
if [ $? -ne 0 ]; then | ||
echo "Please run this test as root" | ||
exit 1 | ||
fi | ||
fi | ||
else | ||
echo "no hugetlbfs support in kernel?" | ||
exit 1 | ||
fi | ||
|
||
mkdir $mnt | ||
mount -t hugetlbfs none $mnt | ||
|
||
echo "--------------------" | ||
echo "runing hugepage-mmap" | ||
echo "--------------------" | ||
./hugepage-mmap | ||
if [ $? -ne 0 ]; then | ||
echo "[FAIL]" | ||
else | ||
echo "[PASS]" | ||
fi | ||
|
||
shmmax=`cat /proc/sys/kernel/shmmax` | ||
shmall=`cat /proc/sys/kernel/shmall` | ||
echo 268435456 > /proc/sys/kernel/shmmax | ||
echo 4194304 > /proc/sys/kernel/shmall | ||
echo "--------------------" | ||
echo "runing hugepage-shm" | ||
echo "--------------------" | ||
./hugepage-shm | ||
if [ $? -ne 0 ]; then | ||
echo "[FAIL]" | ||
else | ||
echo "[PASS]" | ||
fi | ||
echo $shmmax > /proc/sys/kernel/shmmax | ||
echo $shmall > /proc/sys/kernel/shmall | ||
|
||
echo "--------------------" | ||
echo "runing map_hugetlb" | ||
echo "--------------------" | ||
./map_hugetlb | ||
if [ $? -ne 0 ]; then | ||
echo "[FAIL]" | ||
else | ||
echo "[PASS]" | ||
fi | ||
|
||
#cleanup | ||
umount $mnt | ||
rm -rf $mnt | ||
echo $nr_hugepgs > /proc/sys/vm/nr_hugepages |