* [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs
@ 2015-04-28 12:02 Jan Stancek
2015-04-28 12:02 ` [LTP] [PATCH 2/2] cpuhotplug04: check that all but last CPU can be offlined Jan Stancek
2015-04-28 13:07 ` [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs Cyril Hrubis
0 siblings, 2 replies; 3+ messages in thread
From: Jan Stancek @ 2015-04-28 12:02 UTC (permalink / raw)
To: ltp-list
Testcases trying to offline/online not present CPUs
currently fail on powerpc with IBM PowerVM hypervisor.
In this setup, Linux guest usually sees all CPUs host has,
but most of them are not present (usable by guest). Attempt
to bring them online fails (presumably because lpar config
does not allow to do so).
Add get_present_cpus function and try to online/offline only
CPUs linux guest sees as 'present'. Very old kernels which
do not provide present cpu mask will try to use all CPUs.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
.../hotplug/cpu_hotplug/functional/cpuhotplug01.sh | 4 +-
.../hotplug/cpu_hotplug/functional/cpuhotplug03.sh | 2 +-
.../hotplug/cpu_hotplug/functional/cpuhotplug04.sh | 4 +-
.../cpu_hotplug/include/cpuhotplug_hotplug.sh | 50 ++++++++++++++++++----
4 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
index f91cf88..2cff3ba 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
@@ -151,7 +151,7 @@ do
IRQ_START=$(cat /proc/interrupts)
# Attempt to offline all CPUs
- for cpu in $( get_all_cpus ); do
+ for cpu in $( get_present_cpus ); do
if [ "$cpu" = "cpu0" ]; then
continue
fi
@@ -166,7 +166,7 @@ do
done
# Attempt to online all CPUs
- for cpu in $( get_all_cpus ); do
+ for cpu in $( get_present_cpus ); do
if [ "$cpu" = "cpu0" ]; then
continue
fi
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
index 8176fb3..7830f35 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
@@ -87,7 +87,7 @@ until [ $LOOP_COUNT -gt $HOTPLUG03_LOOPS ]; do
number_of_cpus=0
# Turns on all CPUs and saves their states
- for i in $( get_all_cpus ); do
+ for i in $( get_present_cpus ); do
if [ "$i" = "cpu0" ]; then
continue
fi
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
index 72fbc6e..6c9bb30 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
@@ -69,7 +69,7 @@ until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do
cpustate=1
# Online all the CPUs' keep track of which were already on
- for i in $(get_all_cpus); do
+ for i in $(get_present_cpus); do
if [ "$i" != "cpu0" ]; then
if ! cpu_is_online $i; then
if ! online_cpu $i; then
@@ -87,7 +87,7 @@ until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do
done
# Now offline all the CPUs
- for i in $(get_all_cpus); do
+ for i in $(get_present_cpus); do
if ! offline_cpu $i; then
if [ "x$i" != "xcpu0" ]; then
tst_resm TFAIL "Did not offline first CPU (offlined $i instead)"
diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
index dd8472f..297724a 100644
--- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
@@ -99,32 +99,64 @@ offline_cpu()
# get_cpus_num()
#
-# Prints the number of all available CPUs, regardless of whether they're
+# Prints the number of all present CPUs, regardless of whether they're
# currently online or offline.
#
get_cpus_num()
{
- [ -d /sys/devices/system/cpu/cpu0 ] || return -1
- NUM=`ls /sys/devices/system/cpu/ \
- | grep -c "cpu[0-9][0-9]*"`
- return $NUM
+ local num=$(get_present_cpus | wc -w)
+ return $num
}
# get_all_cpus()
#
# Prints a list of all available CPUs, regardless of whether they're
-# currently online or offline.
+# present.
#
# This routine will work even if the CPUs are not hotpluggable, however
# it requires you have sysfs enabled in the kernel.
#
get_all_cpus()
{
- [ -d /sys/devices/system/cpu/cpu0 ] || return 1
- ls -dr /sys/devices/system/cpu/cpu[0-9]* | \
- sed "s/\/sys\/devices\/system\/cpu\///g" || return 2
+ [ -d /sys/devices/system/cpu ] || return 1
+ (cd /sys/devices/system/cpu; ls -d cpu[0-9]*)
}
+# get_present_cpus()
+#
+# Prints a list of present CPUs, regardless of whether they're
+# currently online or offline.
+#
+# This routine will work even if the CPUs are not hotpluggable, however
+# it requires you have sysfs enabled in the kernel.
+#
+get_present_cpus()
+{
+ # if sysfs present mask is missing, assume all cpu are present
+ if [ ! -e /sys/devices/system/cpu/present ]; then
+ get_all_cpus
+ return
+ fi
+
+ local present_mask="/sys/devices/system/cpu/present"
+ local present_cpus=""
+
+ for part in $(cat $present_mask | tr "," " "); do
+ if echo $part | grep -q "-"; then
+ range_low=$(echo $part | cut -d - -f 1)
+ range_high=$(echo $part | cut -d - -f 2)
+ else
+ range_low=$(part)
+ range_high=$(part)
+ fi
+ for cpu in $(seq $range_low $range_high); do
+ if [ -e /sys/devices/system/cpu/cpu$cpu ]; then
+ present_cpus="$present_cpus cpu$cpu"
+ fi
+ done
+ done
+ echo $present_cpus
+}
# get_all_cpu_states()
#
--
1.8.3.1
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread* [LTP] [PATCH 2/2] cpuhotplug04: check that all but last CPU can be offlined
2015-04-28 12:02 [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs Jan Stancek
@ 2015-04-28 12:02 ` Jan Stancek
2015-04-28 13:07 ` [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2015-04-28 12:02 UTC (permalink / raw)
To: ltp-list
This testcase check looks wrong. Failing to offline CPU X
does not mean that it failed to offline CPU 0.
Change the condition to check, that all but last CPU can
be offlined.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
.../kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
index 6c9bb30..4fc6399 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
@@ -87,19 +87,22 @@ until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do
done
# Now offline all the CPUs
+ failed_to_offline=0
for i in $(get_present_cpus); do
if ! offline_cpu $i; then
- if [ "x$i" != "xcpu0" ]; then
- tst_resm TFAIL "Did not offline first CPU (offlined $i instead)"
- tst_exit
- fi
+ tst_resm TINFO "Failed to offline $i"
+ failed_to_offline=$((failed_to_offline + 1))
fi
done
+ if [ "$failed_to_offline" -gt 1 ]; then
+ tst_resm TFAIL "$failed_to_offline CPUs failed to offline"
+ tst_exit
+ fi
LOOP_COUNT=$((LOOP_COUNT+1))
done
-tst_resm TPASS "Successfully offlined first CPU, $i"
+tst_resm TPASS "Successfully offlined all but last CPU"
tst_exit
--
1.8.3.1
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs
2015-04-28 12:02 [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs Jan Stancek
2015-04-28 12:02 ` [LTP] [PATCH 2/2] cpuhotplug04: check that all but last CPU can be offlined Jan Stancek
@ 2015-04-28 13:07 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2015-04-28 13:07 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Hi!
Both patches looks good to me, acked.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-28 13:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-28 12:02 [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs Jan Stancek
2015-04-28 12:02 ` [LTP] [PATCH 2/2] cpuhotplug04: check that all but last CPU can be offlined Jan Stancek
2015-04-28 13:07 ` [LTP] [PATCH 1/2] cpu_hotplug: use present rather than all CPUs Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox