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 <jstan...@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