All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Gongyi <zhaogongyi@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-kselftest@vger.kernel.org>
Cc: <shuah@kernel.org>, <akpm@linux-foundation.org>,
	<akinobu.mita@gmail.com>, Zhao Gongyi <zhaogongyi@huawei.com>
Subject: [PATCH -next v2 4/5] selftests/cpu-hotplug: Reserve one cpu online at least
Date: Mon, 5 Sep 2022 20:45:24 +0800	[thread overview]
Message-ID: <20220905124525.130067-5-zhaogongyi@huawei.com> (raw)
In-Reply-To: <20220905124525.130067-1-zhaogongyi@huawei.com>

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


  parent reply	other threads:[~2022-09-05 12:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 12:45 [PATCH -next v2 0/5] Optimize and bugfix for cpu-on-off-test.sh Zhao Gongyi
2022-09-05 12:45 ` [PATCH -next v2 1/5] selftests/cpu-hotplug: Correct log info Zhao Gongyi
2022-09-05 12:45 ` [PATCH -next v2 2/5] selftests/cpu-hotplug: Use return instead of exit Zhao Gongyi
2022-09-05 12:45 ` [PATCH -next v2 3/5] selftests/cpu-hotplug: Delete fault injection related code Zhao Gongyi
2022-09-05 12:45 ` Zhao Gongyi [this message]
2022-09-05 12:45 ` [PATCH -next v2 5/5] selftests/cpu-hotplug: Add log info when test success Zhao Gongyi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220905124525.130067-5-zhaogongyi@huawei.com \
    --to=zhaogongyi@huawei.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.