blob: c87b6812300d62b3875c95cf31125b1aa2d28536 [file] [log] [blame]
Dave Youngf0f57b22012-03-28 14:42:56 -07001#!/bin/bash
2#please run as root
3
4#we need 256M, below is the size in kB
5needmem=262144
6mnt=./huge
Joern Engel51a1d162013-07-03 15:09:17 -07007exitcode=0
Dave Youngf0f57b22012-03-28 14:42:56 -07008
9#get pagesize and freepages from /proc/meminfo
10while 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
17done < /proc/meminfo
18
19#set proper nr_hugepages
20if [ -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
31else
32 echo "no hugetlbfs support in kernel?"
33 exit 1
34fi
35
36mkdir $mnt
37mount -t hugetlbfs none $mnt
38
39echo "--------------------"
Masanari Iidace8283d2012-07-18 00:56:18 +090040echo "running hugepage-mmap"
Dave Youngf0f57b22012-03-28 14:42:56 -070041echo "--------------------"
42./hugepage-mmap
43if [ $? -ne 0 ]; then
44 echo "[FAIL]"
Joern Engel51a1d162013-07-03 15:09:17 -070045 exitcode=1
Dave Youngf0f57b22012-03-28 14:42:56 -070046else
47 echo "[PASS]"
48fi
49
50shmmax=`cat /proc/sys/kernel/shmmax`
51shmall=`cat /proc/sys/kernel/shmall`
52echo 268435456 > /proc/sys/kernel/shmmax
53echo 4194304 > /proc/sys/kernel/shmall
54echo "--------------------"
Masanari Iidace8283d2012-07-18 00:56:18 +090055echo "running hugepage-shm"
Dave Youngf0f57b22012-03-28 14:42:56 -070056echo "--------------------"
57./hugepage-shm
58if [ $? -ne 0 ]; then
59 echo "[FAIL]"
Joern Engel51a1d162013-07-03 15:09:17 -070060 exitcode=1
Dave Youngf0f57b22012-03-28 14:42:56 -070061else
62 echo "[PASS]"
63fi
64echo $shmmax > /proc/sys/kernel/shmmax
65echo $shmall > /proc/sys/kernel/shmall
66
67echo "--------------------"
Masanari Iidace8283d2012-07-18 00:56:18 +090068echo "running map_hugetlb"
Dave Youngf0f57b22012-03-28 14:42:56 -070069echo "--------------------"
70./map_hugetlb
71if [ $? -ne 0 ]; then
72 echo "[FAIL]"
Joern Engel51a1d162013-07-03 15:09:17 -070073 exitcode=1
Dave Youngf0f57b22012-03-28 14:42:56 -070074else
75 echo "[PASS]"
76fi
77
Joern Engel7e505332013-07-03 15:09:19 -070078echo "--------------------"
79echo "running hugetlbfstest"
80echo "--------------------"
81./hugetlbfstest
82if [ $? -ne 0 ]; then
83 echo "[FAIL]"
84 exitcode=1
85else
86 echo "[PASS]"
87fi
88
Dave Youngf0f57b22012-03-28 14:42:56 -070089#cleanup
90umount $mnt
91rm -rf $mnt
92echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
Joern Engel51a1d162013-07-03 15:09:17 -070093exit $exitcode