* [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh
@ 2022-09-05 13:36 Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 1/5] selftests/cpu-hotplug: Correct log info Zhao Gongyi
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Zhao Gongyi @ 2022-09-05 13:36 UTC (permalink / raw)
To: linux-kernel, linux-kselftest; +Cc: shuah, akpm, akinobu.mita, Zhao Gongyi
1. Correct log info
2. Replace exit with return to make the test exit gracefully
3. Delete fault injection related code
4. Reserve one cpu online when the test offline all cpus
5. Add log info when run full test successfully
Changes in v3:
- Remove config file for patch 2
- Update information of cover letter
Changes in v2:
- Update change log of patch 2
- Update exiting value to avoid incorrect report for patch 2
- Keep online_cpu_expect_fail() and offline_cpu_expect_fail() for
patch 3
Zhao Gongyi (5):
selftests/cpu-hotplug: Correct log info
selftests/cpu-hotplug: Use return instead of exit
selftests/cpu-hotplug: Delete fault injection related code
selftests/cpu-hotplug: Reserve one cpu online at least
selftests/cpu-hotplug: Add log info when test success
tools/testing/selftests/cpu-hotplug/Makefile | 2 +-
tools/testing/selftests/cpu-hotplug/config | 1 -
.../selftests/cpu-hotplug/cpu-on-off-test.sh | 140 +++++-------------
3 files changed, 37 insertions(+), 106 deletions(-)
delete mode 100644 tools/testing/selftests/cpu-hotplug/config
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH -next v3 1/5] selftests/cpu-hotplug: Correct log info
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
@ 2022-09-05 13:36 ` Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 2/5] selftests/cpu-hotplug: Use return instead of exit Zhao Gongyi
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Zhao Gongyi @ 2022-09-05 13:36 UTC (permalink / raw)
To: linux-kernel, linux-kselftest; +Cc: shuah, akpm, akinobu.mita, Zhao Gongyi
Correct the log info to match the test.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index 0d26b5e3f966..1169ef82b55e 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -196,7 +196,7 @@ if [ $allcpus -eq 0 ]; then
online_cpu_expect_success $online_max
if [[ $offline_cpus -gt 0 ]]; then
- echo -e "\t offline to online to offline: cpu $present_max"
+ echo -e "\t online to offline to online: cpu $present_max"
online_cpu_expect_success $present_max
offline_cpu_expect_success $present_max
online_cpu $present_max
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH -next v3 2/5] selftests/cpu-hotplug: Use return instead of exit
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 1/5] selftests/cpu-hotplug: Correct log info Zhao Gongyi
@ 2022-09-05 13:36 ` Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 3/5] selftests/cpu-hotplug: Delete fault injection related code Zhao Gongyi
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Zhao Gongyi @ 2022-09-05 13:36 UTC (permalink / raw)
To: linux-kernel, linux-kselftest; +Cc: shuah, akpm, akinobu.mita, Zhao Gongyi
Some cpus will be left in offline state when online
function exits in some error conditions. Use return
instead of exit to fix it.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
.../selftests/cpu-hotplug/cpu-on-off-test.sh | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index 1169ef82b55e..bd2e791fe887 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -4,6 +4,7 @@
SYSFS=
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
+retval=0
prerequisite()
{
@@ -102,10 +103,10 @@ online_cpu_expect_success()
if ! online_cpu $cpu; then
echo $FUNCNAME $cpu: unexpected fail >&2
- exit 1
+ retval=1
elif ! cpu_is_online $cpu; then
echo $FUNCNAME $cpu: unexpected offline >&2
- exit 1
+ retval=1
fi
}
@@ -128,10 +129,10 @@ offline_cpu_expect_success()
if ! offline_cpu $cpu; then
echo $FUNCNAME $cpu: unexpected fail >&2
- exit 1
+ retval=1
elif ! cpu_is_offline $cpu; then
echo $FUNCNAME $cpu: unexpected offline >&2
- exit 1
+ retval=1
fi
}
@@ -201,7 +202,7 @@ if [ $allcpus -eq 0 ]; then
offline_cpu_expect_success $present_max
online_cpu $present_max
fi
- exit 0
+ exit $retval
else
echo "Full scope test: all hotplug cpus"
echo -e "\t online all offline cpus"
@@ -291,3 +292,5 @@ done
echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
/sbin/modprobe -q -r cpu-notifier-error-inject
+
+exit $retval
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH -next v3 3/5] selftests/cpu-hotplug: Delete fault injection related code
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 1/5] selftests/cpu-hotplug: Correct log info Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 2/5] selftests/cpu-hotplug: Use return instead of exit Zhao Gongyi
@ 2022-09-05 13:36 ` Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 4/5] selftests/cpu-hotplug: Reserve one cpu online at least Zhao Gongyi
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Zhao Gongyi @ 2022-09-05 13:36 UTC (permalink / raw)
To: linux-kernel, linux-kselftest; +Cc: shuah, akpm, akinobu.mita, Zhao Gongyi
Delete fault injection related code since the module has been deleted.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
tools/testing/selftests/cpu-hotplug/config | 1 -
.../selftests/cpu-hotplug/cpu-on-off-test.sh | 87 ++-----------------
2 files changed, 6 insertions(+), 82 deletions(-)
delete mode 100644 tools/testing/selftests/cpu-hotplug/config
diff --git a/tools/testing/selftests/cpu-hotplug/config b/tools/testing/selftests/cpu-hotplug/config
deleted file mode 100644
index d4aca2ad5069..000000000000
--- a/tools/testing/selftests/cpu-hotplug/config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_NOTIFIER_ERROR_INJECTION=y
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index bd2e791fe887..184156763ccb 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -116,10 +116,10 @@ online_cpu_expect_fail()
if online_cpu $cpu 2> /dev/null; then
echo $FUNCNAME $cpu: unexpected success >&2
- exit 1
+ retval=1
elif ! cpu_is_offline $cpu; then
echo $FUNCNAME $cpu: unexpected online >&2
- exit 1
+ retval=1
fi
}
@@ -142,16 +142,14 @@ offline_cpu_expect_fail()
if offline_cpu $cpu 2> /dev/null; then
echo $FUNCNAME $cpu: unexpected success >&2
- exit 1
+ retval=1
elif ! cpu_is_online $cpu; then
echo $FUNCNAME $cpu: unexpected offline >&2
- exit 1
+ retval=1
fi
}
-error=-12
allcpus=0
-priority=0
online_cpus=0
online_max=0
offline_cpus=0
@@ -159,31 +157,20 @@ offline_max=0
present_cpus=0
present_max=0
-while getopts e:ahp: opt; do
+while getopts ah opt; do
case $opt in
- e)
- error=$OPTARG
- ;;
a)
allcpus=1
;;
h)
- echo "Usage $0 [ -a ] [ -e errno ] [ -p notifier-priority ]"
+ echo "Usage $0 [ -a ]"
echo -e "\t default offline one cpu"
echo -e "\t run with -a option to offline all cpus"
exit
;;
- p)
- priority=$OPTARG
- ;;
esac
done
-if ! [ "$error" -ge -4095 -a "$error" -lt 0 ]; then
- echo "error code must be -4095 <= errno < 0" >&2
- exit 1
-fi
-
prerequisite
#
@@ -231,66 +218,4 @@ for cpu in `hotplaggable_offline_cpus`; do
online_cpu_expect_success $cpu
done
-#
-# Test with cpu notifier error injection
-#
-
-DEBUGFS=`mount -t debugfs | head -1 | awk '{ print $3 }'`
-NOTIFIER_ERR_INJECT_DIR=$DEBUGFS/notifier-error-inject/cpu
-
-prerequisite_extra()
-{
- msg="skip extra tests:"
-
- /sbin/modprobe -q -r cpu-notifier-error-inject
- /sbin/modprobe -q cpu-notifier-error-inject priority=$priority
-
- if [ ! -d "$DEBUGFS" ]; then
- echo $msg debugfs is not mounted >&2
- exit $ksft_skip
- fi
-
- if [ ! -d $NOTIFIER_ERR_INJECT_DIR ]; then
- echo $msg cpu-notifier-error-inject module is not available >&2
- exit $ksft_skip
- fi
-}
-
-prerequisite_extra
-
-#
-# Offline all hot-pluggable CPUs
-#
-echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
-for cpu in `hotpluggable_online_cpus`; do
- offline_cpu_expect_success $cpu
-done
-
-#
-# Test CPU hot-add error handling (offline => online)
-#
-echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error
-for cpu in `hotplaggable_offline_cpus`; do
- online_cpu_expect_fail $cpu
-done
-
-#
-# Online all hot-pluggable CPUs
-#
-echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_UP_PREPARE/error
-for cpu in `hotplaggable_offline_cpus`; do
- online_cpu_expect_success $cpu
-done
-
-#
-# Test CPU hot-remove error handling (online => offline)
-#
-echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
-for cpu in `hotpluggable_online_cpus`; do
- offline_cpu_expect_fail $cpu
-done
-
-echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
-/sbin/modprobe -q -r cpu-notifier-error-inject
-
exit $retval
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH -next v3 4/5] selftests/cpu-hotplug: Reserve one cpu online at least
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
` (2 preceding siblings ...)
2022-09-05 13:36 ` [PATCH -next v3 3/5] selftests/cpu-hotplug: Delete fault injection related code Zhao Gongyi
@ 2022-09-05 13:36 ` Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 5/5] selftests/cpu-hotplug: Add log info when test success Zhao Gongyi
2022-09-07 21:48 ` [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Shuah Khan
5 siblings, 0 replies; 7+ messages in thread
From: Zhao Gongyi @ 2022-09-05 13:36 UTC (permalink / raw)
To: linux-kernel, linux-kselftest; +Cc: shuah, akpm, akinobu.mita, Zhao Gongyi
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>
---
.../selftests/cpu-hotplug/cpu-on-off-test.sh | 40 ++++++++++---------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index 184156763ccb..d5dc7e0dc726 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -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
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH -next v3 5/5] selftests/cpu-hotplug: Add log info when test success
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
` (3 preceding siblings ...)
2022-09-05 13:36 ` [PATCH -next v3 4/5] selftests/cpu-hotplug: Reserve one cpu online at least Zhao Gongyi
@ 2022-09-05 13:36 ` Zhao Gongyi
2022-09-07 21:48 ` [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Shuah Khan
5 siblings, 0 replies; 7+ messages in thread
From: Zhao Gongyi @ 2022-09-05 13:36 UTC (permalink / raw)
To: linux-kernel, linux-kselftest; +Cc: shuah, akpm, akinobu.mita, Zhao Gongyi
Add log information when run full test successfully.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
tools/testing/selftests/cpu-hotplug/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index d8be047ee5b6..8b66c4738344 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -6,6 +6,6 @@ TEST_PROGS := cpu-on-off-test.sh
include ../lib.mk
run_full_test:
- @/bin/bash ./cpu-on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
+ @/bin/bash ./cpu-on-off-test.sh -a && echo "cpu-hotplug selftests: [PASS]" || echo "cpu-hotplug selftests: [FAIL]"
clean:
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
` (4 preceding siblings ...)
2022-09-05 13:36 ` [PATCH -next v3 5/5] selftests/cpu-hotplug: Add log info when test success Zhao Gongyi
@ 2022-09-07 21:48 ` Shuah Khan
5 siblings, 0 replies; 7+ messages in thread
From: Shuah Khan @ 2022-09-07 21:48 UTC (permalink / raw)
To: Zhao Gongyi, linux-kernel, linux-kselftest
Cc: shuah, akpm, akinobu.mita, Shuah Khan
On 9/5/22 07:36, Zhao Gongyi wrote:
> 1. Correct log info
> 2. Replace exit with return to make the test exit gracefully
> 3. Delete fault injection related code
> 4. Reserve one cpu online when the test offline all cpus
> 5. Add log info when run full test successfully
>
> Changes in v3:
> - Remove config file for patch 2
> - Update information of cover letter
>
Thank you fixing the issues in v2. Now applied to linux-kselftest next
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-09-07 21:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 13:36 [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 1/5] selftests/cpu-hotplug: Correct log info Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 2/5] selftests/cpu-hotplug: Use return instead of exit Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 3/5] selftests/cpu-hotplug: Delete fault injection related code Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 4/5] selftests/cpu-hotplug: Reserve one cpu online at least Zhao Gongyi
2022-09-05 13:36 ` [PATCH -next v3 5/5] selftests/cpu-hotplug: Add log info when test success Zhao Gongyi
2022-09-07 21:48 ` [PATCH -next v3 0/5] Optimize and bugfix for cpu-on-off-test.sh Shuah Khan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.