Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #please run as root |
| 3 | |
| 4 | #we need 256M, below is the size in kB |
| 5 | needmem=262144 |
| 6 | mnt=./huge |
Joern Engel | 51a1d16 | 2013-07-03 15:09:17 -0700 | [diff] [blame] | 7 | exitcode=0 |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 8 | |
| 9 | #get pagesize and freepages from /proc/meminfo |
| 10 | while read name size unit; do |
| 11 | if [ "$name" = "HugePages_Free:" ]; then |
| 12 | freepgs=$size |
| 13 | fi |
| 14 | if [ "$name" = "Hugepagesize:" ]; then |
| 15 | pgsize=$size |
| 16 | fi |
| 17 | done < /proc/meminfo |
| 18 | |
| 19 | #set proper nr_hugepages |
| 20 | if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then |
| 21 | nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` |
| 22 | needpgs=`expr $needmem / $pgsize` |
| 23 | if [ $freepgs -lt $needpgs ]; then |
| 24 | lackpgs=$(( $needpgs - $freepgs )) |
| 25 | echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages |
| 26 | if [ $? -ne 0 ]; then |
| 27 | echo "Please run this test as root" |
| 28 | exit 1 |
| 29 | fi |
| 30 | fi |
| 31 | else |
| 32 | echo "no hugetlbfs support in kernel?" |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | mkdir $mnt |
| 37 | mount -t hugetlbfs none $mnt |
| 38 | |
| 39 | echo "--------------------" |
Masanari Iida | ce8283d | 2012-07-18 00:56:18 +0900 | [diff] [blame] | 40 | echo "running hugepage-mmap" |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 41 | echo "--------------------" |
| 42 | ./hugepage-mmap |
| 43 | if [ $? -ne 0 ]; then |
| 44 | echo "[FAIL]" |
Joern Engel | 51a1d16 | 2013-07-03 15:09:17 -0700 | [diff] [blame] | 45 | exitcode=1 |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 46 | else |
| 47 | echo "[PASS]" |
| 48 | fi |
| 49 | |
| 50 | shmmax=`cat /proc/sys/kernel/shmmax` |
| 51 | shmall=`cat /proc/sys/kernel/shmall` |
| 52 | echo 268435456 > /proc/sys/kernel/shmmax |
| 53 | echo 4194304 > /proc/sys/kernel/shmall |
| 54 | echo "--------------------" |
Masanari Iida | ce8283d | 2012-07-18 00:56:18 +0900 | [diff] [blame] | 55 | echo "running hugepage-shm" |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 56 | echo "--------------------" |
| 57 | ./hugepage-shm |
| 58 | if [ $? -ne 0 ]; then |
| 59 | echo "[FAIL]" |
Joern Engel | 51a1d16 | 2013-07-03 15:09:17 -0700 | [diff] [blame] | 60 | exitcode=1 |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 61 | else |
| 62 | echo "[PASS]" |
| 63 | fi |
| 64 | echo $shmmax > /proc/sys/kernel/shmmax |
| 65 | echo $shmall > /proc/sys/kernel/shmall |
| 66 | |
| 67 | echo "--------------------" |
Masanari Iida | ce8283d | 2012-07-18 00:56:18 +0900 | [diff] [blame] | 68 | echo "running map_hugetlb" |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 69 | echo "--------------------" |
| 70 | ./map_hugetlb |
| 71 | if [ $? -ne 0 ]; then |
| 72 | echo "[FAIL]" |
Joern Engel | 51a1d16 | 2013-07-03 15:09:17 -0700 | [diff] [blame] | 73 | exitcode=1 |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 74 | else |
| 75 | echo "[PASS]" |
| 76 | fi |
| 77 | |
Joern Engel | 7e50533 | 2013-07-03 15:09:19 -0700 | [diff] [blame] | 78 | echo "--------------------" |
| 79 | echo "running hugetlbfstest" |
| 80 | echo "--------------------" |
| 81 | ./hugetlbfstest |
| 82 | if [ $? -ne 0 ]; then |
| 83 | echo "[FAIL]" |
| 84 | exitcode=1 |
| 85 | else |
| 86 | echo "[PASS]" |
| 87 | fi |
| 88 | |
Dave Young | f0f57b2 | 2012-03-28 14:42:56 -0700 | [diff] [blame] | 89 | #cleanup |
| 90 | umount $mnt |
| 91 | rm -rf $mnt |
| 92 | echo $nr_hugepgs > /proc/sys/vm/nr_hugepages |
Joern Engel | 51a1d16 | 2013-07-03 15:09:17 -0700 | [diff] [blame] | 93 | exit $exitcode |