aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuah Khan <shuah.kh@samsung.com>2014-07-02 11:51:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-11 21:13:06 -0400
commitddddda9bc41c9214731def8665ad92414356d685 (patch)
tree59f328999b30f14b4f881fd02d3314c052041a46
parent6e7e6c348492cb7e0a8a36a9d74d098de6f93208 (diff)
tools: selftests - create a separate hotplug target for full range test
On some systems, hot-plug tests could hang forever waiting for cpu and memory to be ready to be offlined. A special hot-plug target is created to run full range of hot-plug tests. In default mode, hot-plug tests run in safe mode with a limited scope. In limited mode, cpu-hotplug test is run on a single cpu as opposed to all hotplug capable cpus, and memory hotplug test is run on 2% of hotplug capable memory instead of 10%. In addition to the above change, cpu-hotplug is chnged to change processor affinity to cpu 0 so it doesn't impact itself while the test runs. Signed-off-by: Shuah Khan <shuah.kh@samsung.com> Cc: Kees Cook <keescook@chromium.org> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--tools/testing/selftests/Makefile18
-rw-r--r--tools/testing/selftests/README.txt27
-rw-r--r--tools/testing/selftests/cpu-hotplug/Makefile3
-rw-r--r--tools/testing/selftests/cpu-hotplug/on-off-test.sh52
-rw-r--r--tools/testing/selftests/memory-hotplug/Makefile3
-rw-r--r--tools/testing/selftests/memory-hotplug/on-off-test.sh8
6 files changed, 105 insertions, 6 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index e66e710cc595..4c2aa357e12f 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -12,6 +12,9 @@ TARGETS += powerpc
12TARGETS += user 12TARGETS += user
13TARGETS += sysctl 13TARGETS += sysctl
14 14
15TARGETS_HOTPLUG = cpu-hotplug
16TARGETS_HOTPLUG += memory-hotplug
17
15all: 18all:
16 for TARGET in $(TARGETS); do \ 19 for TARGET in $(TARGETS); do \
17 make -C $$TARGET; \ 20 make -C $$TARGET; \
@@ -22,6 +25,21 @@ run_tests: all
22 make -C $$TARGET run_tests; \ 25 make -C $$TARGET run_tests; \
23 done; 26 done;
24 27
28hotplug:
29 for TARGET in $(TARGETS_HOTPLUG); do \
30 make -C $$TARGET; \
31 done;
32
33run_hotplug: hotplug
34 for TARGET in $(TARGETS_HOTPLUG); do \
35 make -C $$TARGET run_full_test; \
36 done;
37
38clean_hotplug:
39 for TARGET in $(TARGETS_HOTPLUG); do \
40 make -C $$TARGET clean; \
41 done;
42
25clean: 43clean:
26 for TARGET in $(TARGETS); do \ 44 for TARGET in $(TARGETS); do \
27 make -C $$TARGET clean; \ 45 make -C $$TARGET clean; \
diff --git a/tools/testing/selftests/README.txt b/tools/testing/selftests/README.txt
index 5e2faf9c55d3..2660d5ff9179 100644
--- a/tools/testing/selftests/README.txt
+++ b/tools/testing/selftests/README.txt
@@ -4,8 +4,15 @@ The kernel contains a set of "self tests" under the tools/testing/selftests/
4directory. These are intended to be small unit tests to exercise individual 4directory. These are intended to be small unit tests to exercise individual
5code paths in the kernel. 5code paths in the kernel.
6 6
7Running the selftests 7On some systems, hot-plug tests could hang forever waiting for cpu and
8===================== 8memory to be ready to be offlined. A special hot-plug target is created
9to run full range of hot-plug tests. In default mode, hot-plug tests run
10in safe mode with a limited scope. In limited mode, cpu-hotplug test is
11run on a single cpu as opposed to all hotplug capable cpus, and memory
12hotplug test is run on 2% of hotplug capable memory instead of 10%.
13
14Running the selftests (hotplug tests are run in limited mode)
15=============================================================
9 16
10To build the tests: 17To build the tests:
11 18
@@ -18,14 +25,26 @@ To run the tests:
18 25
19- note that some tests will require root privileges. 26- note that some tests will require root privileges.
20 27
21 28To run only tests targeted for a single subsystem: (including
22To run only tests targetted for a single subsystem: 29hotplug targets in limited mode)
23 30
24 $ make -C tools/testing/selftests TARGETS=cpu-hotplug run_tests 31 $ make -C tools/testing/selftests TARGETS=cpu-hotplug run_tests
25 32
26See the top-level tools/testing/selftests/Makefile for the list of all possible 33See the top-level tools/testing/selftests/Makefile for the list of all possible
27targets. 34targets.
28 35
36Running the full range hotplug selftests
37========================================
38
39To build the tests:
40
41 $ make -C tools/testing/selftests hotplug
42
43To run the tests:
44
45 $ make -C tools/testing/selftests run_hotplug
46
47- note that some tests will require root privileges.
29 48
30Contributing new tests 49Contributing new tests
31====================== 50======================
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index 790c23a9db44..e9c28d8dc84b 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -3,4 +3,7 @@ all:
3run_tests: 3run_tests:
4 @/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]" 4 @/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
5 5
6run_full_test:
7 @/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
8
6clean: 9clean:
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh
index bdde7cf428bb..98b1d6565f2c 100644
--- a/tools/testing/selftests/cpu-hotplug/on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/on-off-test.sh
@@ -11,6 +11,8 @@ prerequisite()
11 exit 0 11 exit 0
12 fi 12 fi
13 13
14 taskset -p 01 $$
15
14 SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` 16 SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
15 17
16 if [ ! -d "$SYSFS" ]; then 18 if [ ! -d "$SYSFS" ]; then
@@ -22,6 +24,19 @@ prerequisite()
22 echo $msg cpu hotplug is not supported >&2 24 echo $msg cpu hotplug is not supported >&2
23 exit 0 25 exit 0
24 fi 26 fi
27
28 echo "CPU online/offline summary:"
29 online_cpus=`cat $SYSFS/devices/system/cpu/online`
30 online_max=${online_cpus##*-}
31 echo -e "\t Cpus in online state: $online_cpus"
32
33 offline_cpus=`cat $SYSFS/devices/system/cpu/offline`
34 if [[ "a$offline_cpus" = "a" ]]; then
35 offline_cpus=0
36 else
37 offline_max=${offline_cpus##*-}
38 fi
39 echo -e "\t Cpus in offline state: $offline_cpus"
25} 40}
26 41
27# 42#
@@ -113,15 +128,25 @@ offline_cpu_expect_fail()
113} 128}
114 129
115error=-12 130error=-12
131allcpus=0
116priority=0 132priority=0
133online_cpus=0
134online_max=0
135offline_cpus=0
136offline_max=0
117 137
118while getopts e:hp: opt; do 138while getopts e:ahp: opt; do
119 case $opt in 139 case $opt in
120 e) 140 e)
121 error=$OPTARG 141 error=$OPTARG
122 ;; 142 ;;
143 a)
144 allcpus=1
145 ;;
123 h) 146 h)
124 echo "Usage $0 [ -e errno ] [ -p notifier-priority ]" 147 echo "Usage $0 [ -a ] [ -e errno ] [ -p notifier-priority ]"
148 echo -e "\t default offline one cpu"
149 echo -e "\t run with -a option to offline all cpus"
125 exit 150 exit
126 ;; 151 ;;
127 p) 152 p)
@@ -138,6 +163,29 @@ fi
138prerequisite 163prerequisite
139 164
140# 165#
166# Safe test (default) - offline and online one cpu
167#
168if [ $allcpus -eq 0 ]; then
169 echo "Limited scope test: one hotplug cpu"
170 echo -e "\t (leaves cpu in the original state):"
171 echo -e "\t online to offline to online: cpu $online_max"
172 offline_cpu_expect_success $online_max
173 online_cpu_expect_success $online_max
174
175 if [[ $offline_cpus -gt 0 ]]; then
176 echo -e "\t offline to online to offline: cpu $offline_max"
177 online_cpu_expect_success $offline_max
178 offline_cpu_expect_success $offline_max
179 fi
180 exit 0
181else
182 echo "Full scope test: all hotplug cpus"
183 echo -e "\t online all offline cpus"
184 echo -e "\t offline all online cpus"
185 echo -e "\t online all offline cpus"
186fi
187
188#
141# Online all hot-pluggable CPUs 189# Online all hot-pluggable CPUs
142# 190#
143for cpu in `hotplaggable_offline_cpus`; do 191for cpu in `hotplaggable_offline_cpus`; do
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index 058c76f5d102..d46b8d489cd2 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -1,6 +1,9 @@
1all: 1all:
2 2
3run_tests: 3run_tests:
4 @/bin/bash ./on-off-test.sh -r 2 || echo "memory-hotplug selftests: [FAIL]"
5
6run_full_test:
4 @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]" 7 @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
5 8
6clean: 9clean:
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/on-off-test.sh
index a2816f631542..6cddde0b96f8 100644
--- a/tools/testing/selftests/memory-hotplug/on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/on-off-test.sh
@@ -142,10 +142,16 @@ fi
142 142
143prerequisite 143prerequisite
144 144
145echo "Test scope: $ratio% hotplug memory"
146echo -e "\t online all hotplug memory in offline state"
147echo -e "\t offline $ratio% hotplug memory in online state"
148echo -e "\t online all hotplug memory in offline state"
149
145# 150#
146# Online all hot-pluggable memory 151# Online all hot-pluggable memory
147# 152#
148for memory in `hotplaggable_offline_memory`; do 153for memory in `hotplaggable_offline_memory`; do
154 echo offline-online $memory
149 online_memory_expect_success $memory 155 online_memory_expect_success $memory
150done 156done
151 157
@@ -154,6 +160,7 @@ done
154# 160#
155for memory in `hotpluggable_online_memory`; do 161for memory in `hotpluggable_online_memory`; do
156 if [ $((RANDOM % 100)) -lt $ratio ]; then 162 if [ $((RANDOM % 100)) -lt $ratio ]; then
163 echo online-offline $memory
157 offline_memory_expect_success $memory 164 offline_memory_expect_success $memory
158 fi 165 fi
159done 166done
@@ -162,6 +169,7 @@ done
162# Online all hot-pluggable memory again 169# Online all hot-pluggable memory again
163# 170#
164for memory in `hotplaggable_offline_memory`; do 171for memory in `hotplaggable_offline_memory`; do
172 echo offline-online $memory
165 online_memory_expect_success $memory 173 online_memory_expect_success $memory
166done 174done
167 175