blob: a24d30af30949a1a9dbc21a7efe4f6a6d0c01e38 [file] [log] [blame]
Dave Youngf0f57b22012-03-28 14:42:56 -07001#!/bin/bash
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Dave Youngf0f57b22012-03-28 14:42:56 -07003#please run as root
4
Shuah Khan (Samsung OSG)a4d75372018-06-13 21:31:43 -06005# Kselftest framework requirement - SKIP code is 4.
6ksft_skip=4
7
Dave Youngf0f57b22012-03-28 14:42:56 -07008mnt=./huge
Joern Engel51a1d162013-07-03 15:09:17 -07009exitcode=0
Dave Youngf0f57b22012-03-28 14:42:56 -070010
Li Zhijian0627be72018-03-09 15:51:16 -080011#get huge pagesize and freepages from /proc/meminfo
Dave Youngf0f57b22012-03-28 14:42:56 -070012while read name size unit; do
13 if [ "$name" = "HugePages_Free:" ]; then
14 freepgs=$size
15 fi
16 if [ "$name" = "Hugepagesize:" ]; then
Li Zhijian0627be72018-03-09 15:51:16 -080017 hpgsize_KB=$size
Dave Youngf0f57b22012-03-28 14:42:56 -070018 fi
19done < /proc/meminfo
20
Li Zhijian0627be72018-03-09 15:51:16 -080021# Simple hugetlbfs tests have a hardcoded minimum requirement of
22# huge pages totaling 256MB (262144KB) in size. The userfaultfd
23# hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take
24# both of these requirements into account and attempt to increase
25# number of huge pages available.
26nr_cpus=$(nproc)
27hpgsize_MB=$((hpgsize_KB / 1024))
28half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128))
29needmem_KB=$((half_ufd_size_MB * 2 * 1024))
30
Dave Youngf0f57b22012-03-28 14:42:56 -070031#set proper nr_hugepages
Li Zhijian0627be72018-03-09 15:51:16 -080032if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
Dave Youngf0f57b22012-03-28 14:42:56 -070033 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
Li Zhijian0627be72018-03-09 15:51:16 -080034 needpgs=$((needmem_KB / hpgsize_KB))
Ben Hutchingsee004792015-11-02 12:22:22 +000035 tries=2
36 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
Dave Youngf0f57b22012-03-28 14:42:56 -070037 lackpgs=$(( $needpgs - $freepgs ))
Ben Hutchingsee004792015-11-02 12:22:22 +000038 echo 3 > /proc/sys/vm/drop_caches
Dave Youngf0f57b22012-03-28 14:42:56 -070039 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
40 if [ $? -ne 0 ]; then
41 echo "Please run this test as root"
Shuah Khan (Samsung OSG)a4d75372018-06-13 21:31:43 -060042 exit $ksft_skip
Dave Youngf0f57b22012-03-28 14:42:56 -070043 fi
Ben Hutchingsee004792015-11-02 12:22:22 +000044 while read name size unit; do
45 if [ "$name" = "HugePages_Free:" ]; then
46 freepgs=$size
47 fi
48 done < /proc/meminfo
49 tries=$((tries - 1))
50 done
51 if [ $freepgs -lt $needpgs ]; then
52 printf "Not enough huge pages available (%d < %d)\n" \
53 $freepgs $needpgs
54 exit 1
Dave Youngf0f57b22012-03-28 14:42:56 -070055 fi
56else
57 echo "no hugetlbfs support in kernel?"
58 exit 1
59fi
60
Masami Hiramatsu7549b332019-10-23 13:57:49 +090061#filter 64bit architectures
Sandipan Das963e3e92020-01-30 12:31:19 +053062ARCH64STR="arm64 ia64 mips64 parisc64 ppc64 ppc64le riscv64 s390x sh64 sparc64 x86_64"
Masami Hiramatsu7549b332019-10-23 13:57:49 +090063if [ -z $ARCH ]; then
64 ARCH=`uname -m 2>/dev/null | sed -e 's/aarch64.*/arm64/'`
65fi
66VADDR64=0
67echo "$ARCH64STR" | grep $ARCH && VADDR64=1
68
Dave Youngf0f57b22012-03-28 14:42:56 -070069mkdir $mnt
70mount -t hugetlbfs none $mnt
71
SeongJae Park2b8713e2017-04-14 01:58:49 +090072echo "---------------------"
Masanari Iidace8283d2012-07-18 00:56:18 +090073echo "running hugepage-mmap"
SeongJae Park2b8713e2017-04-14 01:58:49 +090074echo "---------------------"
Dave Youngf0f57b22012-03-28 14:42:56 -070075./hugepage-mmap
76if [ $? -ne 0 ]; then
77 echo "[FAIL]"
Joern Engel51a1d162013-07-03 15:09:17 -070078 exitcode=1
Dave Youngf0f57b22012-03-28 14:42:56 -070079else
80 echo "[PASS]"
81fi
82
83shmmax=`cat /proc/sys/kernel/shmmax`
84shmall=`cat /proc/sys/kernel/shmall`
85echo 268435456 > /proc/sys/kernel/shmmax
86echo 4194304 > /proc/sys/kernel/shmall
87echo "--------------------"
Masanari Iidace8283d2012-07-18 00:56:18 +090088echo "running hugepage-shm"
Dave Youngf0f57b22012-03-28 14:42:56 -070089echo "--------------------"
90./hugepage-shm
91if [ $? -ne 0 ]; then
92 echo "[FAIL]"
Joern Engel51a1d162013-07-03 15:09:17 -070093 exitcode=1
Dave Youngf0f57b22012-03-28 14:42:56 -070094else
95 echo "[PASS]"
96fi
97echo $shmmax > /proc/sys/kernel/shmmax
98echo $shmall > /proc/sys/kernel/shmall
99
SeongJae Park2b8713e2017-04-14 01:58:49 +0900100echo "-------------------"
Masanari Iidace8283d2012-07-18 00:56:18 +0900101echo "running map_hugetlb"
SeongJae Park2b8713e2017-04-14 01:58:49 +0900102echo "-------------------"
Dave Youngf0f57b22012-03-28 14:42:56 -0700103./map_hugetlb
104if [ $? -ne 0 ]; then
105 echo "[FAIL]"
Joern Engel51a1d162013-07-03 15:09:17 -0700106 exitcode=1
Dave Youngf0f57b22012-03-28 14:42:56 -0700107else
108 echo "[PASS]"
109fi
110
Mina Almasry12b61322021-11-05 13:41:43 -0700111echo "-----------------------"
112echo "running hugepage-mremap"
113echo "-----------------------"
114./hugepage-mremap
115if [ $? -ne 0 ]; then
116 echo "[FAIL]"
117 exitcode=1
118else
119 echo "[PASS]"
120fi
121
Mike Kravetzfd5a9ec2015-09-08 15:02:55 -0700122echo "NOTE: The above hugetlb tests provide minimal coverage. Use"
123echo " https://github.com/libhugetlbfs/libhugetlbfs.git for"
124echo " hugetlb regression testing."
125
SeongJae Park9e69fa42020-02-20 20:04:06 -0800126echo "---------------------------"
127echo "running map_fixed_noreplace"
128echo "---------------------------"
129./map_fixed_noreplace
130if [ $? -ne 0 ]; then
131 echo "[FAIL]"
132 exitcode=1
133else
134 echo "[PASS]"
135fi
136
John Hubbardd943fe82020-12-14 19:05:24 -0800137echo "------------------------------------------------------"
138echo "running: gup_test -u # get_user_pages_fast() benchmark"
139echo "------------------------------------------------------"
140./gup_test -u
John Hubbardbe871412020-04-01 21:05:45 -0700141if [ $? -ne 0 ]; then
142 echo "[FAIL]"
143 exitcode=1
144else
145 echo "[PASS]"
146fi
147
John Hubbardd943fe82020-12-14 19:05:24 -0800148echo "------------------------------------------------------"
149echo "running: gup_test -a # pin_user_pages_fast() benchmark"
150echo "------------------------------------------------------"
151./gup_test -a
152if [ $? -ne 0 ]; then
153 echo "[FAIL]"
154 exitcode=1
155else
156 echo "[PASS]"
157fi
158
159echo "------------------------------------------------------------"
160echo "# Dump pages 0, 19, and 4096, using pin_user_pages:"
161echo "running: gup_test -ct -F 0x1 0 19 0x1000 # dump_page() test"
162echo "------------------------------------------------------------"
163./gup_test -ct -F 0x1 0 19 0x1000
John Hubbardbe871412020-04-01 21:05:45 -0700164if [ $? -ne 0 ]; then
165 echo "[FAIL]"
166 exitcode=1
167else
168 echo "[PASS]"
169fi
170
SeongJae Park2b8713e2017-04-14 01:58:49 +0900171echo "-------------------"
Andrea Arcangelic47174f2015-09-04 15:47:23 -0700172echo "running userfaultfd"
SeongJae Park2b8713e2017-04-14 01:58:49 +0900173echo "-------------------"
John Hubbarda26c4c62020-12-14 19:05:31 -0800174./userfaultfd anon 20 16
Andrea Arcangelic47174f2015-09-04 15:47:23 -0700175if [ $? -ne 0 ]; then
176 echo "[FAIL]"
177 exitcode=1
178else
179 echo "[PASS]"
180fi
181
SeongJae Park2b8713e2017-04-14 01:58:49 +0900182echo "---------------------------"
Mike Kravetz9903bd72017-02-22 15:43:07 -0800183echo "running userfaultfd_hugetlb"
SeongJae Park2b8713e2017-04-14 01:58:49 +0900184echo "---------------------------"
Li Zhijian0627be72018-03-09 15:51:16 -0800185# Test requires source and destination huge pages. Size of source
186# (half_ufd_size_MB) is passed as argument to test.
187./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file
Mike Kravetz9903bd72017-02-22 15:43:07 -0800188if [ $? -ne 0 ]; then
189 echo "[FAIL]"
190 exitcode=1
191else
192 echo "[PASS]"
193fi
194rm -f $mnt/ufd_test_file
195
SeongJae Park2b8713e2017-04-14 01:58:49 +0900196echo "-------------------------"
Mike Rapoport419624d2017-02-22 15:43:46 -0800197echo "running userfaultfd_shmem"
SeongJae Park2b8713e2017-04-14 01:58:49 +0900198echo "-------------------------"
John Hubbarda26c4c62020-12-14 19:05:31 -0800199./userfaultfd shmem 20 16
Mike Rapoport419624d2017-02-22 15:43:46 -0800200if [ $? -ne 0 ]; then
201 echo "[FAIL]"
202 exitcode=1
203else
204 echo "[PASS]"
205fi
206
Dave Youngf0f57b22012-03-28 14:42:56 -0700207#cleanup
208umount $mnt
209rm -rf $mnt
210echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
Sri Jayaramappabd67d5c2015-04-23 14:21:41 -0400211
212echo "-----------------------"
213echo "running compaction_test"
214echo "-----------------------"
215./compaction_test
216if [ $? -ne 0 ]; then
217 echo "[FAIL]"
218 exitcode=1
219else
220 echo "[PASS]"
221fi
222
SeongJae Park2b8713e2017-04-14 01:58:49 +0900223echo "----------------------"
Eric B Munsonb3b0d092015-11-05 18:51:43 -0800224echo "running on-fault-limit"
SeongJae Park2b8713e2017-04-14 01:58:49 +0900225echo "----------------------"
Eric B Munsonb3b0d092015-11-05 18:51:43 -0800226sudo -u nobody ./on-fault-limit
227if [ $? -ne 0 ]; then
228 echo "[FAIL]"
229 exitcode=1
230else
231 echo "[PASS]"
232fi
233
234echo "--------------------"
Dmitry Safonov1caed862018-08-21 21:53:47 -0700235echo "running map_populate"
236echo "--------------------"
237./map_populate
238if [ $? -ne 0 ]; then
239 echo "[FAIL]"
240 exitcode=1
241else
242 echo "[PASS]"
243fi
244
SeongJae Park9e69fa42020-02-20 20:04:06 -0800245echo "-------------------------"
246echo "running mlock-random-test"
247echo "-------------------------"
248./mlock-random-test
249if [ $? -ne 0 ]; then
250 echo "[FAIL]"
251 exitcode=1
252else
253 echo "[PASS]"
254fi
255
Dmitry Safonov1caed862018-08-21 21:53:47 -0700256echo "--------------------"
Eric B Munsonb3b0d092015-11-05 18:51:43 -0800257echo "running mlock2-tests"
258echo "--------------------"
259./mlock2-tests
260if [ $? -ne 0 ]; then
261 echo "[FAIL]"
262 exitcode=1
263else
264 echo "[PASS]"
265fi
266
Kalesh Singh7df66622020-12-14 19:07:25 -0800267echo "-------------------"
268echo "running mremap_test"
269echo "-------------------"
270./mremap_test
271if [ $? -ne 0 ]; then
272 echo "[FAIL]"
273 exitcode=1
274else
275 echo "[PASS]"
276fi
277
SeongJae Park9e69fa42020-02-20 20:04:06 -0800278echo "-----------------"
279echo "running thuge-gen"
280echo "-----------------"
281./thuge-gen
282if [ $? -ne 0 ]; then
283 echo "[FAIL]"
284 exitcode=1
285else
286 echo "[PASS]"
287fi
288
Masami Hiramatsu7549b332019-10-23 13:57:49 +0900289if [ $VADDR64 -ne 0 ]; then
Anshuman Khandual4e5ce332017-05-08 16:00:19 -0700290echo "-----------------------------"
291echo "running virtual_address_range"
292echo "-----------------------------"
293./virtual_address_range
294if [ $? -ne 0 ]; then
295 echo "[FAIL]"
296 exitcode=1
297else
298 echo "[PASS]"
299fi
300
Aneesh Kumar K.V235266b2018-01-31 16:16:59 -0800301echo "-----------------------------"
302echo "running virtual address 128TB switch test"
303echo "-----------------------------"
304./va_128TBswitch
305if [ $? -ne 0 ]; then
306 echo "[FAIL]"
307 exitcode=1
308else
309 echo "[PASS]"
310fi
Masami Hiramatsu7549b332019-10-23 13:57:49 +0900311fi # VADDR64
Aneesh Kumar K.V235266b2018-01-31 16:16:59 -0800312
Uladzislau Rezki (Sony)a05ef002019-03-05 15:43:37 -0800313echo "------------------------------------"
314echo "running vmalloc stability smoke test"
315echo "------------------------------------"
316./test_vmalloc.sh smoke
317ret_val=$?
318
319if [ $ret_val -eq 0 ]; then
320 echo "[PASS]"
321elif [ $ret_val -eq $ksft_skip ]; then
322 echo "[SKIP]"
323 exitcode=$ksft_skip
324else
325 echo "[FAIL]"
326 exitcode=1
327fi
328
Brian Geffon0c287592020-04-01 21:09:20 -0700329echo "------------------------------------"
330echo "running MREMAP_DONTUNMAP smoke test"
331echo "------------------------------------"
332./mremap_dontunmap
333ret_val=$?
334
335if [ $ret_val -eq 0 ]; then
336 echo "[PASS]"
337elif [ $ret_val -eq $ksft_skip ]; then
338 echo "[SKIP]"
339 exitcode=$ksft_skip
340else
341 echo "[FAIL]"
342 exitcode=1
343fi
Ralph Campbellfee9f6d2020-04-22 12:50:27 -0700344
345echo "running HMM smoke test"
346echo "------------------------------------"
347./test_hmm.sh smoke
348ret_val=$?
349
350if [ $ret_val -eq 0 ]; then
351 echo "[PASS]"
352elif [ $ret_val -eq $ksft_skip ]; then
353 echo "[SKIP]"
354 exitcode=$ksft_skip
355else
356 echo "[FAIL]"
357 exitcode=1
358fi
359
David Hildenbrande5bfac52021-06-30 18:52:39 -0700360echo "--------------------------------------------------------"
361echo "running MADV_POPULATE_READ and MADV_POPULATE_WRITE tests"
362echo "--------------------------------------------------------"
363./madv_populate
364ret_val=$?
365
366if [ $ret_val -eq 0 ]; then
367 echo "[PASS]"
368elif [ $ret_val -eq $ksft_skip ]; then
369 echo "[SKIP]"
370 exitcode=$ksft_skip
371else
372 echo "[FAIL]"
373 exitcode=1
374fi
375
Mike Rapoport76fe17e2021-07-07 18:08:15 -0700376echo "running memfd_secret test"
377echo "------------------------------------"
378./memfd_secret
379ret_val=$?
380
381if [ $ret_val -eq 0 ]; then
382 echo "[PASS]"
383elif [ $ret_val -eq $ksft_skip ]; then
384 echo "[SKIP]"
385 exitcode=$ksft_skip
386else
387 echo "[FAIL]"
388 exitcode=1
389fi
390
Zhansaya Bagdauletkyzy68d62892021-09-02 15:00:39 -0700391echo "-------------------------------------------------------"
392echo "running KSM MADV_MERGEABLE test with 10 identical pages"
393echo "-------------------------------------------------------"
Zhansaya Bagdauletkyzya40c80e2021-09-02 15:00:42 -0700394./ksm_tests -M -p 10
395ret_val=$?
396
397if [ $ret_val -eq 0 ]; then
398 echo "[PASS]"
399elif [ $ret_val -eq $ksft_skip ]; then
400 echo "[SKIP]"
401 exitcode=$ksft_skip
402else
403 echo "[FAIL]"
404 exitcode=1
405fi
406
407echo "------------------------"
408echo "running KSM unmerge test"
409echo "------------------------"
410./ksm_tests -U
Zhansaya Bagdauletkyzy68d62892021-09-02 15:00:39 -0700411ret_val=$?
412
413if [ $ret_val -eq 0 ]; then
414 echo "[PASS]"
415elif [ $ret_val -eq $ksft_skip ]; then
416 echo "[SKIP]"
417 exitcode=$ksft_skip
418else
419 echo "[FAIL]"
420 exitcode=1
421fi
422
Zhansaya Bagdauletkyzy39619982021-09-02 15:00:45 -0700423echo "----------------------------------------------------------"
424echo "running KSM test with 10 zero pages and use_zero_pages = 0"
425echo "----------------------------------------------------------"
426./ksm_tests -Z -p 10 -z 0
427ret_val=$?
428
429if [ $ret_val -eq 0 ]; then
430 echo "[PASS]"
431elif [ $ret_val -eq $ksft_skip ]; then
432 echo "[SKIP]"
433 exitcode=$ksft_skip
434else
435 echo "[FAIL]"
436 exitcode=1
437fi
438
439echo "----------------------------------------------------------"
440echo "running KSM test with 10 zero pages and use_zero_pages = 1"
441echo "----------------------------------------------------------"
442./ksm_tests -Z -p 10 -z 1
443ret_val=$?
444
445if [ $ret_val -eq 0 ]; then
446 echo "[PASS]"
447elif [ $ret_val -eq $ksft_skip ]; then
448 echo "[SKIP]"
449 exitcode=$ksft_skip
450else
451 echo "[FAIL]"
452 exitcode=1
453fi
454
Zhansaya Bagdauletkyzy82e717a2021-09-02 15:00:48 -0700455echo "-------------------------------------------------------------"
456echo "running KSM test with 2 NUMA nodes and merge_across_nodes = 1"
457echo "-------------------------------------------------------------"
458./ksm_tests -N -m 1
459ret_val=$?
460
461if [ $ret_val -eq 0 ]; then
462 echo "[PASS]"
463elif [ $ret_val -eq $ksft_skip ]; then
464 echo "[SKIP]"
465 exitcode=$ksft_skip
466else
467 echo "[FAIL]"
468 exitcode=1
469fi
470
471echo "-------------------------------------------------------------"
472echo "running KSM test with 2 NUMA nodes and merge_across_nodes = 0"
473echo "-------------------------------------------------------------"
474./ksm_tests -N -m 0
475ret_val=$?
476
477if [ $ret_val -eq 0 ]; then
478 echo "[PASS]"
479elif [ $ret_val -eq $ksft_skip ]; then
480 echo "[SKIP]"
481 exitcode=$ksft_skip
482else
483 echo "[FAIL]"
484 exitcode=1
485fi
486
Mike Rapoport76fe17e2021-07-07 18:08:15 -0700487exit $exitcode
488
Joern Engel51a1d162013-07-03 15:09:17 -0700489exit $exitcode