]> git.baikalelectronics.ru Git - kernel.git/commitdiff
selftests/cpu-hotplug: Reserve one cpu online at least
authorZhao Gongyi <zhaogongyi@huawei.com>
Mon, 5 Sep 2022 13:36:14 +0000 (21:36 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 5 Oct 2022 17:05:18 +0000 (11:05 -0600)
Considering that we can not offline all cpus in any cases,
we need to reserve one cpu online when the test offline all
hotpluggable online cpus, otherwise the test will fail forever.

Fixes: d89dffa976bc ("fault-injection: add selftests for cpu and memory hotplug")
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh

index 184156763ccb8fe2f5c6d6e42270b83d192b2700..d5dc7e0dc726351a739bc487ee72bae9bd6cf090 100755 (executable)
@@ -149,6 +149,25 @@ offline_cpu_expect_fail()
        fi
 }
 
+online_all_hot_pluggable_cpus()
+{
+       for cpu in `hotplaggable_offline_cpus`; do
+               online_cpu_expect_success $cpu
+       done
+}
+
+offline_all_hot_pluggable_cpus()
+{
+       local reserve_cpu=$online_max
+       for cpu in `hotpluggable_online_cpus`; do
+               # Reserve one cpu oneline at least.
+               if [ $cpu -eq $reserve_cpu ];then
+                       continue
+               fi
+               offline_cpu_expect_success $cpu
+       done
+}
+
 allcpus=0
 online_cpus=0
 online_max=0
@@ -197,25 +216,10 @@ else
        echo -e "\t online all offline cpus"
 fi
 
-#
-# Online all hot-pluggable CPUs
-#
-for cpu in `hotplaggable_offline_cpus`; do
-       online_cpu_expect_success $cpu
-done
+online_all_hot_pluggable_cpus
 
-#
-# Offline all hot-pluggable CPUs
-#
-for cpu in `hotpluggable_online_cpus`; do
-       offline_cpu_expect_success $cpu
-done
+offline_all_hot_pluggable_cpus
 
-#
-# Online all hot-pluggable CPUs again
-#
-for cpu in `hotplaggable_offline_cpus`; do
-       online_cpu_expect_success $cpu
-done
+online_all_hot_pluggable_cpus
 
 exit $retval