2 # SPDX-License-Identifier: GPL-2.0
4 # Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
6 # This is a test script for the kernel test driver to analyse vmalloc
7 # allocator. Therefore it is just a kernel module loader. You can specify
8 # and pass different parameters in order to:
9 # a) analyse performance of vmalloc allocations;
10 # b) stressing and stability check of vmalloc subsystem.
13 DRIVER
="test_${TEST_NAME}"
18 # Kselftest framework requirement - SKIP code is 4.
22 # Static templates for performance, stressing and smoke tests.
23 # Also it is possible to pass any supported parameters manualy.
25 PERF_PARAM
="single_cpu_test=1 sequential_test_order=1 test_repeat_count=3"
26 SMOKE_PARAM
="single_cpu_test=1 test_loop_count=10000 test_repeat_count=10"
27 STRESS_PARAM
="test_repeat_count=20"
29 check_test_requirements
()
32 if [ $uid -ne 0 ]; then
33 echo "$0: Must be run as root"
37 if ! which modprobe
> /dev
/null
2>&1; then
38 echo "$0: You need modprobe installed"
42 if ! modinfo
$DRIVER > /dev
/null
2>&1; then
43 echo "$0: You must have the following enabled in your kernel:"
44 echo "CONFIG_TEST_VMALLOC=m"
49 run_perfformance_check
()
51 echo "Run performance tests to evaluate how fast vmalloc allocation is."
52 echo "It runs all test cases on one single CPU with sequential order."
54 modprobe
$DRIVER $PERF_PARAM > /dev
/null
2>&1
56 echo "Ccheck the kernel message buffer to see the summary."
61 echo "Run stability tests. In order to stress vmalloc subsystem we run"
62 echo "all available test cases on all available CPUs simultaneously."
63 echo "It will take time, so be patient."
65 modprobe
$DRIVER $STRESS_PARAM > /dev
/null
2>&1
67 echo "Check the kernel ring buffer to see the summary."
72 echo "Run smoke test. Note, this test provides basic coverage."
73 echo "Please check $0 output how it can be used"
74 echo "for deep performance analysis as well as stress testing."
76 modprobe
$DRIVER $SMOKE_PARAM > /dev
/null
2>&1
78 echo "Check the kernel ring buffer to see the summary."
83 echo -n "Usage: $0 [ performance ] | [ stress ] | | [ smoke ] | "
84 echo "manual parameters"
86 echo "Valid tests and parameters:"
92 echo "# Shows help message"
95 echo "# Runs 1 test(id_1), repeats it 5 times on all online CPUs"
96 echo "./${DRIVER}.sh run_test_mask=1 test_repeat_count=5"
98 echo -n "# Runs 4 tests(id_1|id_2|id_4|id_16) on one CPU with "
99 echo "sequential order"
100 echo -n "./${DRIVER}.sh single_cpu_test=1 sequential_test_order=1 "
101 echo "run_test_mask=23"
103 echo -n "# Runs all tests on all online CPUs, shuffled order, repeats "
105 echo "./${DRIVER}.sh test_repeat_count=20"
107 echo "# Performance analysis"
108 echo "./${DRIVER}.sh performance"
110 echo "# Stress testing"
111 echo "./${DRIVER}.sh stress"
116 function validate_passed_args
()
118 VALID_ARGS
=`modinfo $DRIVER | awk '/parm:/ {print $2}' | sed 's/:.*//'`
121 # Something has been passed, check it.
123 for passed_arg
in $@
; do
124 key
=${passed_arg//=*/}
125 val
="${passed_arg:$((${#key}+1))}"
128 for valid_arg
in $VALID_ARGS; do
129 if [[ $key = $valid_arg ]] && [[ $val -gt 0 ]]; then
135 if [[ $valid -ne 1 ]]; then
136 echo "Error: key or value is not correct: ${key} $val"
142 function run_manual_check
()
145 # Validate passed parameters. If there is wrong one,
146 # the script exists and does not execute further.
148 validate_passed_args $@
150 echo "Run the test with following parameters: $@"
151 modprobe
$DRIVER $@
> /dev
/null
2>&1
153 echo "Check the kernel ring buffer to see the summary."
158 if [ $# -eq 0 ]; then
161 if [[ "$1" = "performance" ]]; then
162 run_perfformance_check
163 elif [[ "$1" = "stress" ]]; then
165 elif [[ "$1" = "smoke" ]]; then
173 check_test_requirements