(merged) cpuhotplug fixes
v3 cover (merged) cpuhotplug fixes
Hi,
This patchset is result of merge of following series:
http://article.gmane.org/gmane.linux.ltp/22762
http://article.gmane.org/gmane.linux.ltp/22678
It is based on patchset from Stanislav, with changes noted below:
1. cpuhotplug: use cpu states in cleanup
no changes to Stanislav's version
2. cpu_hotplug: added get_hotplug_cpus, get_hotplug_cpus_num This patch has been merged with my 'get_present_cpus' patch, get_hotplug_cpus has been modified to operate on present cpus only.
3. cpu_hotplug: use hotplug/present cpus functions
This comes from my series, there is no counterpart or conflict with Stanislav's patchset.
4. cpuhotplug04.sh: operate only with hotpluggable CPUs minor change here to use number of present CPUs, rather than all
Changes in v3:
+ use present_mask variable in get_present_cpus
+ no special treatment for cpu0 in cpuhotplug03
+ fix cpuhotplug03 to spawn (number of present cpus)*2 processes
+ this time whole series has correct version in subject
Regards,
Jan
Jan Stancek (1):
cpu_hotplug: use hotplug/present cpus functions
Stanislav Kholmanskikh (3):
cpuhotplug: use cpu states in cleanup
cpu_hotplug: add get_hotplug_cpus, get_present_cpus cpuhotplug04.sh: operate only with hotpluggable CPUs
.../hotplug/cpu_hotplug/functional/cpuhotplug01.sh | 17 ++--- .../hotplug/cpu_hotplug/functional/cpuhotplug02.sh | 2 +- .../hotplug/cpu_hotplug/functional/cpuhotplug03.sh | 32 +++----- .../hotplug/cpu_hotplug/functional/cpuhotplug04.sh | 74 +++++++++--------- .../hotplug/cpu_hotplug/functional/cpuhotplug05.sh | 2 +- .../hotplug/cpu_hotplug/functional/cpuhotplug06.sh | 2 +- .../hotplug/cpu_hotplug/functional/cpuhotplug07.sh | 2 +- .../cpu_hotplug/include/cpuhotplug_hotplug.sh | 89 +++++++++++++++++++--- 8 files changed, 140 insertions(+), 80 deletions(-)
Signature · 13 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v3 1/4 cpuhotplug: use cpu states in cleanup
From: Stanislav Kholmanskikh <[email protected]>
There is a couple of good functions:
* get_all_cpu_states
* set_all_cpu_states
which can help to avoid unnecessary cleanup logic in test cases.
So let's use them.
Also modified offline_cpu and online_cpu, so now they do nothing if the cpu is already in the desired state.
--- .../hotplug/cpu_hotplug/functional/cpuhotplug01.sh | 11 ++++------- .../hotplug/cpu_hotplug/functional/cpuhotplug03.sh | 12 +++++------- .../hotplug/cpu_hotplug/functional/cpuhotplug04.sh | 18 +++++------------- .../hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh | 16 ++++++++++------ 4 files changed, 24 insertions(+), 33 deletions(-)
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh +4 -7
@@ -45,13 +45,8 @@ do_clean() { kill_pid ${WRL_ID} - # Turns off the cpus that were off before the test start - until [ $CPU_COUNT -eq 0 ]; do - offline_cpu=$(eval "echo \$OFFLINE_CPU_${CPU_COUNT}") - tst_resm TINFO "CPU = $CPU_COUNT @on = $offline_cpu" - offline_cpu $offline_cpu - CPU_COUNT=$((CPU_COUNT-1)) - done + # Restore CPU states + set_all_cpu_states "$cpu_states" }
@@ -138,6 +133,8 @@ fi TST_CLEANUP=do_clean +cpu_states=$(get_all_cpu_states) + CPU_COUNT=0 # Start up a process that writes to disk; keep track of its PID
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh +5 -7
@@ -46,11 +46,8 @@ do_clean() rm /var/run/hotplug4_$$.pid fi - # Turn off the CPUs that were off before the test start - until [ $cpu -eq 0 ];do - offline_cpu $(eval "echo \$on_${cpu}") - cpu=$((cpu-1)) - done + # Restore CPU states + set_all_cpu_states "$cpu_states" } while getopts c:l: OPTION; do
@@ -82,11 +79,13 @@ fi TST_CLEANUP=do_clean +cpu_states=$(get_all_cpu_states) + until [ $LOOP_COUNT -gt $HOTPLUG03_LOOPS ]; do cpu=0 number_of_cpus=0 - # Turns on all CPUs and saves their states + # Turns on all CPUs for i in $( get_all_cpus ); do if [ "$i" = "cpu0" ]; then continue
@@ -96,7 +95,6 @@ until [ $LOOP_COUNT -gt $HOTPLUG03_LOOPS ]; do tst_brkm TBROK "Could not online cpu $i" fi cpu=$((cpu+1)) - eval "on_${cpu}=$i" fi number_of_cpus=$((number_of_cpus+1)) done
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh +5 -13
@@ -33,17 +33,8 @@ EOF do_clean() { # Online the ones that were on initially - until [ $cpu -eq 0 ]; do - online_cpu $(eval "echo \$on_${cpu}") - cpu=$((cpu-1)) - done - - # Return CPU 0 to its initial state - if [ $cpustate = 1 ]; then - online_cpu 0 - else - offline_cpu 0 - fi + # Restore CPU states + set_all_cpu_states "$cpu_states" } while getopts l: OPTION; do
@@ -64,11 +55,13 @@ fi TST_CLEANUP=do_clean +cpu_states=$(get_all_cpu_states) + until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do cpu=0 cpustate=1 - # Online all the CPUs' keep track of which were already on + # Online all the CPUs for i in $(get_all_cpus); do if [ "$i" != "cpu0" ]; then if ! cpu_is_online $i; then
@@ -77,7 +70,6 @@ until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do fi fi cpu=$((cpu+1)) - eval "on_${cpu}=$i" echo $i else if online_cpu $i; then
testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh +10 -6
@@ -73,6 +73,9 @@ online_cpu() if [ ! -w /sys/devices/system/cpu/cpu${CPU}/online ]; then return 1 fi + + cpu_is_online ${CPU} && return 0 + $TIME echo 1 > /sys/devices/system/cpu/cpu${CPU}/online RC=$? report_timing "Online cpu ${CPU}"
@@ -91,6 +94,9 @@ offline_cpu() if [ ! -w /sys/devices/system/cpu/cpu${CPU}/online ]; then return 1 fi + + ! cpu_is_online ${CPU} && return 0 + $TIME echo 0 > /sys/devices/system/cpu/cpu${CPU}/online RC=$? report_timing "Offline cpu ${CPU}"
@@ -141,20 +147,18 @@ get_all_cpu_states() # set_all_cpu_states(STATES) # -# Sets all of the CPU states according to $STATE, which must be +# Sets all of the CPU states according to STATES, which must be # of the form "cpuX:Y", where X is the CPU number and Y its state. # Each must be on a separate line. # set_all_cpu_states() { - for cpu_state in $STATE; do - cpu=`echo $c | cut -d: -f 1` - state=`echo $c | cut -d: -f 1` + for cpu_state in $1; do + cpu=`echo $cpu_state | cut -d: -f 1` + state=`echo $cpu_state | cut -d: -f 2` if [ $state = 1 ]; then - echo "# Re-onlining $cpu" online_cpu $cpu else - echo "# Re-offlining $cpu" offline_cpu $cpu fi done
Signature · 13 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v3 2/4 cpu_hotplug: add get_hotplug_cpus, get_present_cpus
In reply to Jan StancekFrom: Stanislav Kholmanskikh <[email protected]>
--- .../cpu_hotplug/include/cpuhotplug_hotplug.sh | 73 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-)
testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh +70 -3
@@ -126,11 +126,78 @@ get_cpus_num() # 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. +# +get_present_cpus() +{ + local present_mask="/sys/devices/system/cpu/present" + local present_cpus="" + + # if sysfs present mask is missing, assume all cpu are present + if [ ! -e "$present_mask" ]; then + get_all_cpus + return + fi + + 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_present_cpus_num() +# +# Prints the number of present CPUs +# +get_present_cpus_num() +{ + return $(get_present_cpus | wc -w) +} + +# get_hotplug_cpus() +# +# Prints a list of present hotpluggable CPUs, regardless of whether they're +# currently online or offline. +# +get_hotplug_cpus() +{ + local present_cpus=$(get_present_cpus) + local hotplug_cpus="" + + for cpu in $present_cpus; do + if [ -e /sys/devices/system/cpu/$cpu/online ]; then + hotplug_cpus="$hotplug_cpus $cpu" + fi + done + echo $hotplug_cpus +} + +# get_hotplug_cpus_num() +# +# Prints the number of hotpluggable CPUs +# +get_hotplug_cpus_num() +{ + return $(get_hotplug_cpus | wc -w) +} # get_all_cpu_states() #
Signature · 13 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v3 3/4 cpu_hotplug: use hotplug/present cpus functions
In reply to Jan StancekAlso, make no special treatment for cpu0.
--- .../hotplug/cpu_hotplug/functional/cpuhotplug01.sh | 6 +++--- .../hotplug/cpu_hotplug/functional/cpuhotplug02.sh | 2 +- .../hotplug/cpu_hotplug/functional/cpuhotplug03.sh | 20 +++++++------------- .../hotplug/cpu_hotplug/functional/cpuhotplug04.sh | 4 ++-- .../hotplug/cpu_hotplug/functional/cpuhotplug05.sh | 2 +- .../hotplug/cpu_hotplug/functional/cpuhotplug06.sh | 2 +- .../hotplug/cpu_hotplug/functional/cpuhotplug07.sh | 2 +- 7 files changed, 16 insertions(+), 22 deletions(-)
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh +3 -3
@@ -111,7 +111,7 @@ LOOP_COUNT=1 tst_check_cmds perl -get_cpus_num +get_present_cpus_num if [ $? -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi
@@ -148,7 +148,7 @@ do IRQ_START=$(cat /proc/interrupts) # Attempt to offline all CPUs - for cpu in $( get_all_cpus ); do + for cpu in $( get_hotplug_cpus ); do if [ "$cpu" = "cpu0" ]; then continue fi
@@ -163,7 +163,7 @@ do done # Attempt to online all CPUs - for cpu in $( get_all_cpus ); do + for cpu in $( get_hotplug_cpus ); do if [ "$cpu" = "cpu0" ]; then continue fi
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh +1 -1
@@ -54,7 +54,7 @@ done LOOP_COUNT=1 -get_cpus_num +get_present_cpus_num if [ $? -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh +7 -13
@@ -63,8 +63,9 @@ done LOOP_COUNT=1 -get_cpus_num -if [ $? -lt 2 ]; then +get_present_cpus_num +cpus_num=$? +if [ $cpus_num -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi
@@ -82,21 +83,14 @@ TST_CLEANUP=do_clean cpu_states=$(get_all_cpu_states) until [ $LOOP_COUNT -gt $HOTPLUG03_LOOPS ]; do - cpu=0 - number_of_cpus=0 # Turns on all CPUs - for i in $( get_all_cpus ); do - if [ "$i" = "cpu0" ]; then - continue - fi + for i in $( get_hotplug_cpus ); do if ! cpu_is_online $i; then if ! online_cpu $i; then tst_brkm TBROK "Could not online cpu $i" fi - cpu=$((cpu+1)) fi - number_of_cpus=$((number_of_cpus+1)) done if ! offline_cpu ${CPU_TO_TEST} ; then
@@ -107,11 +101,11 @@ until [ $LOOP_COUNT -gt $HOTPLUG03_LOOPS ]; do # CPUs we have. This is to help ensure we've got enough processes # that at least one will migrate to the new CPU. Store the PIDs # so we can kill them later. - number_of_cpus=$((number_of_cpus*2)) - until [ $number_of_cpus -eq 0 ]; do + number_of_procs=$((cpus_num*2)) + until [ $number_of_procs -eq 0 ]; do cpuhotplug_do_spin_loop > /dev/null 2>&1 & echo $! >> /var/run/hotplug4_$$.pid - number_of_cpus=$((number_of_cpus-1)) + number_of_procs=$((number_of_procs-1)) done ps aux | head -n 1
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh +2 -2
@@ -62,7 +62,7 @@ until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do cpustate=1 # Online all the CPUs - for i in $(get_all_cpus); do + for i in $(get_hotplug_cpus); do if [ "$i" != "cpu0" ]; then if ! cpu_is_online $i; then if ! online_cpu $i; then
@@ -79,7 +79,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_hotplug_cpus); do if ! offline_cpu $i; then if [ "x$i" != "xcpu0" ]; then tst_resm TFAIL "Did not offline first CPU (offlined $i instead)"
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh +1 -1
@@ -54,7 +54,7 @@ LOOP_COUNT=1 tst_check_cmds sar -get_cpus_num +get_present_cpus_num if [ $? -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh +1 -1
@@ -49,7 +49,7 @@ done LOOP_COUNT=1 -get_cpus_num +get_present_cpus_num if [ $? -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh +1 -1
@@ -55,7 +55,7 @@ done LOOP_COUNT=1 -get_cpus_num +get_present_cpus_num if [ $? -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi
Signature · 13 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v3 4/4 cpuhotplug04.sh: operate only with hotpluggable CPUs
In reply to Jan StancekFrom: Stanislav Kholmanskikh <[email protected]>
If cpu0 is hotpluggable, then the last CPU may not be cpu0, and there is no reason to treat cpu0 as a special case.
To make the test be more generic I'm proposing these changes:
* Operate (offline/online) only with hotpluggable CPUs, because how can we enable/disable a CPU if there is no 'online' file?
* If all CPUs in the system are hotpluggable, then we expect that the kernel will only refuse to offline the last CPU. And this last CPU may not be cpu0.
* If only a part of CPUs in the system is hotpluggable, then we should be able to offline all of them
--- .../hotplug/cpu_hotplug/functional/cpuhotplug04.sh | 52 +++++++++++++--------- 1 file changed, 30 insertions(+), 22 deletions(-)
testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh +30 -22
@@ -48,42 +48,50 @@ done LOOP_COUNT=1 -get_cpus_num -if [ $? -lt 2 ]; then +get_present_cpus_num +cpus_num=$? +if [ $cpus_num -lt 2 ]; then tst_brkm TCONF "system doesn't have required CPU hotplug support" fi +get_hotplug_cpus_num +if [ $? -lt 1 ]; then + tst_brkm TCONF "system doesn't have at least one hotpluggable CPU" +fi + TST_CLEANUP=do_clean cpu_states=$(get_all_cpu_states) until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do - cpu=0 - cpustate=1 - # Online all the CPUs + # Online all the hotpluggable CPUs for i in $(get_hotplug_cpus); do - if [ "$i" != "cpu0" ]; then - if ! cpu_is_online $i; then - if ! online_cpu $i; then - tst_brkm TBROK "$i cannot be onlined" - fi - fi - cpu=$((cpu+1)) - echo $i - else - if online_cpu $i; then - cpustate=0 + if ! cpu_is_online $i; then + if ! online_cpu $i; then + tst_brkm TBROK "$i can not be onlined" fi fi done - # Now offline all the CPUs + # Now offline them + cpu=0 for i in $(get_hotplug_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 + cpu=$((cpu + 1)) + + # If all the CPUs are hotpluggable, we expect + # that the kernel will refuse to offline the last CPU. + # If only some of the CPUs are hotpluggable, + # they all can be offlined. + if [ $cpu -eq $cpus_num ]; then + if offline_cpu $i 2> /dev/null; then + tst_brkm TFAIL "Have we just offlined the last CPU?" + else + tst_resm TPASS "System prevented us from offlining the last CPU - $i" + fi + else + if ! offline_cpu $i; then + tst_brkm TFAIL "Could not offline $i" fi fi done
@@ -92,6 +100,6 @@ until [ $LOOP_COUNT -gt $HOTPLUG04_LOOPS ]; do done -tst_resm TPASS "Successfully offlined first CPU, $i" +tst_resm TPASS "Success" tst_exit
Signature · 13 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 20 lines · Jan Stancek
Hi,
This patchset is result of merge of following series:
http://article.gmane.org/gmane.linux.ltp/22762 http://article.gmane.org/gmane.linux.ltp/22678It is based on patchset from Stanislav, with changes noted below:
1. cpuhotplug: use cpu states in cleanup
no changes to Stanislav's version
2.cpu_hotplug: addedget_hotplug_cpus,get_hotplug_cpus_numThis patch has been merged with my 'get_present_cpus' patch,get_hotplug_cpushas been modified to operate on present cpus only.
3.cpu_hotplug: use hotplug/present cpus functions
This comes from my series, there is no counterpart or conflict with Stanislav's patchset.
4.cpuhotplug04.sh: operate only with hotpluggable CPUs minor change here to use number of present CPUs, rather than all
Quoted 5 lines
Changes in v3:
+ usepresent_maskvariable inget_present_cpus
+ no special treatment for cpu0 in cpuhotplug03
+ fix cpuhotplug03 to spawn (number of present cpus)*2 processes
+ this time whole series has correct version in subject
Plus tested the series in a 4 vCPU VirtualBox VM both with and without the 'cpu0_hotplug' kernel cmdline.
Thanks.
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Looks good to me as well.
(you should have pushed it already)
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ 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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list