~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/mm/test_vmalloc.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 #
  4 # Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
  5 #
  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.
 11 
 12 TEST_NAME="vmalloc"
 13 DRIVER="test_${TEST_NAME}"
 14 NUM_CPUS=`grep -c ^processor /proc/cpuinfo`
 15 
 16 # 1 if fails
 17 exitcode=1
 18 
 19 # Kselftest framework requirement - SKIP code is 4.
 20 ksft_skip=4
 21 
 22 #
 23 # Static templates for performance, stressing and smoke tests.
 24 # Also it is possible to pass any supported parameters manualy.
 25 #
 26 PERF_PARAM="sequential_test_order=1 test_repeat_count=3"
 27 SMOKE_PARAM="test_loop_count=10000 test_repeat_count=10"
 28 STRESS_PARAM="nr_threads=$NUM_CPUS test_repeat_count=20"
 29 
 30 check_test_requirements()
 31 {
 32         uid=$(id -u)
 33         if [ $uid -ne 0 ]; then
 34                 echo "$0: Must be run as root"
 35                 exit $ksft_skip
 36         fi
 37 
 38         if ! which modprobe > /dev/null 2>&1; then
 39                 echo "$0: You need modprobe installed"
 40                 exit $ksft_skip
 41         fi
 42 
 43         if ! modinfo $DRIVER > /dev/null 2>&1; then
 44                 echo "$0: You must have the following enabled in your kernel:"
 45                 echo "CONFIG_TEST_VMALLOC=m"
 46                 exit $ksft_skip
 47         fi
 48 }
 49 
 50 run_perfformance_check()
 51 {
 52         echo "Run performance tests to evaluate how fast vmalloc allocation is."
 53         echo "It runs all test cases on one single CPU with sequential order."
 54 
 55         modprobe $DRIVER $PERF_PARAM > /dev/null 2>&1
 56         echo "Done."
 57         echo "Ccheck the kernel message buffer to see the summary."
 58 }
 59 
 60 run_stability_check()
 61 {
 62         echo "Run stability tests. In order to stress vmalloc subsystem all"
 63         echo "available test cases are run by NUM_CPUS workers simultaneously."
 64         echo "It will take time, so be patient."
 65 
 66         modprobe $DRIVER $STRESS_PARAM > /dev/null 2>&1
 67         echo "Done."
 68         echo "Check the kernel ring buffer to see the summary."
 69 }
 70 
 71 run_smoke_check()
 72 {
 73         echo "Run smoke test. Note, this test provides basic coverage."
 74         echo "Please check $0 output how it can be used"
 75         echo "for deep performance analysis as well as stress testing."
 76 
 77         modprobe $DRIVER $SMOKE_PARAM > /dev/null 2>&1
 78         echo "Done."
 79         echo "Check the kernel ring buffer to see the summary."
 80 }
 81 
 82 usage()
 83 {
 84         echo -n "Usage: $0 [ performance ] | [ stress ] | | [ smoke ] | "
 85         echo "manual parameters"
 86         echo
 87         echo "Valid tests and parameters:"
 88         echo
 89         modinfo $DRIVER
 90         echo
 91         echo "Example usage:"
 92         echo
 93         echo "# Shows help message"
 94         echo "./${DRIVER}.sh"
 95         echo
 96         echo "# Runs 1 test(id_1), repeats it 5 times by NUM_CPUS workers"
 97         echo "./${DRIVER}.sh nr_threads=$NUM_CPUS run_test_mask=1 test_repeat_count=5"
 98         echo
 99         echo -n "# Runs 4 tests(id_1|id_2|id_4|id_16) on one CPU with "
100         echo "sequential order"
101         echo -n "./${DRIVER}.sh sequential_test_order=1 "
102         echo "run_test_mask=23"
103         echo
104         echo -n "# Runs all tests by NUM_CPUS workers, shuffled order, repeats "
105         echo "20 times"
106         echo "./${DRIVER}.sh nr_threads=$NUM_CPUS test_repeat_count=20"
107         echo
108         echo "# Performance analysis"
109         echo "./${DRIVER}.sh performance"
110         echo
111         echo "# Stress testing"
112         echo "./${DRIVER}.sh stress"
113         echo
114         exit 0
115 }
116 
117 function validate_passed_args()
118 {
119         VALID_ARGS=`modinfo $DRIVER | awk '/parm:/ {print $2}' | sed 's/:.*//'`
120 
121         #
122         # Something has been passed, check it.
123         #
124         for passed_arg in $@; do
125                 key=${passed_arg//=*/}
126                 val="${passed_arg:$((${#key}+1))}"
127                 valid=0
128 
129                 for valid_arg in $VALID_ARGS; do
130                         if [[ $key = $valid_arg ]] && [[ $val -gt 0 ]]; then
131                                 valid=1
132                                 break
133                         fi
134                 done
135 
136                 if [[ $valid -ne 1 ]]; then
137                         echo "Error: key or value is not correct: ${key} $val"
138                         exit $exitcode
139                 fi
140         done
141 }
142 
143 function run_manual_check()
144 {
145         #
146         # Validate passed parameters. If there is wrong one,
147         # the script exists and does not execute further.
148         #
149         validate_passed_args $@
150 
151         echo "Run the test with following parameters: $@"
152         modprobe $DRIVER $@ > /dev/null 2>&1
153         echo "Done."
154         echo "Check the kernel ring buffer to see the summary."
155 }
156 
157 function run_test()
158 {
159         if [ $# -eq 0 ]; then
160                 usage
161         else
162                 if [[ "$1" = "performance" ]]; then
163                         run_perfformance_check
164                 elif [[ "$1" = "stress" ]]; then
165                         run_stability_check
166                 elif [[ "$1" = "smoke" ]]; then
167                         run_smoke_check
168                 else
169                         run_manual_check $@
170                 fi
171         fi
172 }
173 
174 check_test_requirements
175 run_test $@
176 
177 exit 0

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php