* [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc.
@ 2015-02-27 8:12 Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench Xing Gu
` (8 more replies)
0 siblings, 9 replies; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
The function "no_of_cpus" doesn't exist, which is used in change_freq.sh,
change_govr.sh and check_cpufreq_sysfs_files.sh. Use "tst_ncpus" instead
of "no_of_cpus".
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
testcases/kernel/power_management/change_freq.sh | 2 +-
testcases/kernel/power_management/change_govr.sh | 2 +-
testcases/kernel/power_management/check_cpufreq_sysfs_files.sh | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/power_management/change_freq.sh b/testcases/kernel/power_management/change_freq.sh
index 204e21f..3a971d2 100755
--- a/testcases/kernel/power_management/change_freq.sh
+++ b/testcases/kernel/power_management/change_freq.sh
@@ -5,7 +5,7 @@ available_freq=$(get_supporting_freq)
available_govr=$(get_supporting_govr)
RC=0
-total_cpus=$(no_of_cpus)
+total_cpus=$(tst_ncpus)
(( total_cpus-=1 ))
if ( echo ${available_govr} | grep -i "userspace" 2>&1 >/dev/null ) ; then
diff --git a/testcases/kernel/power_management/change_govr.sh b/testcases/kernel/power_management/change_govr.sh
index 4c2546e..bfe6c5b 100755
--- a/testcases/kernel/power_management/change_govr.sh
+++ b/testcases/kernel/power_management/change_govr.sh
@@ -3,7 +3,7 @@
. pm_include.sh
available_govr=$(get_supporting_govr)
-total_cpus=$(no_of_cpus)
+total_cpus=$(tst_ncpus)
(( total_cpus-=1 ))
RC=0
diff --git a/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh b/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh
index cb51aa0..dcf8a1d 100755
--- a/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh
+++ b/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh
@@ -2,7 +2,7 @@
. pm_include.sh
-total_cpus=$(no_of_cpus)
+total_cpus=$(tst_ncpus)
(( total_cpus-=1 ))
RC=0
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-03-02 15:00 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 3/9] power_management: split runpwtests.sh into separate testcases Xing Gu
` (7 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
* After installing LTP, the ebizzy/kernbench benchmark are located in
testcase/bin. Here using utils/benchmark path for searching ebizzy/kernbench
outputs "INFO: ebizzy/kernbench benchmark not found" error message. So add
the testcase/bin path for benchmark in trigger_ebizzy/trigger_kernbench
function.
* Change formatting in trigger_ebizzy/trigger_kernbench function.
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
testcases/kernel/power_management/lib/sched_mc.py | 138 +++++++++++++---------
1 file changed, 85 insertions(+), 53 deletions(-)
diff --git a/testcases/kernel/power_management/lib/sched_mc.py b/testcases/kernel/power_management/lib/sched_mc.py
index cb78b55..24285eb 100755
--- a/testcases/kernel/power_management/lib/sched_mc.py
+++ b/testcases/kernel/power_management/lib/sched_mc.py
@@ -318,51 +318,67 @@ def trigger_ebizzy (sched_smt, stress, duration, background, pinned):
'''
try:
threads = get_job_count(stress, "ebizzy", sched_smt)
- olddir = os.getcwd()
- path = '%s/utils/benchmark' % os.environ['LTPROOT']
- os.chdir(path)
- wklds_avlbl = list()
workload = "ebizzy"
- workload_dir = ""
+ olddir = os.getcwd()
+ installdir = '%s/utils/benchmark' % os.environ['LTPROOT']
+ if os.path.exists(installdir):
+ path = '%s/utils/benchmark' % os.environ['LTPROOT']
+ os.chdir(path)
+ wklds_avlbl = list()
+ workload_dir = ""
+
+ # Use the latest version of similar workload available
+ for file_name in os.listdir('.'):
+ if file_name.find(workload) != -1:
+ wklds_avlbl.append(file_name)
- # Use the latest version of similar workload available
- for file_name in os.listdir('.'):
- if file_name.find(workload) != -1:
- wklds_avlbl.append(file_name)
-
- wklds_avlbl.sort()
- workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
- if workload_dir != "":
- new_path = os.path.join(path,"%s" % workload_dir)
- get_proc_data(stats_start)
- get_proc_loc_count(intr_start)
- try:
+ wklds_avlbl.sort()
+ workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
+ if workload_dir != "":
+ new_path = os.path.join(path,"%s" % workload_dir)
os.chdir(new_path)
- if background == "yes":
- succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null &'
- % (threads, duration))
+ else:
+ print "INFO: ebizzy benchmark not found"
+ sys.exit(1)
+ else:
+ path = '%s/testcases/bin' % os.environ['LTPROOT']
+ os.chdir(path)
+ workload_file = ""
+ for file_name in os.listdir('.'):
+ if file_name == workload:
+ workload_file = file_name
+ break
+ if workload_file == "":
+ print "INFO: ebizzy benchmark not found"
+ sys.exit(1)
+ get_proc_data(stats_start)
+ get_proc_loc_count(intr_start)
+ try:
+ if background == "yes":
+ succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null &'
+ % (threads, duration))
+ else:
+ if pinned == "yes":
+ succ = os.system('taskset -c %s ./ebizzy -t%s -s4096 -S %s >/dev/null'
+ % (cpu_count -1, threads, duration))
else:
- if pinned == "yes":
- succ = os.system('taskset -c %s ./ebizzy -t%s -s4096 -S %s >/dev/null'
- % (cpu_count -1, threads, duration))
- else:
- succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null'
- % (threads, duration))
-
- if succ == 0:
- print "INFO: ebizzy workload triggerd"
- os.chdir(olddir)
- #Commented bcoz it doesnt make sense to capture it when workload triggered
- #in background
- #get_proc_loc_count(intr_stop)
- #get_proc_data(stats_stop)
- else:
- print "INFO: ebizzy workload triggerd failed"
- os.chdir(olddir)
- sys.exit(1)
- except Exception, details:
- print "Ebizzy workload trigger failed ", details
+ succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null'
+ % (threads, duration))
+
+ if succ == 0:
+ print "INFO: ebizzy workload triggerd"
+ os.chdir(olddir)
+ #Commented bcoz it doesnt make sense to capture it when workload triggered
+ #in background
+ #get_proc_loc_count(intr_stop)
+ #get_proc_data(stats_stop)
+ else:
+ print "INFO: ebizzy workload triggerd failed"
+ os.chdir(olddir)
sys.exit(1)
+ except Exception, details:
+ print "Ebizzy workload trigger failed ", details
+ sys.exit(1)
except Exception, details:
print "Ebizzy workload trigger failed ", details
sys.exit(1)
@@ -377,22 +393,38 @@ def trigger_kernbench (sched_smt, stress, background, pinned, perf_test):
threads = get_job_count(stress, "kernbench", sched_smt)
dst_path = "/root"
+ workload = "kernbench"
olddir = os.getcwd()
- path = '%s/utils/benchmark' % os.environ['LTPROOT']
- os.chdir(path)
- wklds_avlbl = list()
- for file_name in os.listdir('.'):
- if file_name.find("kernbench") != -1:
- wklds_avlbl.append(file_name)
- if len(wklds_avlbl):
- wklds_avlbl.sort()
- workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
- if workload_dir != "":
- benchmark_path = os.path.join(path,"%s" % workload_dir)
+ installdir = '%s/utils/benchmark' % os.environ['LTPROOT']
+ if os.path.exists(installdir):
+ path = '%s/utils/benchmark' % os.environ['LTPROOT']
+ os.chdir(path)
+ wklds_avlbl = list()
+ workload_dir = ""
+ for file_name in os.listdir('.'):
+ if file_name.find(workload) != -1:
+ wklds_avlbl.append(file_name)
+ if len(wklds_avlbl):
+ wklds_avlbl.sort()
+ workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
+ if workload_dir != "":
+ benchmark_path = os.path.join(path,"%s" % workload_dir)
+ else:
+ print "INFO: kernbench benchmark not found"
+ sys.exit(1)
+ else:
+ path = '%s/testcases/bin' % os.environ['LTPROOT']
+ os.chdir(path)
+ workload_file = ""
+ for file_name in os.listdir('.'):
+ if file_name == workload:
+ workload_file = file_name
+ break
+ if workload_file != "":
+ benchmark_path = path
else:
print "INFO: kernbench benchmark not found"
sys.exit(1)
- os.chdir(olddir)
os.chdir(dst_path)
linux_source_dir=""
@@ -405,7 +437,7 @@ def trigger_kernbench (sched_smt, stress, background, pinned, perf_test):
else:
print "INFO: Linux kernel source not found in /root. Workload\
Kernbench cannot be executed"
- sys.exit(1)
+ sys.exit(1)
get_proc_data(stats_start)
get_proc_loc_count(intr_start)
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 3/9] power_management: split runpwtests.sh into separate testcases
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-03-02 14:49 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 4/9] power_management: call the function eg. test_sched_mc instead of script test_sched_mc.sh Xing Gu
` (6 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
Split runpwtests.sh into separate testcases, eg. runpwtests01.sh.
Modification of pm_include.sh:
* Add check_kervel_arch() to check kernel version and architecture.
* Echo the result instead of using return from the is_multi_core etc.
* Use "tst_brkm TCONF" instead of "echo", when the current system
configuration doesn't support the test.
* In order to match the count of TPASS/TFAIL with the TST_COUNT
in each case, eg. runpwtests_exclusive01.sh, change "tst_resm
TPASS/TFAIL" to "echo" in analyze_package_consolidation_result
function etc.
* Change format.
Modification of power_management_tests/power_management_tests_exclusive
in runtest:
* Change runpwtests.sh to new testcases.
* Since I don't have suitable machines and can't test some cases'
correctness, eg runpwtests05.sh, currently these cases are
disabled.
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
runtest/power_management_tests | 8 +-
runtest/power_management_tests_exclusive | 13 +-
testcases/kernel/power_management/pm_include.sh | 154 ++++++---
testcases/kernel/power_management/runpwtests.sh | 380 ---------------------
testcases/kernel/power_management/runpwtests01.sh | 49 +++
testcases/kernel/power_management/runpwtests02.sh | 47 +++
testcases/kernel/power_management/runpwtests03.sh | 64 ++++
testcases/kernel/power_management/runpwtests04.sh | 37 ++
testcases/kernel/power_management/runpwtests05.sh | 82 +++++
testcases/kernel/power_management/runpwtests06.sh | 51 +++
.../power_management/runpwtests_exclusive01.sh | 101 ++++++
.../power_management/runpwtests_exclusive02.sh | 71 ++++
.../power_management/runpwtests_exclusive03.sh | 99 ++++++
.../power_management/runpwtests_exclusive04.sh | 56 +++
.../power_management/runpwtests_exclusive05.sh | 101 ++++++
15 files changed, 879 insertions(+), 434 deletions(-)
delete mode 100755 testcases/kernel/power_management/runpwtests.sh
create mode 100755 testcases/kernel/power_management/runpwtests01.sh
create mode 100755 testcases/kernel/power_management/runpwtests02.sh
create mode 100755 testcases/kernel/power_management/runpwtests03.sh
create mode 100755 testcases/kernel/power_management/runpwtests04.sh
create mode 100755 testcases/kernel/power_management/runpwtests05.sh
create mode 100755 testcases/kernel/power_management/runpwtests06.sh
create mode 100755 testcases/kernel/power_management/runpwtests_exclusive01.sh
create mode 100755 testcases/kernel/power_management/runpwtests_exclusive02.sh
create mode 100755 testcases/kernel/power_management/runpwtests_exclusive03.sh
create mode 100755 testcases/kernel/power_management/runpwtests_exclusive04.sh
create mode 100755 testcases/kernel/power_management/runpwtests_exclusive05.sh
diff --git a/runtest/power_management_tests b/runtest/power_management_tests
index 5aa18bf..884e615 100644
--- a/runtest/power_management_tests
+++ b/runtest/power_management_tests
@@ -1 +1,7 @@
-POWER_MANAGEMENT runpwtests.sh
+#POWER_MANAGEMENT
+runpwtests01 runpwtests01.sh
+runpwtests02 runpwtests02.sh
+runpwtests03 runpwtests03.sh
+runpwtests04 runpwtests04.sh
+#runpwtests05 runpwtests05.sh
+runpwtests06 runpwtests06.sh
diff --git a/runtest/power_management_tests_exclusive b/runtest/power_management_tests_exclusive
index a1692df..26176e2 100644
--- a/runtest/power_management_tests_exclusive
+++ b/runtest/power_management_tests_exclusive
@@ -1 +1,12 @@
-POWER_MANAGEMENT runpwtests.sh -exclusive
+#POWER_MANAGEMENT exclusive
+runpwtests01 runpwtests01.sh
+runpwtests02 runpwtests02.sh
+runpwtests03 runpwtests03.sh
+runpwtests04 runpwtests04.sh
+#runpwtests05 runpwtests05.sh
+runpwtests06 runpwtests06.sh
+#runpwtests_exclusive01 runpwtests_exclusive01.sh
+#runpwtests_exclusive02 runpwtests_exclusive02.sh
+#runpwtests_exclusive03 runpwtests_exclusive03.sh
+#runpwtests_exclusive04 runpwtests_exclusive04.sh
+#runpwtests_exclusive05 runpwtests_exclusive05.sh
diff --git a/testcases/kernel/power_management/pm_include.sh b/testcases/kernel/power_management/pm_include.sh
index b1867e6..366c914 100755
--- a/testcases/kernel/power_management/pm_include.sh
+++ b/testcases/kernel/power_management/pm_include.sh
@@ -15,9 +15,27 @@ cleanup() {
fi
}
+check_kervel_arch() {
+ # Checking required kernel version and architecture
+ tst_kvercmp 2 6 21; rc=$?
+ if [ $rc -ne 1 -a $rc -ne 2 ] ; then
+ tst_brkm TCONF "Kernel version not supported; not " \
+ "running testcases"
+ else
+ case "$(uname -m)" in
+ i[4-6]86|x86_64)
+ ;;
+ *)
+ tst_brkm TCONF "Arch not supported; not running " \
+ "testcases"
+ ;;
+ esac
+ fi
+}
+
check_config_options() {
if ( ! ${3} "${1}" ${2} | grep -v "#" > /dev/null ) ; then
- echo "NOSUPPORT: current system dosen't support ${1}"
+ tst_brkm TCONF "NOSUPPORT: current system dosen't support ${1}"
fi
}
@@ -30,7 +48,8 @@ get_topology() {
for cpu in $(seq 0 "${total_cpus}" )
do
cpus[$cpu]=cpu${cpu}
- phyid[$cpu]=$(cat /sys/devices/system/cpu/cpu${cpu}/topology/physical_package_id)
+ phyid[$cpu]=$(cat \
+ /sys/devices/system/cpu/cpu${cpu}/topology/physical_package_id)
done
j=0
while [ "${j}" -lt "${total_cpus}" ]
@@ -50,24 +69,27 @@ check_cpufreq() {
for cpu in $(seq 0 "${total_cpus}" )
do
if [ ! -d /sys/devices/system/cpu/cpu${cpu}/cpufreq ] ; then
- echo "NOSUPPORT: cpufreq support not found please check Kernel configuration or BIOS settings"
- exit $NOSUPPORT
+ tst_brkm TCONF "NOSUPPORT: cpufreq support not " \
+ "found please check Kernel configuration " \
+ "or BIOS settings"
fi
done
}
get_supporting_freq() {
- cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies | uniq
+ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies \
+ | uniq
}
get_supporting_govr() {
- cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors | uniq
+ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors \
+ | uniq
}
is_hyper_threaded() {
siblings=`cat /proc/cpuinfo | grep siblings | uniq | cut -f2 -d':'`
cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | cut -f2 -d':'`
- [ $siblings -gt $cpu_cores ]; return $?
+ [ $siblings -gt $cpu_cores ]; echo $?
}
check_input() {
@@ -102,35 +124,39 @@ check_input() {
}
is_multi_socket() {
- no_of_sockets=`cat /sys/devices/system/cpu/cpu?/topology/physical_package_id | uniq | wc -l`
- [ $no_of_sockets -gt 1 ] ; return $?
+ no_of_sockets=`cat \
+ /sys/devices/system/cpu/cpu?/topology/physical_package_id \
+ | uniq | wc -l`
+ [ $no_of_sockets -gt 1 ] ; echo $?
}
is_multi_core() {
siblings=`cat /proc/cpuinfo | grep siblings | uniq | cut -f2 -d':'`
cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | cut -f2 -d':'`
if [ $siblings -eq $cpu_cores ]; then
- [ $cpu_cores -gt 1 ]; return $?
+ [ $cpu_cores -gt 1 ]; echo $?
else
: $(( num_of_cpus = siblings / cpu_cores ))
- [ $num_of_cpus -gt 1 ]; return $?
+ [ $num_of_cpus -gt 1 ]; echo $?
fi
}
is_dual_core() {
siblings=`cat /proc/cpuinfo | grep siblings | uniq | cut -f2 -d':'`
- cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | cut -f2 -d':'`
+ cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq \
+ | cut -f2 -d':'`
if [ $siblings -eq $cpu_cores ]; then
- [ $cpu_cores -eq 2 ]; return $?
+ [ $cpu_cores -eq 2 ]; echo $?
else
: $(( num_of_cpus = siblings / cpu_cores ))
- [ $num_of_cpus -eq 2 ]; return $?
+ [ $num_of_cpus -eq 2 ]; echo $?
fi
}
get_kernel_version() {
# Get kernel minor version
- export kernel_version=`uname -r | awk -F. '{print $1"."$2"."$3}' | cut -f1 -d'-'`
+ export kernel_version=`uname -r | awk -F. '{print $1"."$2"."$3}' \
+ | cut -f1 -d'-'`
}
get_valid_input() {
@@ -146,42 +172,46 @@ analyze_result_hyperthreaded() {
sched_mc=$1
pass_count=$2
sched_smt=$3
+ PASS="Test PASS"
+ FAIL="Test FAIL"
+ RC=0
case "$sched_mc" in
0)
case "$sched_smt" in
0)
if [ $pass_count -lt 5 ]; then
- tst_resm TPASS "cpu consolidation failed for sched_mc=\
-$sched_mc & sched_smt=$sched_smt"
+ echo "${PASS}: cpu consolidation failed for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
else
RC=1
- tst_resm TFAIL "cpu consolidation passed for sched_mc=\
-$sched_mc & sched_smt=$sched_smt"
+ echo "${FAIL}: cpu consolidation passed for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
fi
;;
*)
if [ $pass_count -lt 5 ]; then
- tst_resm TFAIL "cpu consolidation for sched_mc=\
-$sched_mc & sched_smt=$sched_smt"
- else
RC=1
- tst_resm TPASS "cpu consolidation for sched_mc=\
-$sched_mc & sched_smt=$sched_smt"
+ echo "${FAIL}: cpu consolidation for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
+ else
+ echo "${PASS}: cpu consolidation for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
fi
;;
esac ;;
*)
if [ $pass_count -lt 5 ]; then
- tst_resm TFAIL "cpu consolidation for sched_mc=\
-$sched_mc & sched_smt=$sched_smt"
- else
RC=1
- tst_resm TPASS "cpu consolidation for sched_mc=\
-$sched_mc & sched_smt=$sched_smt"
+ echo "${FAIL}: cpu consolidation for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
+ else
+ echo "${PASS}: cpu consolidation for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
fi
;;
esac
+ return $RC
}
analyze_package_consolidation_result() {
@@ -195,84 +225,104 @@ analyze_package_consolidation_result() {
sched_smt=-1
fi
+ PASS="Test PASS"
+ FAIL="Test FAIL"
+
+ RC=0
if [ $hyper_threaded -eq $YES -a $sched_smt -gt -1 ]; then
analyze_result_hyperthreaded $sched_mc $pass_count $sched_smt
else
case "$sched_mc" in
0)
if [ $pass_count -lt 5 ]; then
- tst_resm TPASS "cpu consolidation failed for sched_mc=\
-$sched_mc"
+ echo "${PASS}: cpu consolidation failed for" \
+ "sched_mc=$sched_mc"
else
RC=1
- tst_resm TFAIL "cpu consolidation passed for sched_mc=\
-$sched_mc"
- fi ;;
+ echo "${FAIL}: cpu consolidation passed for" \
+ "sched_mc=$sched_mc"
+ fi
+ ;;
*)
if [ $pass_count -lt 5 ]; then
- tst_resm TFAIL "Consolidation at package level failed for \
-sched_mc=$sched_mc"
+ RC=1
+ echo "${FAIL}: consolidation at package level" \
+ "failed for sched_mc=$sched_mc"
else
- tst_resm TPASS "Consolidation at package level passed for \
-sched_mc=$sched_mc"
+ echo "${PASS}: consolidation at package level" \
+ "passed for sched_mc=$sched_mc"
fi
;;
esac
fi
+ return $RC
}
analyze_core_consolidation_result() {
sched_smt=$1
pass_count=$2
+ PASS="Test PASS"
+ FAIL="Test FAIL"
+ RC=0
case "$sched_smt" in
0)
if [ $pass_count -lt 5 ]; then
- tst_resm TPASS "Consolidation at core level failed \
-when sched_smt=$sched_smt"
+ echo "${PASS}: consolidation at core level failed" \
+ "when sched_smt=$sched_smt"
else
- tst_resm TFAIL "Consolidation at core level passed for \
-sched_smt=$sched_smt"
+ RC=1
+ echo "${FAIL}: consolidation at core level passed for" \
+ "sched_smt=$sched_smt"
fi ;;
*)
if [ $pass_count -lt 5 ]; then
RC=1
- tst_resm TFAIL "Consolidation at core level failed for \
-sched_smt=$sched_smt"
+ echo "${FAIL}: consolidation at core level failed for" \
+ "sched_smt=$sched_smt"
else
- tst_resm TPASS "Consolidation at core level passed for \
-sched_smt=$sched_smt"
+ echo "${PASS}: consolidation at core level passed for" \
+ "sched_smt=$sched_smt"
fi ;;
esac
+ return $RC
}
analyze_sched_domain_result(){
sched_mc=$1
result=$2
sched_smt=$3
+ PASS="Test PASS"
+ FAIL="Test FAIL"
+ RC=0
if [ $hyper_threaded -eq $YES ]; then
if [ $sched_smt ]; then
if [ "$result" = 0 ];then
- tst_resm TPASS "sched domain test for sched_mc=$sched_mc & sched_smt=$sched_smt"
+ echo "${PASS}: sched domain test for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
else
RC=1
- tst_resm TFAIL "sched domain test sched_mc=$sched_mc & sched_smt=$sched_smt"
+ echo "${FAIL}: sched domain test for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
fi
else
if [ "$result" = 0 ];then
- tst_resm TPASS "sched domain test for sched_mc=$sched_mc"
+ echo "${PASS}: sched domain test for" \
+ "sched_mc=$sched_mc"
else
RC=1
- tst_resm TFAIL "sched domain test for sched_mc=$sched_mc"
+ echo "${FAIL}: sched domain test for" \
+ "sched_mc=$sched_mc"
fi
fi
else
if [ "$result" = 0 ];then
- tst_resm TPASS "sched domain test for sched_mc=$sched_mc"
+ echo "${PASS}: sched domain test for sched_mc=$sched_mc"
else
RC=1
- tst_resm TFAIL "sched domain test sched_mc=$sched_mc"
+ echo "${FAIL}: sched domain test for sched_mc=$sched_mc"
fi
fi
+ return $RC
}
diff --git a/testcases/kernel/power_management/runpwtests.sh b/testcases/kernel/power_management/runpwtests.sh
deleted file mode 100755
index 9055964..0000000
--- a/testcases/kernel/power_management/runpwtests.sh
+++ /dev/null
@@ -1,380 +0,0 @@
-#! /bin/sh
-################################################################################
-## ##
-## Copyright (c) International Business Machines Corp., 2001 ##
-## ##
-## This program is free software; you can redistribute it and#or modify ##
-## it under the terms of the GNU General Public License as published by ##
-## the Free Software Foundation; either version 2 of the License, or ##
-## (at your option) any later version. ##
-## ##
-## This program is distributed in the hope that it will be useful, but ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
-## for more details. ##
-## ##
-## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
-## ##
-################################################################################
-#
-# File : runpwtests.sh
-#
-# Description:
-#
-# Author: Nageswara R Sastry <nasastry@in.ibm.com>
-#
-# History: 26 Aug 2008 - Created this file
-# 03 Nov 2008 - Added CPUIDLE sysfs testcase
-#
-
-# Exporting Required variables
-export TST_TOTAL=1
-#LTPTMP=${TMP}
-export PATH=${PATH}:.
-export TCID="Power_Management"
-export TST_COUNT=0
-export contacts="mpnayak@linux.vnet.ibm.com"
-export analysis="/proctstat"
-
-YES=0
-NO=1
-#List of reusable functions defined in pm_include.sh
-. pm_include.sh
-
-# Function: main
-#
-# Description: - Execute all tests, exit with test status.
-#
-# Exit: - zero on success
-# - non-zero on failure.
-#
-RC=0 #Return status
-
-# Checking required kernel version and architecture
-tst_kvercmp 2 6 21; rc=$?
-if [ $rc -ne 1 -a $rc -ne 2 ] ; then
- tst_resm TCONF "Kernel version not supported; not running testcases"
- exit 0
-else
- case "$(uname -m)" in
- i[4-6]86|x86_64)
- ;;
- *)
- tst_resm TCONF "Arch not supported; not running testcases"
- exit 0
- ;;
- esac
-fi
-
-tst_kvercmp 2 6 29; rc=$?
-if [ $rc -eq 2 ] ; then
- max_sched_mc=2
- max_sched_smt=2
-else
- max_sched_mc=1
- max_sched_smt=1
-fi
-
-tst_kvercmp 2 6 31; rc=$?
-if [ $rc -eq 1 -o $rc -eq 2 ] ; then
- timer_migr_support_compatible=1
-else
- timer_migr_support_compatible=0
-fi
-
-is_hyper_threaded; hyper_threaded=$?
-is_multi_socket; multi_socket=$?
-is_multi_core; multi_core=$?
-is_dual_core; dual_core=$?
-
-#Checking sched_mc sysfs interface
-#check_config.sh config_sched_mc || RC=$?
-TST_COUNT=1
-if [ $multi_socket -eq $YES -a $multi_core -eq $YES ] ; then
- if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
- if test_sched_mc.sh ; then
- tst_resm TPASS "SCHED_MC sysfs tests"
- else
- RC=$?
- tst_resm TFAIL "SCHED_MC sysfs tests"
- fi
- else
- tst_resm TCONF "Required kernel configuration for SCHED_MC NOT set"
- fi
-else
- if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
- tst_resm TFAIL "sched_mc_power_savings interface in system which is not a multi socket &(/) multi core"
- else
- tst_resm TCONF "Not a suitable architecture for SCHED_MC test"
- fi
-fi
-
-# Test sched_smt_power_savings interface on HT machines
-: $(( TST_COUNT += 1 ))
-if [ $hyper_threaded -eq $YES ]; then
- if [ -f /sys/devices/system/cpu/sched_smt_power_savings ] ; then
- if test_sched_smt.sh; then
- tst_resm TPASS "SCHED_SMT sysfs test"
- else
- RC=$?
- tst_resm TFAIL "SCHED_SMT sysfs test"
- fi
- else
- RC=$?
- tst_resm TFAIL "Required kernel configuration for SCHED_SMT NOT set"
- fi
-else
- if [ -f /sys/devices/system/cpu/sched_smt_power_savings ] ; then
- RC=$?
- tst_resm TFAIL "sched_smt_power_saving interface in system not hyper-threaded"
- else
- tst_resm TCONF "Required Hyper Threading support for SCHED_SMT test"
- fi
-fi
-
-# Checking cpufreq sysfs interface files
-#check_config.sh config_cpu_freq || RC=$?
-: $(( TST_COUNT += 1 ))
-if [ -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
- if check_cpufreq_sysfs_files.sh; then
- tst_resm TPASS "CPUFREQ sysfs tests"
- else
- RC=$?
- tst_resm TFAIL "CPUFREQ sysfs tests "
- fi
-
- # Changing governors
- : $(( TST_COUNT += 1 ))
- if change_govr.sh; then
- tst_resm TPASS "Changing governors "
- else
- RC=$?
- tst_resm TFAIL "Changing governors "
- fi
-
- # Changing frequencies
- : $(( TST_COUNT += 1 ))
- if change_freq.sh ; then
- tst_resm TPASS "Changing frequncies "
- else
- RC=$?
- tst_resm TFAIL "Changing frequncies "
- fi
-
- # Loading and Unloading governor related kernel modules
- : $(( TST_COUNT += 1 ))
- if pwkm_load_unload.sh ; then
- tst_resm TPASS "Loading and Unloading of governor kernel \
-modules"
- else
- RC=$?
- tst_resm TFAIL "Loading and Unloading of governor kernel \
- modules got failed"
- fi
-else
- tst_resm TCONF "Required kernel configuration for CPU_FREQ NOT set"
-fi
-
-# Checking cpuidle sysfs interface files
-: $(( TST_COUNT+=1))
-if check_cpuidle_sysfs_files.sh ; then
- tst_resm TPASS "CPUIDLE sysfs tests passed"
-else
- RC=$?
- tst_resm TFAIL "CPUIDLE sysfs tests failed"
-fi
-
-# sched_domain test
-if ! type python > /dev/null ; then
- tst_resm TCONF "Python is not installed, CPU Consolidation\
-test cannot run"
-elif ! grep sched_debug -qw /proc/cmdline ; then
- tst_resm TCONF "Kernel cmdline parameter 'sched_debug' needed,\
-CPU Consolidation test cannot run"
-else
- if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
- echo "max sched mc $max_sched_mc"
- for sched_mc in `seq 0 $max_sched_mc`; do
- : $(( TST_COUNT+=1))
- sched_domain.py -c $sched_mc; RC=$?
- analyze_sched_domain_result $sched_mc $RC
- if [ $hyper_threaded -eq $YES -a -f /sys/devices/system/cpu/sched_smt_power_savings ]; then
- get_sched_values sched_smt; max_sched_smt=$?
- for sched_smt in `seq 0 $max_sched_smt`; do
- # Testcase to validate sched_domain tree
- : $(( TST_COUNT+=1))
- sched_domain.py -c $sched_mc -t $sched_smt; RC=$?
- analyze_sched_domain_result $sched_mc $RC $sched_smt ;
- done
- fi
- done
- fi
-fi
-
-: $(( TST_COUNT+=1))
-if [ -f /proc/sys/kernel/timer_migration ]; then
- if [ $timer_migr_support_compatible -eq $YES ]; then
- if test_timer_migration.sh; then
- tst_resm TPASS "Timer Migration interface test"
- else
- RC=$?
- tst_resm TFAIL "Timer migration interface test"
- fi
- fi
-else
- if [ $timer_migr_support_compatible -eq $YES ]; then
- RC=$?
- tst_resm TFAIL "Timer migration interface missing"
- else
- tst_resm TCONF "Kernel version does not support Timer migration"
- fi
-fi
-
-if [ $# -gt 0 -a "$1" = "-exclusive" ]; then
- # Test CPU consolidation
- if [ $multi_socket -eq $YES -a $multi_core -eq $YES ]; then
- for sched_mc in `seq 0 $max_sched_mc`; do
- : $(( TST_COUNT += 1 ))
- sched_mc_pass_cnt=0
- if [ $sched_mc -eq 2 ]; then
- work_load="kernbench"
- else
- work_load="ebizzy"
- fi
- for repeat_test in `seq 1 10`; do
- #Testcase to validate CPU consolidation for sched_mc
- if cpu_consolidation.py -c $sched_mc -w $work_load ; then
- : $(( sched_mc_pass_cnt += 1 ))
- fi
- done
- analyze_package_consolidation_result $sched_mc $sched_mc_pass_cnt
-
- if [ $hyper_threaded -eq $YES ]; then
- for sched_smt in `seq 0 $max_sched_smt`; do
- : $(( TST_COUNT += 1 ))
- sched_mc_smt_pass_cnt=0
- for repeat_test in `seq 1 10`; do
- # Testcase to validate CPU consolidation for
- # for sched_mc & sched_smt with stress=50%
- if cpu_consolidation.py -c $sched_mc -t $sched_smt -w $work_load; then
- : $(( sched_mc_smt_pass_cnt += 1 ))
- fi
- done
- analyze_package_consolidation_result $sched_mc $sched_mc_smt_pass_cnt $sched_smt
- done
- fi
- done
-
- fi
-
- if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES -a $multi_core -eq $NO ]; then
- #Testcase to validate consolidation at core level
- for sched_smt in `seq 0 $max_sched_smt`; do
- if [ $sched_smt -eq 2 ]; then
- work_load="kernbench"
- else
- work_load="ebizzy"
- fi
- sched_smt_pass_cnt=0
- : $(( TST_COUNT += 1 ))
- stress="thread"
- for repeat_test in `seq 1 10`; do
- if cpu_consolidation.py -t $sched_smt -w $work_load -s $stress; then
- : $(( sched_smt_pass_cnt += 1 ))
- fi
- done
- analyze_core_consolidation_result $sched_smt $sched_smt_pass_cnt
- done
- fi
-
- # Verify threads consolidation stops when sched_mc &(/) sched_smt is disabled
- if [ $multi_socket -eq $YES -a $multi_core -eq $YES ]; then
- for sched_mc in `seq 1 $max_sched_mc`; do
- : $(( TST_COUNT += 1 ))
-
- # Vary sched_mc from 1/2 to 0 when workload is running and ensure that
- # tasks do not consolidate to single package when sched_mc is set to 0
- if cpu_consolidation.py -v -c $sched_mc; then
- tst_resm TPASS "CPU consolidation test by varying sched_mc $sched_mc to 0"
- else
- tst_resm TFAIL "CPU consolidation test by varying sched_mc $sched_mc to 0"
- fi
-
- if [ $hyper_threaded -eq $YES ]; then
- for sched_smt in `seq 1 $max_sched_smt`; do
- if [ $sched_smt -eq $sched_mc ]; then
- # Vary sched_mc & sched_smt from 1 to 0 & 2 to 0 when workload is running and ensure that
- # tasks do not consolidate to single package when sched_mc is set to 0
- : $(( TST_COUNT += 1 ))
- if cpu_consolidation.py -v -c $sched_mc -t $sched_smt; then
- tst_resm TPASS "CPU consolidation test by varying sched_mc \
-& sched_smt from $sched_mc to 0"
- else
- tst_resm TFAIL "CPU consolidation test by varying sched_mc \
-& sched_smt from $sched_mc to 0"
- fi
- fi
- done
- fi
- done
- fi
-
- # Verify threads consolidation stops when sched_smt is disabled in HT systems
- if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES ]; then
- # Vary only sched_smt from 1 to 0 when workload is running and ensure that
- # tasks do not consolidate to single core when sched_smt is set to 0
- : $(( TST_COUNT += 1 ))
- if cpu_consolidation.py -v -t 1; then
- tst_resm TPASS "CPU consolidation test by varying sched_smt from 1 to 0"
- else
- tst_resm TFAIL "CPU consolidation test by varying sched_smt from 1 to 0"
- fi
-
- # Vary only sched_smt from 2 to 0 when workload is running and ensure that
- # tasks do not consolidate to single core when sched_smt is set to 0
- : $(( TST_COUNT += 1 ))
- if cpu_consolidation.py -v -t 2; then
- tst_resm TPASS "CPU consolidation test by varying sched_smt 2 to 0"
- else
- tst_resm TFAIL "CPU consolidation test by varying sched_smt 2 to 0"
- fi
-
- fi
-
- # Verify ILB runs in same package as workload
- if [ $multi_socket -eq $YES -a $multi_core -eq $YES ]; then
- for sched_mc in `seq 1 $max_sched_mc`; do
- : $(( TST_COUNT += 1 ))
- if [ $sched_mc -eq 2 ]; then
- work_load="kernbench"
- else
- work_load="ebizzy"
- fi
-
- ilb_test.py -c $sched_mc -w $work_load; RC=$?
- if [ $RC -eq 0 ]; then
- tst_resm TPASS "ILB & workload in same package for sched_mc=$sched_mc"
- else
- tst_resm TFAIL "ILB & workload did not run in same package for sched_mc=$sched_mc\
-. Ensure CONFIG_NO_HZ is set"
- fi
- if [ $hyper_threaded -eq $YES ]; then
- for sched_smt in `seq 1 $max_sched_smt`; do
- : $(( TST_COUNT += 1 ))
- ilb_test.py -c $sched_mc -t sched_smt -w $work_load; RC=$?
- if [ $RC -eq 0 ]; then
- tst_resm TPASS "ILB & workload in same package for sched_mc=$sched_mc \
-& sched_smt=$sched_smt"
- else
- tst_resm TFAIL "ILB & workload did not execute in same package for \
-sched_mc=$sched_mc & sched_smt=$sched_smt. Ensure CONFIG_NO_HZ is set"
- fi
- done
- fi
- done
- fi
-fi
-
-exit $RC
diff --git a/testcases/kernel/power_management/runpwtests01.sh b/testcases/kernel/power_management/runpwtests01.sh
new file mode 100755
index 0000000..7dc164c
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests01.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management01"
+export TST_TOTAL=1
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+# Checking sched_mc sysfs interface
+multi_socket=$(is_multi_socket)
+multi_core=$(is_multi_core)
+if [ ! -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
+ tst_brkm TCONF "Required kernel configuration for SCHED_MC" \
+ "NOT set"
+else
+ if [ $multi_socket -ne 0 -a $multi_core -ne 0 ] ; then
+ tst_brkm TCONF "sched_mc_power_savings interface in system" \
+ "which is not a multi socket &(/) multi core"
+ fi
+fi
+
+if test_sched_mc.sh ; then
+ tst_resm TPASS "SCHED_MC sysfs tests"
+else
+ tst_resm TFAIL "SCHED_MC sysfs tests"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests02.sh b/testcases/kernel/power_management/runpwtests02.sh
new file mode 100755
index 0000000..067569e
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests02.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management02"
+export TST_TOTAL=1
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+# Check sched_smt_power_savings interface on HT machines
+hyper_threaded=$(is_hyper_threaded)
+if [ ! -f /sys/devices/system/cpu/sched_smt_power_savings ] ; then
+ tst_brkm TCONF "Required kernel configuration for SCHED_SMT NOT set"
+else
+ if [ $hyper_threaded -ne 0 ]; then
+ tst_brkm TCONF "sched_smt_power_saving interface in system" \
+ "not hyper-threaded"
+ fi
+fi
+
+if test_sched_smt.sh ; then
+ tst_resm TPASS "SCHED_SMT sysfs test"
+else
+ tst_resm TFAIL "SCHED_SMT sysfs test"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests03.sh b/testcases/kernel/power_management/runpwtests03.sh
new file mode 100755
index 0000000..34fb1a4
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests03.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management03"
+export TST_TOTAL=4
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+# Checking cpufreq sysfs interface files
+if [ ! -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
+ tst_brkm TCONF "Required kernel configuration for CPU_FREQ NOT set"
+fi
+
+if check_cpufreq_sysfs_files.sh ; then
+ tst_resm TPASS "CPUFREQ sysfs tests"
+else
+ tst_resm TFAIL "CPUFREQ sysfs tests"
+fi
+
+# Changing governors
+if change_govr.sh ; then
+ tst_resm TPASS "Changing governors"
+else
+ tst_resm TFAIL "Changing governors"
+fi
+
+# Changing frequencies
+if change_freq.sh ; then
+ tst_resm TPASS "Changing frequncies"
+else
+ tst_resm TFAIL "Changing frequncies"
+fi
+
+# Loading and Unloading governor related kernel modules
+if pwkm_load_unload.sh ; then
+ tst_resm TPASS "Loading and Unloading of governor kernel" \
+ "modules"
+else
+ tst_resm TFAIL "Loading and Unloading of governor kernel" \
+ "modules got failed"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests04.sh b/testcases/kernel/power_management/runpwtests04.sh
new file mode 100755
index 0000000..eeb4b22
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests04.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management04"
+export TST_TOTAL=1
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+# Checking cpuidle sysfs interface files
+if check_cpuidle_sysfs_files.sh ; then
+ tst_resm TPASS "CPUIDLE sysfs tests passed"
+else
+ tst_resm TFAIL "CPUIDLE sysfs tests failed"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests05.sh b/testcases/kernel/power_management/runpwtests05.sh
new file mode 100755
index 0000000..c086e3c
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests05.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management05"
+export TST_TOTAL=2
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+tst_kvercmp 2 6 29; rc=$?
+if [ $rc -eq 2 ] ; then
+ max_sched_mc=2
+ max_sched_smt=2
+else
+ max_sched_mc=1
+ max_sched_smt=1
+fi
+
+tst_check_cmds python
+
+if ! grep sched_debug -qw /proc/cmdline ; then
+ tst_brkm TCONF "Kernel cmdline parameter 'sched_debug' needed," \
+ "CPU Consolidation test cannot run"
+fi
+
+hyper_threaded=$(is_hyper_threaded)
+if [ ! -f /sys/devices/system/cpu/sched_mc_power_savings \
+ -o $hyper_threaded -ne 0 ] ; then
+ tst_brkm TCONF "Required kernel configuration for SCHED_MC" \
+ "NOT set, or sched_mc_power_savings interface in system" \
+ "which is not hyper-threaded"
+fi
+
+# sched_domain test
+echo "max sched mc $max_sched_mc"
+RC=0
+for sched_mc in `seq 0 $max_sched_mc`; do
+ sched_domain.py -c $sched_mc; ret=$?
+ analyze_sched_domain_result $sched_mc $ret; RC=$?
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "Sched_domain test for sched_mc"
+else
+ tst_resm TFAIL "Sched_domain test for sched_mc"
+fi
+
+# Testcase to validate sched_domain tree
+RC=0
+for sched_mc in `seq 0 $max_sched_mc`; do
+ get_sched_values sched_smt; max_sched_smt=$?
+ for sched_smt in `seq 0 $max_sched_smt`; do
+ sched_domain.py -c $sched_mc -t $sched_smt; ret=$?
+ analyze_sched_domain_result $sched_mc $ret $sched_smt; RC=$?
+ done
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "Sched_domain test for sched_mc & sched_smt"
+else
+ tst_resm TFAIL "Sched_domain test for sched_mc & sched_smt"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests06.sh b/testcases/kernel/power_management/runpwtests06.sh
new file mode 100755
index 0000000..ab5d7de
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests06.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management06"
+export TST_TOTAL=1
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+tst_kvercmp 2 6 31; rc=$?
+if [ $rc -eq 1 -o $rc -eq 2 ] ; then
+ timer_migr_support_compatible=0
+else
+ timer_migr_support_compatible=1
+fi
+
+if [ $timer_migr_support_compatible -eq 1 ]; then
+ tst_brkm TCONF "Kernel version does not support Timer migration"
+else
+ if [ ! -f /proc/sys/kernel/timer_migration ]; then
+ tst_brkm TBROK "Timer migration interface missing"
+ fi
+fi
+
+if test_timer_migration.sh; then
+ tst_resm TPASS "Timer Migration interface test"
+else
+ tst_resm TFAIL "Timer migration interface test"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests_exclusive01.sh b/testcases/kernel/power_management/runpwtests_exclusive01.sh
new file mode 100755
index 0000000..2a7e437
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests_exclusive01.sh
@@ -0,0 +1,101 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management_exclusive01"
+export TST_TOTAL=2
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+tst_kvercmp 2 6 29; rc=$?
+if [ $rc -eq 2 ] ; then
+ max_sched_mc=2
+ max_sched_smt=2
+else
+ max_sched_mc=1
+ max_sched_smt=1
+fi
+
+hyper_threaded=$(is_hyper_threaded)
+multi_socket=$(is_multi_socket)
+multi_core=$(is_multi_core)
+if [ $multi_socket -ne 0 -o $multi_core -ne 0 -o \
+ $hyper_threaded -ne 0 ]; then
+ tst_brkm TCONF "System is not a multi socket & multi core" \
+ "& hyper-threaded"
+fi
+
+# Test CPU consolidation
+RC=0
+for sched_mc in `seq 0 $max_sched_mc`; do
+ sched_mc_pass_cnt=0
+ if [ $sched_mc -eq 2 ]; then
+ work_load="kernbench"
+ else
+ work_load="ebizzy"
+ fi
+ for repeat_test in `seq 1 10`; do
+ #Testcase to validate CPU consolidation for sched_mc
+ if cpu_consolidation.py -c $sched_mc -w $work_load ; then
+ : $(( sched_mc_pass_cnt += 1 ))
+ fi
+ done
+ analyze_package_consolidation_result $sched_mc \
+ $sched_mc_pass_cnt; RC=$?
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "CPU consolidation test for sched_mc"
+else
+ tst_resm TFAIL "CPU consolidation test for sched_mc"
+fi
+
+RC=0
+for sched_mc in `seq 0 $max_sched_mc`; do
+ if [ $sched_mc -eq 2 ]; then
+ work_load="kernbench"
+ else
+ work_load="ebizzy"
+ fi
+ for sched_smt in `seq 0 $max_sched_smt`; do
+ sched_mc_smt_pass_cnt=0
+ for repeat_test in `seq 1 10`; do
+ # Testcase to validate CPU consolidation for
+ # for sched_mc & sched_smt with stress=50%
+ if cpu_consolidation.py -c $sched_mc -t $sched_smt \
+ -w $work_load ; then
+ : $(( sched_mc_smt_pass_cnt += 1 ))
+ fi
+ done
+ analyze_package_consolidation_result $sched_mc \
+ $sched_mc_smt_pass_cnt $sched_smt; RC=$?
+ done
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "CPU consolidation test for sched_mc &" \
+ "sched_smt with stress=50%"
+else
+ tst_resm TFAIL "CPU consolidation test for sched_mc &" \
+ "sched_smt with stress=50%"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests_exclusive02.sh b/testcases/kernel/power_management/runpwtests_exclusive02.sh
new file mode 100755
index 0000000..af08482
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests_exclusive02.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management_exclusive02"
+export TST_TOTAL=1
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+tst_kvercmp 2 6 29; rc=$?
+if [ $rc -eq 2 ] ; then
+ max_sched_smt=2
+else
+ max_sched_smt=1
+fi
+
+hyper_threaded=$(is_hyper_threaded)
+multi_socket=$(is_multi_socket)
+multi_core=$(is_multi_core)
+if [ $hyper_threaded -ne 0 -o $multi_socket -ne 0 \
+ -o $multi_core -eq 0 ]; then
+ tst_brkm TCONF "System is a multi core but not multi" \
+ "socket & hyper-threaded"
+fi
+
+#Testcase to validate consolidation at core level
+RC=0
+for sched_smt in `seq 0 $max_sched_smt`; do
+ if [ $sched_smt -eq 2 ]; then
+ work_load="kernbench"
+ else
+ work_load="ebizzy"
+ fi
+ sched_smt_pass_cnt=0
+ stress="thread"
+ for repeat_test in `seq 1 10`; do
+ if cpu_consolidation.py -t $sched_smt -w $work_load \
+ -s $stress; then
+ : $(( sched_smt_pass_cnt += 1 ))
+ fi
+ done
+ analyze_core_consolidation_result $sched_smt \
+ $sched_smt_pass_cnt; RC=$?
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "Consolidation test at core level for sched_smt"
+else
+ tst_resm TFAIL "Consolidation test at core level for sched_smt"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests_exclusive03.sh b/testcases/kernel/power_management/runpwtests_exclusive03.sh
new file mode 100755
index 0000000..4e3c99e
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests_exclusive03.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management_exclusive03"
+export TST_TOTAL=2
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+tst_kvercmp 2 6 29; rc=$?
+if [ $rc -eq 2 ] ; then
+ max_sched_mc=2
+ max_sched_smt=2
+else
+ max_sched_mc=1
+ max_sched_smt=1
+fi
+
+hyper_threaded=$(is_hyper_threaded)
+multi_socket=$(is_multi_socket)
+multi_core=$(is_multi_core)
+if [ $multi_socket -ne 0 -o $multi_core -ne 0 -o \
+ $hyper_threaded -ne 0 ]; then
+ tst_brkm TCONF "System is not a multi socket & multi core" \
+ "& hyper-threaded"
+fi
+
+# Verify threads consolidation stops when sched_mc &(/) sched_smt
+# is disabled.
+# Vary sched_mc from 1/2 to 0 when workload is running and
+# ensure that tasks do not consolidate to single package when
+# sched_mc is set to 0.
+RC=0
+for sched_mc in `seq 1 $max_sched_mc`; do
+ if cpu_consolidation.py -v -c $sched_mc; then
+ echo "Test PASS: CPU consolidation test by varying" \
+ "sched_mc $sched_mc to 0"
+ else
+ RC=1
+ echo "Test FAIL: CPU consolidation test by varying" \
+ "sched_mc $sched_mc to 0"
+ fi
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "CPU consolidation test by varying sched_mc"
+else
+ tst_resm TFAIL "CPU consolidation test by varying sched_mc"
+fi
+
+# Vary sched_mc & sched_smt from 1 to 0 & 2 to 0 when workload
+# is running and ensure that tasks do not consolidate to single
+# package when sched_mc is set to 0.
+RC=0
+for sched_mc in `seq 1 $max_sched_mc`; do
+ for sched_smt in `seq 1 $max_sched_smt`; do
+ if [ $sched_smt -eq $sched_mc ]; then
+ if cpu_consolidation.py -v -c $sched_mc \
+ -t $sched_smt; then
+ echo "Test PASS: CPU consolidation test by" \
+ "varying sched_mc & sched_smt from" \
+ "$sched_mc to 0"
+ else
+ RC=1
+ echo "Test FAIL: CPU consolidation test by" \
+ "varying sched_mc & sched_smt from" \
+ "$sched_mc to 0"
+ fi
+ fi
+ done
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "CPU consolidation test by varying" \
+ "sched_mc & sched_smt"
+else
+ tst_resm TFAIL "CPU consolidation test by varying" \
+ "sched_mc & sched_smt"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests_exclusive04.sh b/testcases/kernel/power_management/runpwtests_exclusive04.sh
new file mode 100755
index 0000000..7958fc0
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests_exclusive04.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management_exclusive04"
+export TST_TOTAL=2
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+hyper_threaded=$(is_hyper_threaded)
+multi_socket=$(is_multi_socket)
+if [ $hyper_threaded -ne 0 -o $multi_socket -ne 0 ]; then
+ tst_brkm TCONF "System is not a multi socket & hyper-threaded"
+fi
+
+# Verify threads consolidation stops when sched_smt is
+# disabled in HT systems.
+# Vary only sched_smt from 1 to 0 when workload is running
+# and ensure that tasks do not consolidate to single core
+# when sched_smt is set to 0.
+if cpu_consolidation.py -v -t 1; then
+ tst_resm TPASS "CPU consolidation test by varying sched_smt from 1 to 0"
+else
+ tst_resm TFAIL "CPU consolidation test by varying sched_smt from 1 to 0"
+fi
+
+# Vary only sched_smt from 2 to 0 when workload is running
+# and ensure that tasks do not consolidate to single core
+# when sched_smt is set to 0.
+if cpu_consolidation.py -v -t 2; then
+ tst_resm TPASS "CPU consolidation test by varying sched_smt from 2 to 0"
+else
+ tst_resm TFAIL "CPU consolidation test by varying sched_smt from 2 to 0"
+fi
+
+tst_exit
diff --git a/testcases/kernel/power_management/runpwtests_exclusive05.sh b/testcases/kernel/power_management/runpwtests_exclusive05.sh
new file mode 100755
index 0000000..186297f
--- /dev/null
+++ b/testcases/kernel/power_management/runpwtests_exclusive05.sh
@@ -0,0 +1,101 @@
+#! /bin/sh
+#
+# Copyright (c) International Business Machines Corp., 2001
+# Author: Nageswara R Sastry <nasastry@in.ibm.com>
+#
+# This program is free software; you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+export TCID="Power_Management_exclusive05"
+export TST_TOTAL=2
+
+. test.sh
+. pm_include.sh
+
+# Checking test environment
+check_kervel_arch
+
+tst_kvercmp 2 6 29; rc=$?
+if [ $rc -eq 2 ] ; then
+ max_sched_mc=2
+ max_sched_smt=2
+else
+ max_sched_mc=1
+ max_sched_smt=1
+fi
+
+hyper_threaded=$(is_hyper_threaded)
+multi_socket=$(is_multi_socket)
+multi_core=$(is_multi_core)
+if [ $multi_socket -ne 0 -o $multi_core -ne 0 -o \
+ $hyper_threaded -ne 0 ]; then
+ tst_brkm TCONF "System is not a multi socket & multi core" \
+ "& hyper-threaded"
+fi
+
+# Verify ILB runs in same package as workload.
+RC=0
+for sched_mc in `seq 1 $max_sched_mc`; do
+ if [ $sched_mc -eq 2 ]; then
+ work_load="kernbench"
+ else
+ work_load="ebizzy"
+ fi
+
+ ilb_test.py -c $sched_mc -w $work_load
+ if [ $? -eq 0 ]; then
+ echo "Test PASS: ILB & workload in same package for" \
+ "sched_mc=$sched_mc"
+ else
+ RC=1
+ echo "Test FAIL: ILB & workload did not run in same package" \
+ "for sched_mc=$sched_mc. Ensure CONFIG_NO_HZ is set"
+ fi
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "ILB & workload test in same package for sched_mc"
+else
+ tst_resm TFAIL "ILB & workload test in same package for sched_mc"
+fi
+
+RC=0
+for sched_mc in `seq 1 $max_sched_mc`; do
+ if [ $sched_mc -eq 2 ]; then
+ work_load="kernbench"
+ else
+ work_load="ebizzy"
+ fi
+ for sched_smt in `seq 1 $max_sched_smt`; do
+ ilb_test.py -c $sched_mc -t sched_smt -w $work_load
+ if [ $? -eq 0 ]; then
+ echo "Test PASS: ILB & workload in same package for" \
+ "sched_mc=$sched_mc & sched_smt=$sched_smt"
+ else
+ RC=1
+ echo "Test FAIL: ILB & workload did not execute in" \
+ "same package for sched_mc=$sched_mc &" \
+ "sched_smt=$sched_smt. Ensure CONFIG_NO_HZ is set"
+ fi
+ done
+done
+if [ $RC -eq 0 ]; then
+ tst_resm TPASS "ILB & workload test in same package for" \
+ "sched_mc & sched_smt"
+else
+ tst_resm TFAIL "ILB & workload test in same package for" \
+ "sched_mc & sched_smt"
+fi
+
+tst_exit
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 4/9] power_management: call the function eg. test_sched_mc instead of script test_sched_mc.sh
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 3/9] power_management: split runpwtests.sh into separate testcases Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-03-02 14:50 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 5/9] power_management: delete unused files Xing Gu
` (5 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
Many scripts eg. test_sched_mc.sh is called only from
one test eg. runpwtests01.sh. Remove the script code
into the corresponding test case.
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
testcases/kernel/power_management/change_freq.sh | 36 ------
testcases/kernel/power_management/change_govr.sh | 24 ----
.../power_management/check_cpufreq_sysfs_files.sh | 24 ----
.../power_management/check_cpuidle_sysfs_files.sh | 19 ---
.../kernel/power_management/pwkm_load_unload.sh | 30 -----
testcases/kernel/power_management/runpwtests01.sh | 24 +++-
testcases/kernel/power_management/runpwtests02.sh | 23 +++-
testcases/kernel/power_management/runpwtests03.sh | 131 ++++++++++++++++++++-
testcases/kernel/power_management/runpwtests04.sh | 23 +++-
testcases/kernel/power_management/runpwtests06.sh | 22 +++-
testcases/kernel/power_management/test_sched_mc.sh | 24 ----
.../kernel/power_management/test_sched_smt.sh | 23 ----
.../power_management/test_timer_migration.sh | 22 ----
13 files changed, 215 insertions(+), 210 deletions(-)
delete mode 100755 testcases/kernel/power_management/change_freq.sh
delete mode 100755 testcases/kernel/power_management/change_govr.sh
delete mode 100755 testcases/kernel/power_management/check_cpufreq_sysfs_files.sh
delete mode 100755 testcases/kernel/power_management/check_cpuidle_sysfs_files.sh
delete mode 100755 testcases/kernel/power_management/pwkm_load_unload.sh
delete mode 100755 testcases/kernel/power_management/test_sched_mc.sh
delete mode 100755 testcases/kernel/power_management/test_sched_smt.sh
delete mode 100755 testcases/kernel/power_management/test_timer_migration.sh
diff --git a/testcases/kernel/power_management/change_freq.sh b/testcases/kernel/power_management/change_freq.sh
deleted file mode 100755
index 3a971d2..0000000
--- a/testcases/kernel/power_management/change_freq.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-available_freq=$(get_supporting_freq)
-available_govr=$(get_supporting_govr)
-RC=0
-
-total_cpus=$(tst_ncpus)
-(( total_cpus-=1 ))
-
-if ( echo ${available_govr} | grep -i "userspace" 2>&1 >/dev/null ) ; then
- for cpu in $(seq 0 "${total_cpus}" )
- do
- echo userspace > /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_governor
- if [ $? -ne 0 ] ; then
- RC=1
- fi
- done
- if [ ${RC} -ne 1 ] ; then
- for cpu in $(seq 0 "${total_cpus}" )
- do
- for freq in ${available_freq}
- do
- echo ${freq} > /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_setspeed
- if [ "$?" -ne "0" ] ; then
- echo "${0}: FAIL: Unable to set frequency -- ${freq} for cpu${cpu}"
- RC=1
- fi
- done
- done
- fi
-fi
-if [ ${RC} -eq 0 ] ; then
- echo "${0}: PASS: Changing cpu frequencies"
-fi
-exit $RC
diff --git a/testcases/kernel/power_management/change_govr.sh b/testcases/kernel/power_management/change_govr.sh
deleted file mode 100755
index bfe6c5b..0000000
--- a/testcases/kernel/power_management/change_govr.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-available_govr=$(get_supporting_govr)
-
-total_cpus=$(tst_ncpus)
-(( total_cpus-=1 ))
-RC=0
-
-for cpu in $(seq 0 "${total_cpus}" )
-do
- for govr in ${available_govr}
- do
- echo ${govr} > /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_governor
- if [ "$?" -ne "0" ] ; then
- echo "${0}: FAIL: Unable to set governor -- ${govr} for cpu${cpu}"
- RC=1
- fi
- done
-done
-if [ ${RC} -eq 0 ] ; then
- echo "${0}: PASS: Changing cpu governors"
-fi
-exit $RC
diff --git a/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh b/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh
deleted file mode 100755
index dcf8a1d..0000000
--- a/testcases/kernel/power_management/check_cpufreq_sysfs_files.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-
-total_cpus=$(tst_ncpus)
-(( total_cpus-=1 ))
-RC=0
-
-for cpu in $(seq 0 "${total_cpus}" )
-do
- cpufiles=$(find /sys/devices/system/cpu/cpu"${cpu}"/cpufreq/ -name "*" -type f)
- for files in ${cpufiles}
- do
- cat ${files} 2>&1 >/dev/null
- if [ $? -ne 0 ] ; then
- echo "${0}: FAIL: cat ${files}"
- RC=1
- fi
- done
-done
-if [ ${RC} -eq 0 ] ; then
- echo "${0}: PASS: Checking cpu freq sysfs files"
-fi
-exit $RC
diff --git a/testcases/kernel/power_management/check_cpuidle_sysfs_files.sh b/testcases/kernel/power_management/check_cpuidle_sysfs_files.sh
deleted file mode 100755
index 4ed4d5b..0000000
--- a/testcases/kernel/power_management/check_cpuidle_sysfs_files.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-RC=0
-if [ -d /sys/devices/system/cpu/cpuidle ] ; then
- for files in current_governor_ro current_driver
- do
- cat /sys/devices/system/cpu/cpuidle/${files} >/dev/null 2>&1
- if [ $? -ne 0 ] ; then
- echo "${0}: FAIL: cat ${files}"
- RC=1
- fi
- done
-fi
-if [ ${RC} -eq 0 ] ; then
- echo "${0}: PASS: Checking cpu idle sysfs files"
-else
- echo "${0}: FAIL: Checking cpu idle sysfs files"
-fi
-exit $RC
diff --git a/testcases/kernel/power_management/pwkm_load_unload.sh b/testcases/kernel/power_management/pwkm_load_unload.sh
deleted file mode 100755
index 9bcbd56..0000000
--- a/testcases/kernel/power_management/pwkm_load_unload.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-#Loading modules
-RC=0
-loaded_governor=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
-for module in `modprobe -l | grep cpufreq_ | cut -f8 -d"/" | cut -f1 -d"."`
-do
- #echo -n "Loading $module ... "
- if [ $module != "cpufreq_$loaded_governor" ];
- then
- modprobe $module >/dev/null
- if [ $? -ne 0 ] ; then
- echo "${0}: FAIL: Loading of module $module or check whether you compiled as module or not"
- RC=1
- fi
- fi
-done
-for module in `modprobe -l | grep cpufreq_ | cut -f8 -d"/" | cut -f1 -d"."`
-do
- #echo -n "Unloading $module ... "
- if [ $module != "cpufreq_$loaded_governor" ];
- then
- modprobe -r $module >/dev/null
- if [ $? -ne 0 ] ; then
- echo "${0}: FAIL: Loading of module $module or check whether you compiled as module or not"
- RC=1
- fi
- fi
-done
-exit $RC
diff --git a/testcases/kernel/power_management/runpwtests01.sh b/testcases/kernel/power_management/runpwtests01.sh
index 7dc164c..d470d11 100755
--- a/testcases/kernel/power_management/runpwtests01.sh
+++ b/testcases/kernel/power_management/runpwtests01.sh
@@ -24,6 +24,28 @@ export TST_TOTAL=1
. test.sh
. pm_include.sh
+test_sched_mc() {
+ get_kernel_version
+ get_valid_input $kernel_version
+
+ invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
+ 2000000000000000000000000000000000000000000000000000000000000000000
+ ox324 -0xfffffffffffffffffffff"
+ test_file="/sys/devices/system/cpu/sched_mc_power_savings"
+ if [ ! -f ${test_file} ] ; then
+ tst_brkm TBROK "MISSING_FILE: missing file ${test_file}"
+ fi
+
+ RC=0
+ echo "${0}: ---Valid test cases---"
+ check_input "${valid_input}" valid $test_file
+ RC=$?
+ echo "${0}: ---Invalid test cases---"
+ check_input "${invalid_input}" invalid $test_file
+ RC=$(( RC | $? ))
+ return $RC
+}
+
# Checking test environment
check_kervel_arch
@@ -40,7 +62,7 @@ else
fi
fi
-if test_sched_mc.sh ; then
+if test_sched_mc ; then
tst_resm TPASS "SCHED_MC sysfs tests"
else
tst_resm TFAIL "SCHED_MC sysfs tests"
diff --git a/testcases/kernel/power_management/runpwtests02.sh b/testcases/kernel/power_management/runpwtests02.sh
index 067569e..8c7936f 100755
--- a/testcases/kernel/power_management/runpwtests02.sh
+++ b/testcases/kernel/power_management/runpwtests02.sh
@@ -24,6 +24,27 @@ export TST_TOTAL=1
. test.sh
. pm_include.sh
+test_sched_smt() {
+ get_kernel_version
+ get_valid_input $kernel_version
+
+ invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
+ 2000000000000000000000000000000000000000000000000000000000000000000000
+ ox324 -0xfffffffffffffffffffff"
+ test_file="/sys/devices/system/cpu/sched_smt_power_savings"
+ if [ ! -f ${test_file} ] ; then
+ tst_brkm TBROK "MISSING_FILE: missing file ${test_file}"
+ fi
+
+ echo "${0}: ---Valid test cases---"
+ check_input "${valid_input}" valid $test_file
+ RC=$?
+ echo "${0}: ---Invalid test cases---"
+ check_input "${invalid_input}" invalid $test_file
+ RC=$(( RC | $? ))
+ return $RC
+}
+
# Checking test environment
check_kervel_arch
@@ -38,7 +59,7 @@ else
fi
fi
-if test_sched_smt.sh ; then
+if test_sched_smt ; then
tst_resm TPASS "SCHED_SMT sysfs test"
else
tst_resm TFAIL "SCHED_SMT sysfs test"
diff --git a/testcases/kernel/power_management/runpwtests03.sh b/testcases/kernel/power_management/runpwtests03.sh
index 34fb1a4..7e9ac4b 100755
--- a/testcases/kernel/power_management/runpwtests03.sh
+++ b/testcases/kernel/power_management/runpwtests03.sh
@@ -24,6 +24,129 @@ export TST_TOTAL=4
. test.sh
. pm_include.sh
+check_cpufreq_sysfs_files() {
+ total_cpus=$(tst_ncpus)
+ (( total_cpus-=1 ))
+ RC=0
+
+ for cpu in $(seq 0 "${total_cpus}" )
+ do
+ cpufiles=$(find /sys/devices/system/cpu/cpu"${cpu}"/cpufreq/ \
+ -name "*" -type f)
+ for files in ${cpufiles}
+ do
+ cat ${files} 2>&1 >/dev/null
+ if [ $? -ne 0 ] ; then
+ echo "${0}: FAIL: cat ${files}"
+ RC=1
+ fi
+ done
+ done
+ if [ ${RC} -eq 0 ] ; then
+ echo "${0}: PASS: Checking cpu freq sysfs files"
+ fi
+ return $RC
+}
+
+change_govr() {
+ available_govr=$(get_supporting_govr)
+
+ total_cpus=$(tst_ncpus)
+ (( total_cpus-=1 ))
+ RC=0
+
+ for cpu in $(seq 0 "${total_cpus}" )
+ do
+ for govr in ${available_govr}
+ do
+ echo ${govr} > \
+ /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_governor
+ if [ "$?" -ne "0" ] ; then
+ echo "${0}: FAIL: Unable to set" \
+ "governor -- ${govr} for cpu${cpu}"
+ RC=1
+ fi
+ done
+ done
+ if [ ${RC} -eq 0 ] ; then
+ echo "${0}: PASS: Changing cpu governors"
+ fi
+ return $RC
+}
+
+change_freq() {
+ available_freq=$(get_supporting_freq)
+ available_govr=$(get_supporting_govr)
+ RC=0
+
+ total_cpus=$(tst_ncpus)
+ (( total_cpus-=1 ))
+
+ if ( echo ${available_govr} | grep -i "userspace" \
+ 2>&1 >/dev/null ); then
+ for cpu in $(seq 0 "${total_cpus}" )
+ do
+ echo userspace > \
+ /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_governor
+ if [ $? -ne 0 ] ; then
+ RC=1
+ fi
+ done
+ if [ ${RC} -ne 1 ] ; then
+ for cpu in $(seq 0 "${total_cpus}" )
+ do
+ for freq in ${available_freq}
+ do
+ echo ${freq} > \
+ /sys/devices/system/cpu/cpu${cpu}/cpufreq/scaling_setspeed
+ if [ "$?" -ne "0" ] ; then
+ echo "${0}: FAIL: Unable" \
+ "to set frequency -- ${freq} for cpu${cpu}"
+ RC=1
+ fi
+ done
+ done
+ fi
+ fi
+ if [ ${RC} -eq 0 ] ; then
+ echo "${0}: PASS: Changing cpu frequencies"
+ fi
+ return $RC
+}
+
+pwkm_load_unload() {
+ RC=0
+ loaded_governor=`cat \
+ /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
+ for module in `modprobe -l | grep cpufreq_ | \
+ cut -f8 -d"/" | cut -f1 -d"."`
+ do
+ #echo -n "Loading $module ... "
+ if [ $module != "cpufreq_$loaded_governor" ]; then
+ modprobe $module >/dev/null
+ if [ $? -ne 0 ] ; then
+ echo "${0}: FAIL: Loading of module $module" \
+ "or check whether you compiled as module or not"
+ RC=1
+ fi
+ fi
+ done
+ for module in `modprobe -l | grep cpufreq_ | \
+ cut -f8 -d"/" | cut -f1 -d"."`
+ do
+ #echo -n "Unloading $module ... "
+ if [ $module != "cpufreq_$loaded_governor" ]; then
+ modprobe -r $module >/dev/null
+ if [ $? -ne 0 ] ; then
+ echo "${0}: FAIL: Loading of module $module" \
+ "or check whether you compiled as module or not"
+ RC=1
+ fi
+ fi
+ done
+ return $RC
+}
+
# Checking test environment
check_kervel_arch
@@ -32,28 +155,28 @@ if [ ! -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
tst_brkm TCONF "Required kernel configuration for CPU_FREQ NOT set"
fi
-if check_cpufreq_sysfs_files.sh ; then
+if check_cpufreq_sysfs_files ; then
tst_resm TPASS "CPUFREQ sysfs tests"
else
tst_resm TFAIL "CPUFREQ sysfs tests"
fi
# Changing governors
-if change_govr.sh ; then
+if change_govr ; then
tst_resm TPASS "Changing governors"
else
tst_resm TFAIL "Changing governors"
fi
# Changing frequencies
-if change_freq.sh ; then
+if change_freq ; then
tst_resm TPASS "Changing frequncies"
else
tst_resm TFAIL "Changing frequncies"
fi
# Loading and Unloading governor related kernel modules
-if pwkm_load_unload.sh ; then
+if pwkm_load_unload ; then
tst_resm TPASS "Loading and Unloading of governor kernel" \
"modules"
else
diff --git a/testcases/kernel/power_management/runpwtests04.sh b/testcases/kernel/power_management/runpwtests04.sh
index eeb4b22..4b727a5 100755
--- a/testcases/kernel/power_management/runpwtests04.sh
+++ b/testcases/kernel/power_management/runpwtests04.sh
@@ -24,11 +24,32 @@ export TST_TOTAL=1
. test.sh
. pm_include.sh
+check_cpuidle_sysfs_files() {
+ RC=0
+ if [ -d /sys/devices/system/cpu/cpuidle ] ; then
+ for files in current_governor_ro current_driver
+ do
+ cat /sys/devices/system/cpu/cpuidle/${files} \
+ >/dev/null 2>&1
+ if [ $? -ne 0 ] ; then
+ echo "${0}: FAIL: cat ${files}"
+ RC=1
+ fi
+ done
+ fi
+ if [ ${RC} -eq 0 ] ; then
+ echo "${0}: PASS: Checking cpu idle sysfs files"
+ else
+ echo "${0}: FAIL: Checking cpu idle sysfs files"
+ fi
+ return $RC
+}
+
# Checking test environment
check_kervel_arch
# Checking cpuidle sysfs interface files
-if check_cpuidle_sysfs_files.sh ; then
+if check_cpuidle_sysfs_files ; then
tst_resm TPASS "CPUIDLE sysfs tests passed"
else
tst_resm TFAIL "CPUIDLE sysfs tests failed"
diff --git a/testcases/kernel/power_management/runpwtests06.sh b/testcases/kernel/power_management/runpwtests06.sh
index ab5d7de..7888a39 100755
--- a/testcases/kernel/power_management/runpwtests06.sh
+++ b/testcases/kernel/power_management/runpwtests06.sh
@@ -24,6 +24,26 @@ export TST_TOTAL=1
. test.sh
. pm_include.sh
+test_timer_migration() {
+ valid_input="0 1"
+ invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
+ 2000000000000000000000000000000000000000000000000000000000000000000000
+ ox324 -0xfffffffffffffffffffff"
+ test_file="/proc/sys/kernel/timer_migration"
+ if [ ! -f ${test_file} ] ; then
+ tst_brkm TBROK "MISSING_FILE: missing file ${test_file}"
+ fi
+
+ RC=0
+ echo "${0}: ---Valid test cases---"
+ check_input "${valid_input}" valid $test_file
+ RC=$?
+ echo "${0}: ---Invalid test cases---"
+ check_input "${invalid_input}" invalid $test_file
+ RC=$(( RC | $? ))
+ return $RC
+}
+
# Checking test environment
check_kervel_arch
@@ -42,7 +62,7 @@ else
fi
fi
-if test_timer_migration.sh; then
+if test_timer_migration ; then
tst_resm TPASS "Timer Migration interface test"
else
tst_resm TFAIL "Timer migration interface test"
diff --git a/testcases/kernel/power_management/test_sched_mc.sh b/testcases/kernel/power_management/test_sched_mc.sh
deleted file mode 100755
index c695798..0000000
--- a/testcases/kernel/power_management/test_sched_mc.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-
-get_kernel_version
-get_valid_input $kernel_version
-
-invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
-200000000000000000000000000000000000000000000000000000000000000000000000000000
-ox324 -0xfffffffffffffffffffff"
-test_file="/sys/devices/system/cpu/sched_mc_power_savings"
-if [ ! -f ${test_file} ] ; then
- echo "MISSING_FILE: missing file ${test_file}"
- exit $MISSING_FILE
-fi
-
-RC=0
-echo "${0}: ---Valid test cases---"
-check_input "${valid_input}" valid $test_file
-RC=$?
-echo "${0}: ---Invalid test cases---"
-check_input "${invalid_input}" invalid $test_file
-RC=$(( RC | $? ))
-exit $RC
diff --git a/testcases/kernel/power_management/test_sched_smt.sh b/testcases/kernel/power_management/test_sched_smt.sh
deleted file mode 100755
index 6cde834..0000000
--- a/testcases/kernel/power_management/test_sched_smt.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-
-get_kernel_version
-get_valid_input $kernel_version
-
-invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
-200000000000000000000000000000000000000000000000000000000000000000000000000000
-ox324 -0xfffffffffffffffffffff"
-test_file="/sys/devices/system/cpu/sched_smt_power_savings"
-if [ ! -f ${test_file} ] ; then
- echo "MISSING_FILE: missing file ${test_file}"
- exit $MISSING_FILE
-fi
-
-echo "${0}: ---Valid test cases---"
-check_input "${valid_input}" valid $test_file
-RC=$?
-echo "${0}: ---Invalid test cases---"
-check_input "${invalid_input}" invalid $test_file
-RC=$(( RC | $? ))
-exit $RC
diff --git a/testcases/kernel/power_management/test_timer_migration.sh b/testcases/kernel/power_management/test_timer_migration.sh
deleted file mode 100755
index e2d3296..0000000
--- a/testcases/kernel/power_management/test_timer_migration.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-
-valid_input="0 1"
-invalid_input="3 4 5 6 7 8 a abcefg x1999 xffff -1 -00000
-200000000000000000000000000000000000000000000000000000000000000000000000000000
-ox324 -0xfffffffffffffffffffff"
-test_file="/proc/sys/kernel/timer_migration"
-if [ ! -f ${test_file} ] ; then
- echo "MISSING_FILE: missing file ${test_file}"
- exit $MISSING_FILE
-fi
-
-RC=0
-echo "${0}: ---Valid test cases---"
-check_input "${valid_input}" valid $test_file
-RC=$?
-echo "${0}: ---Invalid test cases---"
-check_input "${invalid_input}" invalid $test_file
-RC=$(( RC | $? ))
-exit $RC
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 5/9] power_management: delete unused files
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
` (2 preceding siblings ...)
2015-02-27 8:12 ` [LTP] [PATCH v3 4/9] power_management: call the function eg. test_sched_mc instead of script test_sched_mc.sh Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 6/9] power_management: prefix files with "pm_" Xing Gu
` (4 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
There are some files that are not used by this
testsuit. Delete them.
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
testcases/kernel/power_management/check_config.sh | 32 -----------------------
testcases/kernel/power_management/config_cpu_freq | 7 -----
testcases/kernel/power_management/config_cpu_idle | 3 ---
testcases/kernel/power_management/config_sched_mc | 1 -
4 files changed, 43 deletions(-)
delete mode 100755 testcases/kernel/power_management/check_config.sh
delete mode 100644 testcases/kernel/power_management/config_cpu_freq
delete mode 100644 testcases/kernel/power_management/config_cpu_idle
delete mode 100644 testcases/kernel/power_management/config_sched_mc
diff --git a/testcases/kernel/power_management/check_config.sh b/testcases/kernel/power_management/check_config.sh
deleted file mode 100755
index 4eeac4e..0000000
--- a/testcases/kernel/power_management/check_config.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-
-. pm_include.sh
-
-if [ $# -lt 1 ] ; then
- echo "Usage: ${0} <filename>"
- RC=1
- return ${RC}
-fi
-filename=${1}
-
-RC=0
-grep_command=grep
-config_file=/boot/config-$(uname -r)
-if [ ! -f ${config_file} ]; then
- echo "MISSING_FILE: can't find the required config file at /boot/config-$(uname -r)"
- echo "Trying for alternate file at /proc/config.gz"
- config_file=/proc/config.gz
-fi
-if [ ! -f ${config_file} ]; then
- echo "MISSING_FILE: can't find the required config file at /proc/config.gz"
- RC=1
-fi
-if [ "${config_file}" = "/proc/config.gz" ] ; then
- grep_command=zgrep
-fi
-
-while read config_option
-do
- check_config_options "${config_option}=*" ${config_file} ${grep_command}
-done < ${filename}
-exit $RC
diff --git a/testcases/kernel/power_management/config_cpu_freq b/testcases/kernel/power_management/config_cpu_freq
deleted file mode 100644
index 76401e6..0000000
--- a/testcases/kernel/power_management/config_cpu_freq
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG_CPU_FREQ
-CONFIG_CPU_FREQ_TABLE
-CONFIG_CPU_FREQ_DEBUG
-CONFIG_CPU_FREQ_STAT
-CONFIG_CPU_FREQ_STAT_DETAILS
-CONFIG_CPU_FREQ_DEFAULT_GOV_*
-CONFIG_CPU_FREQ_GOV_*
diff --git a/testcases/kernel/power_management/config_cpu_idle b/testcases/kernel/power_management/config_cpu_idle
deleted file mode 100644
index f899fae..0000000
--- a/testcases/kernel/power_management/config_cpu_idle
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_CPU_IDLE
-CONFIG_CPU_IDLE_GOV_LADDER
-CONFIG_CPU_IDLE_GOV_MENU
diff --git a/testcases/kernel/power_management/config_sched_mc b/testcases/kernel/power_management/config_sched_mc
deleted file mode 100644
index 30d0f97..0000000
--- a/testcases/kernel/power_management/config_sched_mc
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_SCHED_MC
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 6/9] power_management: prefix files with "pm_"
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
` (3 preceding siblings ...)
2015-02-27 8:12 ` [LTP] [PATCH v3 5/9] power_management: delete unused files Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 7/9] power_management: install lib/pm_sched_mc.py into testcases/bin directory Xing Gu
` (3 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
.../kernel/power_management/cpu_consolidation.py | 145 ----
.../kernel/power_management/get_sched_values.c | 50 --
testcases/kernel/power_management/ilb_test.py | 59 --
.../kernel/power_management/lib/pm_sched_mc.py | 872 +++++++++++++++++++++
testcases/kernel/power_management/lib/sched_mc.py | 872 ---------------------
.../power_management/pm_cpu_consolidation.py | 145 ++++
.../kernel/power_management/pm_get_sched_values.c | 50 ++
testcases/kernel/power_management/pm_ilb_test.py | 59 ++
.../kernel/power_management/pm_sched_domain.py | 56 ++
testcases/kernel/power_management/runpwtests05.sh | 6 +-
.../power_management/runpwtests_exclusive01.sh | 4 +-
.../power_management/runpwtests_exclusive02.sh | 2 +-
.../power_management/runpwtests_exclusive03.sh | 4 +-
.../power_management/runpwtests_exclusive04.sh | 4 +-
.../power_management/runpwtests_exclusive05.sh | 4 +-
testcases/kernel/power_management/sched_domain.py | 56 --
16 files changed, 1194 insertions(+), 1194 deletions(-)
delete mode 100755 testcases/kernel/power_management/cpu_consolidation.py
delete mode 100644 testcases/kernel/power_management/get_sched_values.c
delete mode 100755 testcases/kernel/power_management/ilb_test.py
create mode 100755 testcases/kernel/power_management/lib/pm_sched_mc.py
delete mode 100755 testcases/kernel/power_management/lib/sched_mc.py
create mode 100755 testcases/kernel/power_management/pm_cpu_consolidation.py
create mode 100644 testcases/kernel/power_management/pm_get_sched_values.c
create mode 100755 testcases/kernel/power_management/pm_ilb_test.py
create mode 100755 testcases/kernel/power_management/pm_sched_domain.py
delete mode 100755 testcases/kernel/power_management/sched_domain.py
diff --git a/testcases/kernel/power_management/cpu_consolidation.py b/testcases/kernel/power_management/cpu_consolidation.py
deleted file mode 100755
index 992a745..0000000
--- a/testcases/kernel/power_management/cpu_consolidation.py
+++ /dev/null
@@ -1,145 +0,0 @@
-#!/usr/bin/python
-''' This Python script interprets various sched stats values.
- Validates cpu consolidation for given sched_mc_power_saving value
-'''
-
-import os
-import sys
-import time
-LIB_DIR = "%s/lib" % os.path.dirname(__file__)
-sys.path.append(LIB_DIR)
-from optparse import OptionParser
-from sched_mc import *
-
-__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
-
-class Usage(Exception):
- def __init__(self, msg):
- self.msg = msg
-
-def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- usage = "-w"
- parser = OptionParser(usage)
- parser.add_option("-v", "--variation_test", dest="vary_mc_smt",
- default=False, action="store_true", help="Vary sched_mc & sched_smt. \
- -c and -t inputs are initial value of sched_mc & sched_smt")
- parser.add_option("-c", "--mc_value", dest="mc_value",
- default=0, help="Sched mc power saving value 0/1/2")
- parser.add_option("-t", "--smt_value", dest="smt_value",
- default=0, help="Sched smt power saving value 0/1/2")
- parser.add_option("-w", "--workload", dest="work_ld",
- default="ebizzy", help="Workload can be ebizzy/kernbench")
- parser.add_option("-s", "--stress", dest="stress",
- default="partial", help="Load on system is full/partial [i.e 50%]/thread")
- parser.add_option("-p", "--performance", dest="perf_test",
- default=False, action="store_true", help="Enable performance test")
- (options, args) = parser.parse_args()
-
- try:
- count_num_cpu()
- count_num_sockets()
- if is_hyper_threaded():
- generate_sibling_list()
-
- # User should set option -v to test cpu consolidation
- # resets when sched_mc &(/) sched_smt is disabled when
- # workload is already running in the system
-
- if options.vary_mc_smt:
-
- # Since same code is used for testing package consolidation and core
- # consolidation is_multi_socket & is_hyper_threaded check is done
- if is_multi_socket() and is_multi_core() and options.mc_value:
- set_sched_mc_power(options.mc_value)
-
- if is_hyper_threaded() and options.smt_value:
- set_sched_smt_power(options.smt_value)
-
- #Generate arguments for trigger workload, run workload in background
- map_cpuid_pkgid()
- background="yes"
- duration=360
- pinned="no"
- if int(options.mc_value) < 2 and int(options.smt_value) < 2:
- trigger_ebizzy (options.smt_value, "partial", duration, background, pinned)
- work_ld="ebizzy"
- #Wait for 120 seconds and then validate cpu consolidation works
- #When sched_mc & sched_smt is set
- import time
- time.sleep(120)
- else:
- #Wait for 120 seconds and then validate cpu consolidation works
- #When sched_mc & sched_smt is set
- trigger_kernbench (options.smt_value, "partial", background, pinned, "no")
- work_ld="kernbench"
- import time
- time.sleep(300)
-
- generate_report()
- status = validate_cpu_consolidation("partial", work_ld, options.mc_value, options.smt_value)
- if status == 0:
- print "INFO: Consolidation worked sched_smt &(/) sched_mc is set"
- #Disable sched_smt & sched_mc interface values
- if options.vary_mc_smt and options.mc_value > 0:
- set_sched_mc_power(0)
- mc_value = options.mc_value
- else:
- mc_value = 0
- if options.vary_mc_smt and options.smt_value > 0 and is_hyper_threaded():
- set_sched_smt_power(0)
- smt_value = options.smt_value
- else:
- smt_value = 0
-
- if work_ld == "kernbench":
- time.sleep(240)
- else:
- time.sleep(120)
-
- generate_report()
- status = validate_cpu_consolidation("partial", work_ld, mc_value, smt_value)
- if background == "yes":
- stop_wkld(work_ld)
- #CPU consolidation should fail as sched_mc &(/) sched_smt is disabled
- if status == 1:
- return(0)
- else:
- return(1)
- else:
- print "INFO: CPU consolidation failed when sched_mc &(/) \
-sched_smt was enabled. This is pre-requisite to proceed"
- return(status)
- else:
- #The else part of the code validates behaviour of sched_mc
- # and sched_smt set to 0, 1 & 2
- if is_multi_socket():
- set_sched_mc_power(options.mc_value)
- if is_hyper_threaded():
- set_sched_smt_power(options.smt_value)
- map_cpuid_pkgid()
- print "INFO: Created table mapping cpu to package"
- background="no"
- duration=60
- pinned ="no"
-
- if options.perf_test:
- perf_test="yes"
- else:
- perf_test="no"
-
- trigger_workld( options.smt_value, options.work_ld, options.stress, duration, background, pinned, perf_test)
- generate_report()
- status = validate_cpu_consolidation(options.stress, options.work_ld,options.mc_value, options.smt_value)
- reset_schedmc()
- if is_hyper_threaded():
- reset_schedsmt()
- return(status)
- except Exception, details:
- print "INFO: CPU consolidation failed", details
- return(1)
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/testcases/kernel/power_management/get_sched_values.c b/testcases/kernel/power_management/get_sched_values.c
deleted file mode 100644
index 328e682..0000000
--- a/testcases/kernel/power_management/get_sched_values.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/************************************************************************
-* Copyright (c) International Business Machines Corp., 2008
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*
-***************************************************************************/
-#include <stdio.h>
-#include "test.h"
-
-const char *TCID = "get_sched_values";
-
-int get_supp_sched_mc(void)
-{
- if (tst_kvercmp(2, 6, 29) < 0)
- return 1;
- else
- return 2;
-}
-
-int get_supp_sched_smt(void)
-{
- if (tst_kvercmp(2, 6, 29) < 0)
- return 1;
- else
- return 2;
-}
-
-int main(int argc, char **argv)
-{
- char *param;
- if (argc == 0)
- return 1;
- else {
- param = argv[1];
- if (strcmp(param, "sched_mc") == 0)
- return (get_supp_sched_mc());
- if (strcmp(param, "sched_smt") == 0)
- return (get_supp_sched_smt());
- }
-}
diff --git a/testcases/kernel/power_management/ilb_test.py b/testcases/kernel/power_management/ilb_test.py
deleted file mode 100755
index cec0b29..0000000
--- a/testcases/kernel/power_management/ilb_test.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/python
-''' This Python script interprets interrupt values.
- Validates Ideal load balancer runs in same package where workload is running
-'''
-
-import os
-import sys
-LIB_DIR = "%s/lib" % os.path.dirname(__file__)
-sys.path.append(LIB_DIR)
-from optparse import OptionParser
-from sched_mc import *
-
-__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
-
-class Usage(Exception):
- def __init__(self, msg):
- self.msg = msg
-
-def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- usage = "-w"
- parser = OptionParser(usage)
- parser.add_option("-c", "--mc_level", dest="mc_level",
- default=0, help="Sched mc power saving value 0/1/2")
- parser.add_option("-t", "--smt_level", dest="smt_level",
- default=0, help="Sched smt power saving value 0/1/2")
- parser.add_option("-w", "--workload", dest="work_ld",
- default="ebizzy", help="Workload can be ebizzy/kernbench")
- (options, args) = parser.parse_args()
-
- try:
- count_num_cpu()
- count_num_sockets()
- if is_multi_socket():
- set_sched_mc_power(options.mc_level)
- if is_hyper_threaded():
- set_sched_smt_power(options.smt_level)
- map_cpuid_pkgid()
- print "INFO: Created table mapping cpu to package"
- background="no"
- duration=120
- pinned="yes"
-
- trigger_workld(options.smt_level,options.work_ld, "single_job", duration, background, pinned, "no")
- generate_loc_intr_report()
- status = validate_ilb(options.mc_level, options.smt_level)
- reset_schedmc()
- if is_hyper_threaded():
- reset_schedsmt()
- return(status)
-
- except Exception, details:
- print "INFO: Idle Load Balancer test failed", details
- return(1)
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/testcases/kernel/power_management/lib/pm_sched_mc.py b/testcases/kernel/power_management/lib/pm_sched_mc.py
new file mode 100755
index 0000000..24285eb
--- /dev/null
+++ b/testcases/kernel/power_management/lib/pm_sched_mc.py
@@ -0,0 +1,872 @@
+#!/usr/bin/python
+''' Reusable functions related to sched mc FVT are put together
+'''
+
+import os
+import sys
+import re
+from time import time
+
+__author__ = "Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>"
+__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
+
+
+cpu_map = {}
+stats_start = {}
+stats_stop = {}
+stats_percentage = {}
+intr_start = []
+intr_stop = []
+cpu_count = 0
+socket_count = 0
+cpu1_max_intr = 0
+cpu2_max_intr = 0
+intr_stat_timer_0 = []
+siblings_list = []
+
+def clear_dmesg():
+ '''
+ Clears dmesg
+ '''
+ try:
+ os.system('dmesg -c >/dev/null')
+ except OSError, e:
+ print 'Clearing dmesg failed', e
+ sys.exit(1)
+
+def count_num_cpu():
+ ''' Returns number of cpu's in system
+ '''
+ try:
+ cpuinfo = open('/proc/cpuinfo', 'r')
+ global cpu_count
+ for line in cpuinfo:
+ if line.startswith('processor'):
+ cpu_count += 1
+ cpuinfo.close()
+ except IOError, e:
+ print "Could not get cpu count", e
+ sys.exit(1)
+
+def count_num_sockets():
+ ''' Returns number of cpu's in system
+ '''
+ socket_list = []
+ global socket_count
+ try:
+ for i in range(0, cpu_count):
+ phy_pkg_file = '/sys/devices/system/cpu/cpu%s' % i
+ phy_pkg_file += '/topology/physical_package_id'
+ socket_id = open(phy_pkg_file).read().rstrip()
+ if socket_id not in socket_list:
+ socket_list.append(socket_id)
+ socket_count = socket_count + 1
+ except Exception, details:
+ print "INFO: Failed to get number of sockets in system", details
+ sys.exit(1)
+
+def is_multi_socket():
+ '''Return 1 if the system is multi socket else return 0
+ '''
+ try:
+ if socket_count > 1:
+ return 1
+ else:
+ return 0
+ except Exception:
+ print "Failed to check if system is multi socket system"
+ sys.exit(1)
+
+def is_hyper_threaded():
+ '''Return 1 if the system is hyper threaded else return 0
+ '''
+ try:
+ file_cpuinfo = open("/proc/cpuinfo", 'r')
+ for line in file_cpuinfo:
+ if line.startswith('siblings'):
+ siblings = line.split(":")
+ if line.startswith('cpu cores'):
+ cpu_cores = line.split(":")
+ break
+ if int( siblings[1] ) / int( cpu_cores[1] )> 1:
+ file_cpuinfo.close()
+ return 1
+ else:
+ return 0
+ except Exception:
+ print "Failed to check if system is hyper-threaded"
+ sys.exit(1)
+
+def is_multi_core():
+ ''' Return true if system has sockets has multiple cores
+ '''
+
+ try:
+ file_cpuinfo = open("/proc/cpuinfo", 'r')
+ for line in file_cpuinfo:
+ if line.startswith('siblings'):
+ siblings = line.split(":")
+ if line.startswith('cpu cores'):
+ cpu_cores = line.split(":")
+ break
+
+ if int( siblings[1] ) == int( cpu_cores[1] ):
+ if int( cpu_cores[1] ) > 1:
+ multi_core = 1
+ else:
+ multi_core = 0
+ else:
+ num_of_cpus = int(siblings[1]) / int(cpu_cores[1])
+ if num_of_cpus > 1:
+ multi_core = 1
+ else:
+ multi_core = 0
+ file_cpuinfo.close()
+ return multi_core
+ except Exception:
+ print "Failed to check if system is multi core system"
+ sys.exit(1)
+
+def get_hyper_thread_count():
+ ''' Return number of threads in CPU. For eg for x3950 this function
+ would return 2. In future if 4 threads are supported in CPU, this
+ routine would return 4
+ '''
+ try:
+ file_cpuinfo = open("/proc/cpuinfo", 'r')
+ for line in file_cpuinfo:
+ if line.startswith('siblings'):
+ siblings = line.split(":")
+ if line.startswith('cpu cores'):
+ cpu_cores = line.split(":")
+ break
+ return( int( siblings[1] ) / int( cpu_cores[1] ) )
+ except Exception:
+ print "Failed to check if system is hyper-threaded"
+ sys.exit(1)
+
+def map_cpuid_pkgid():
+ ''' Routine to map physical package id to cpu id
+ '''
+ if is_hyper_threaded():
+ core_info = {}
+ try:
+ for i in range(0, cpu_count):
+ phy_pkg_file = '/sys/devices/system/cpu/cpu%s' % i
+ phy_pkg_file += '/topology/physical_package_id'
+ core_file = '/sys/devices/system/cpu/cpu%s' % i
+ core_file += '/topology/core_id'
+ core_id = open(core_file).read().rstrip()
+ cpu_phy_id = open(phy_pkg_file).read().rstrip()
+ if not cpu_phy_id in cpu_map.keys():
+ core_info = {}
+ else:
+ core_info = cpu_map[cpu_phy_id]
+ if not core_id in core_info.keys():
+ core_info[core_id] = [i]
+ else:
+ core_info[core_id].append(i)
+ cpu_map[cpu_phy_id] = core_info
+ except Exception, details:
+ print "Package, core & cpu map table creation failed", e
+ sys.exit(1)
+ else:
+ for i in range(0, cpu_count):
+ try:
+ phy_pkg_file = '/sys/devices/system/cpu/cpu%s' %i
+ phy_pkg_file += '/topology/physical_package_id'
+ cpu_phy_id = open(phy_pkg_file).read().rstrip()
+ if not cpu_phy_id in cpu_map.keys():
+ cpu_map[cpu_phy_id] = [i]
+ else:
+ cpu_map[cpu_phy_id].append(i)
+ except IOError, e:
+ print "Mapping of CPU to pkg id failed", e
+ sys.exit(1)
+
+
+def generate_sibling_list():
+ ''' Routine to generate siblings list
+ '''
+ try:
+ for i in range(0, cpu_count):
+ siblings_file = '/sys/devices/system/cpu/cpu%s' % i
+ siblings_file += '/topology/thread_siblings_list'
+ threads_sibs = open(siblings_file).read().rstrip()
+ thread_ids = threads_sibs.split("-")
+
+ if not thread_ids in siblings_list:
+ siblings_list.append(thread_ids)
+ except Exception, details:
+ print "Exception in generate_siblings_list", details
+ sys.exit(1)
+
+def get_siblings(cpu_id):
+ ''' Return siblings of cpu_id
+ '''
+ try:
+ cpus = ""
+ for i in range(0, len(siblings_list)):
+ for cpu in siblings_list[i]:
+ if cpu_id == cpu:
+ for j in siblings_list[i]:
+ # Exclude cpu_id in the list of siblings
+ if j != cpu_id:
+ cpus += j
+ return cpus
+ return cpus
+ except Exception, details:
+ print "Exception in get_siblings", details
+ sys.exit(1)
+
+def get_proc_data(stats_list):
+ ''' Read /proc/stat info and store in dictionary
+ '''
+ try:
+ file_procstat = open("/proc/stat", 'r')
+ for line in file_procstat:
+ if line.startswith('cpu'):
+ data = line.split()
+ stats_list[data[0]] = data
+ file_procstat.close()
+ except OSError, e:
+ print "Could not read statistics", e
+ sys.exit(1)
+
+def get_proc_loc_count(loc_stats):
+ ''' Read /proc/interrupts info and store in list
+ '''
+ try:
+ file_procstat = open("/proc/interrupts", 'r')
+ for line in file_procstat:
+ if line.startswith(' LOC:') or line.startswith('LOC:'):
+ data = line.split()
+ for i in range(0, cpu_count):
+ # To skip LOC
+ loc_stats.append(data[i+1])
+ file_procstat.close()
+ return
+ except Exception, details:
+ print "Could not read interrupt statistics", details
+ sys.exit(1)
+
+
+def set_sched_mc_power(sched_mc_level):
+ ''' Routine to set sched_mc_power_savings to required level
+ '''
+ try:
+ os.system('echo %s > \
+ /sys/devices/system/cpu/sched_mc_power_savings 2>/dev/null'
+ % sched_mc_level)
+
+ get_proc_data(stats_start)
+ except OSError, e:
+ print "Could not set sched_mc_power_savings to", sched_mc_level, e
+ sys.exit(1)
+
+def set_sched_smt_power(sched_smt_level):
+ ''' Routine to set sched_smt_power_savings to required level
+ '''
+ try:
+ os.system('echo %s > \
+ /sys/devices/system/cpu/sched_smt_power_savings 2>/dev/null'
+ % sched_smt_level)
+
+ get_proc_data(stats_start)
+ except OSError, e:
+ print "Could not set sched_smt_power_savings to", sched_smt_level, e
+ sys.exit(1)
+
+def set_timer_migration_interface(value):
+ ''' Set value of timer migration interface to a value
+ passed as argument
+ '''
+ try:
+ os.system('echo %s > \
+ /proc/sys/kernel/timer_migration 2>/dev/null' % value)
+ except OSError, e:
+ print "Could not set timer_migration to ", value, e
+ sys.exit(1)
+
+def get_job_count(stress, workload, sched_smt):
+ ''' Returns number of jobs/threads to be triggered
+ '''
+
+ try:
+ if stress == "thread":
+ threads = get_hyper_thread_count()
+ if stress == "partial":
+ threads = cpu_count / socket_count
+ if is_hyper_threaded():
+ if workload == "ebizzy" and int(sched_smt) ==0:
+ threads = threads / get_hyper_thread_count()
+ if workload == "kernbench" and int(sched_smt) < 2:
+ threads = threads / get_hyper_thread_count()
+ if stress == "full":
+ threads = cpu_count
+ if stress == "single_job":
+ threads = 1
+ duration = 180
+ return threads
+ except Exception, details:
+ print "get job count failed ", details
+ sys.exit(1)
+
+def trigger_ebizzy (sched_smt, stress, duration, background, pinned):
+ ''' Triggers ebizzy workload for sched_mc=1
+ testing
+ '''
+ try:
+ threads = get_job_count(stress, "ebizzy", sched_smt)
+ workload = "ebizzy"
+ olddir = os.getcwd()
+ installdir = '%s/utils/benchmark' % os.environ['LTPROOT']
+ if os.path.exists(installdir):
+ path = '%s/utils/benchmark' % os.environ['LTPROOT']
+ os.chdir(path)
+ wklds_avlbl = list()
+ workload_dir = ""
+
+ # Use the latest version of similar workload available
+ for file_name in os.listdir('.'):
+ if file_name.find(workload) != -1:
+ wklds_avlbl.append(file_name)
+
+ wklds_avlbl.sort()
+ workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
+ if workload_dir != "":
+ new_path = os.path.join(path,"%s" % workload_dir)
+ os.chdir(new_path)
+ else:
+ print "INFO: ebizzy benchmark not found"
+ sys.exit(1)
+ else:
+ path = '%s/testcases/bin' % os.environ['LTPROOT']
+ os.chdir(path)
+ workload_file = ""
+ for file_name in os.listdir('.'):
+ if file_name == workload:
+ workload_file = file_name
+ break
+ if workload_file == "":
+ print "INFO: ebizzy benchmark not found"
+ sys.exit(1)
+ get_proc_data(stats_start)
+ get_proc_loc_count(intr_start)
+ try:
+ if background == "yes":
+ succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null &'
+ % (threads, duration))
+ else:
+ if pinned == "yes":
+ succ = os.system('taskset -c %s ./ebizzy -t%s -s4096 -S %s >/dev/null'
+ % (cpu_count -1, threads, duration))
+ else:
+ succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null'
+ % (threads, duration))
+
+ if succ == 0:
+ print "INFO: ebizzy workload triggerd"
+ os.chdir(olddir)
+ #Commented bcoz it doesnt make sense to capture it when workload triggered
+ #in background
+ #get_proc_loc_count(intr_stop)
+ #get_proc_data(stats_stop)
+ else:
+ print "INFO: ebizzy workload triggerd failed"
+ os.chdir(olddir)
+ sys.exit(1)
+ except Exception, details:
+ print "Ebizzy workload trigger failed ", details
+ sys.exit(1)
+ except Exception, details:
+ print "Ebizzy workload trigger failed ", details
+ sys.exit(1)
+
+def trigger_kernbench (sched_smt, stress, background, pinned, perf_test):
+ ''' Trigger load on system like kernbench.
+ Copys existing copy of LTP into as LTP2 and then builds it
+ with make -j
+ '''
+ olddir = os.getcwd()
+ try:
+ threads = get_job_count(stress, "kernbench", sched_smt)
+
+ dst_path = "/root"
+ workload = "kernbench"
+ olddir = os.getcwd()
+ installdir = '%s/utils/benchmark' % os.environ['LTPROOT']
+ if os.path.exists(installdir):
+ path = '%s/utils/benchmark' % os.environ['LTPROOT']
+ os.chdir(path)
+ wklds_avlbl = list()
+ workload_dir = ""
+ for file_name in os.listdir('.'):
+ if file_name.find(workload) != -1:
+ wklds_avlbl.append(file_name)
+ if len(wklds_avlbl):
+ wklds_avlbl.sort()
+ workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
+ if workload_dir != "":
+ benchmark_path = os.path.join(path,"%s" % workload_dir)
+ else:
+ print "INFO: kernbench benchmark not found"
+ sys.exit(1)
+ else:
+ path = '%s/testcases/bin' % os.environ['LTPROOT']
+ os.chdir(path)
+ workload_file = ""
+ for file_name in os.listdir('.'):
+ if file_name == workload:
+ workload_file = file_name
+ break
+ if workload_file != "":
+ benchmark_path = path
+ else:
+ print "INFO: kernbench benchmark not found"
+ sys.exit(1)
+
+ os.chdir(dst_path)
+ linux_source_dir=""
+ for file_name in os.listdir('.'):
+ if file_name.find("linux-2.6") != -1 and os.path.isdir(file_name):
+ linux_source_dir=file_name
+ break
+ if linux_source_dir != "":
+ os.chdir(linux_source_dir)
+ else:
+ print "INFO: Linux kernel source not found in /root. Workload\
+ Kernbench cannot be executed"
+ sys.exit(1)
+
+ get_proc_data(stats_start)
+ get_proc_loc_count(intr_start)
+ if pinned == "yes":
+ os.system ( 'taskset -c %s %s/kernbench -o %s -M -H -n 1 \
+ >/dev/null 2>&1 &' % (cpu_count-1, benchmark_path, threads))
+
+ # We have to delete import in future
+ import time
+ time.sleep(240)
+ stop_wkld("kernbench")
+ else:
+ if background == "yes":
+ os.system ( '%s/kernbench -o %s -M -H -n 1 >/dev/null 2>&1 &' \
+ % (benchmark_path, threads))
+ else:
+ if perf_test == "yes":
+ os.system ( '%s/kernbench -o %s -M -H -n 1 >/dev/null 2>&1' \
+ % (benchmark_path, threads))
+ else:
+ os.system ( '%s/kernbench -o %s -M -H -n 1 >/dev/null 2>&1 &' \
+ % (benchmark_path, threads))
+ # We have to delete import in future
+ import time
+ time.sleep(240)
+ stop_wkld("kernbench")
+
+ print "INFO: Workload kernbench triggerd"
+ os.chdir(olddir)
+ except Exception, details:
+ print "Workload kernbench trigger failed ", details
+ sys.exit(1)
+
+def trigger_workld(sched_smt, workload, stress, duration, background, pinned, perf_test):
+ ''' Triggers workload passed as argument. Number of threads
+ triggered is based on stress value.
+ '''
+ try:
+ if workload == "ebizzy":
+ trigger_ebizzy (sched_smt, stress, duration, background, pinned)
+ if workload == "kernbench":
+ trigger_kernbench (sched_smt, stress, background, pinned, perf_test)
+ except Exception, details:
+ print "INFO: Trigger workload failed", details
+ sys.exit(1)
+
+def generate_report():
+ ''' Generate report of CPU utilization
+ '''
+ cpu_labels = ('cpu', 'user', 'nice', 'system', 'idle', 'iowait', 'irq',
+ 'softirq', 'x', 'y')
+ if (not os.path.exists('/procstat')):
+ os.mkdir('/procstat')
+
+ get_proc_data(stats_stop)
+
+ reportfile = open('/procstat/cpu-utilisation', 'a')
+ debugfile = open('/procstat/cpu-utilisation.debug', 'a')
+ for l in stats_stop:
+ percentage_list = []
+ total = 0
+ for i in range(1, len(stats_stop[l])):
+ stats_stop[l][i] = int(stats_stop[l][i]) - int(stats_start[l][i])
+ total += stats_stop[l][i]
+ percentage_list.append(l)
+ for i in range(1, len(stats_stop[l])):
+ percentage_list.append(float(stats_stop[l][i])*100/total)
+
+ stats_percentage[l] = percentage_list
+
+ for i in range(0, len(cpu_labels)):
+ print >> debugfile, cpu_labels[i], '\t',
+ print >> debugfile
+ for l in sorted(stats_stop.keys()):
+ print >> debugfile, l, '\t',
+ for i in range(1, len(stats_stop[l])):
+ print >> debugfile, stats_stop[l][i], '\t',
+ print >> debugfile
+
+ for i in range(0, len(cpu_labels)):
+ print >> reportfile, cpu_labels[i], '\t',
+ print >> reportfile
+ for l in sorted(stats_percentage.keys()):
+ print >> reportfile, l, '\t',
+ for i in range(1, len(stats_percentage[l])):
+ print >> reportfile, " %3.4f" % stats_percentage[l][i],
+ print >> reportfile
+
+ #Now get the package ID information
+ try:
+ print >> debugfile, "cpu_map: ", cpu_map
+ keyvalfile = open('/procstat/keyval', 'a')
+ print >> keyvalfile, "nr_packages=%d" % len(cpu_map)
+ print >> keyvalfile, "system-idle=%3.4f" % (stats_percentage['cpu'][4])
+ for pkg in sorted(cpu_map.keys()):
+ if is_hyper_threaded():
+ for core in sorted(cpu_map[pkg].keys()):
+ total_idle = 0
+ total = 0
+ for cpu in cpu_map[pkg][core]:
+ total_idle += stats_stop["cpu%d" % cpu][4]
+ for i in range(1, len(stats_stop["cpu%d" % cpu])):
+ total += stats_stop["cpu%d" % cpu][i]
+ else:
+ total_idle = 0
+ total = 0
+ for cpu in cpu_map[pkg]:
+ total_idle += stats_stop["cpu%d" % cpu][4]
+ for i in range(1, len(stats_stop["cpu%d" % cpu])):
+ total += stats_stop["cpu%d" % cpu][i]
+ print >> reportfile, "Package: ", pkg, "Idle %3.4f%%" \
+ % (float(total_idle)*100/total)
+ print >> keyvalfile, "package-%s=%3.4f" % \
+ (pkg, (float(total_idle)*100/total))
+ except Exception, details:
+ print "Generating utilization report failed: ", details
+ sys.exit(1)
+
+ #Add record delimiter '\n' before closing these files
+ print >> debugfile
+ debugfile.close()
+ print >> reportfile
+ reportfile.close()
+ print >> keyvalfile
+ keyvalfile.close()
+
+def generate_loc_intr_report():
+ ''' Generate interrupt report of CPU's
+ '''
+ try:
+ if (not os.path.exists('/procstat')):
+ os.mkdir('/procstat')
+
+ get_proc_loc_count(intr_stop)
+
+ reportfile = open('/procstat/cpu-loc_interrupts', 'a')
+ print >> reportfile, "=============================================="
+ print >> reportfile, " Local timer interrupt stats "
+ print >> reportfile, "=============================================="
+
+ for i in range(0, cpu_count):
+ intr_stop[i] = int(intr_stop[i]) - int(intr_start[i])
+ print >> reportfile, "CPU%s: %s" %(i, intr_stop[i])
+ print >> reportfile
+ reportfile.close()
+ except Exception, details:
+ print "Generating interrupt report failed: ", details
+ sys.exit(1)
+
+def record_loc_intr_count():
+ ''' Record Interrupt statistics when timer_migration
+ was disabled
+ '''
+ try:
+ global intr_start, intr_stop
+ for i in range(0, cpu_count):
+ intr_stat_timer_0.append(intr_stop[i])
+ intr_start = []
+ intr_stop = []
+ except Exception, details:
+ print "INFO: Record interrupt statistics when timer_migration=0",details
+
+def expand_range(range_val):
+ '''
+ Expand the range of value into actual numbers
+ '''
+ ids_list = list()
+ try:
+ sep_comma = range_val.split(",")
+ for i in range(0, len(sep_comma)):
+ hyphen_values = sep_comma[i].split("-")
+ if len(hyphen_values) == 1:
+ ids_list.append(int(hyphen_values[0]))
+ else:
+ for j in range(int(hyphen_values[0]), int(hyphen_values[1])+1):
+ ids_list.append(j)
+ return(ids_list)
+ except Exception, details:
+ print "INFO: expand_pkg_grps failed ", details
+
+def is_quad_core():
+ '''
+ Read /proc/cpuinfo and check if system is Quad core
+ '''
+ try:
+ cpuinfo = open('/proc/cpuinfo', 'r')
+ for line in cpuinfo:
+ if line.startswith('cpu cores'):
+ cores = line.split("cpu cores")
+ num_cores = cores[1].split(":")
+ cpuinfo.close()
+ if int(num_cores[1]) == 4:
+ return(1)
+ else:
+ return(0)
+ except IOError, e:
+ print "Failed to get cpu core information", e
+ sys.exit(1)
+
+def validate_cpugrp_map(cpu_group, sched_mc_level, sched_smt_level):
+ '''
+ Verify if cpugrp belong to same package
+ '''
+ modi_cpu_grp = cpu_group[:]
+ try:
+ if is_hyper_threaded():
+ for pkg in sorted(cpu_map.keys()):
+ # if CPU utilized is across package this condition will be true
+ if len(modi_cpu_grp) != len(cpu_group):
+ break
+ for core in sorted(cpu_map[pkg].keys()):
+ core_cpus = cpu_map[pkg][core]
+ if core_cpus == modi_cpu_grp:
+ return 0
+ else:
+ #if CPUs used across the cores
+ for i in range(0, len(core_cpus)):
+ if core_cpus[i] in modi_cpu_grp:
+ modi_cpu_grp.remove(core_cpus[i])
+ if len(modi_cpu_grp) == 0:
+ return 0
+ #This code has to be deleted
+ #else:
+ # If sched_smt == 0 then its oky if threads run
+ # in different cores of same package
+ #if sched_smt_level > 0 :
+ #return 1
+ else:
+ for pkg in sorted(cpu_map.keys()):
+ pkg_cpus = cpu_map[pkg]
+ if len(cpu_group) == len(pkg_cpus):
+ if pkg_cpus == cpu_group:
+ return(0)
+ else:
+ if int(cpus_utilized[0]) in cpu_map[pkg] or int(cpus_utilized[1]) in cpu_map[pkg]:
+ return(0)
+
+ return(1)
+
+ except Exception, details:
+ print "Exception in validate_cpugrp_map: ", details
+ sys.exit(1)
+
+
+def verify_sched_domain_dmesg(sched_mc_level, sched_smt_level):
+ '''
+ Read sched domain information from dmesg.
+ '''
+ cpu_group = list()
+ try:
+ dmesg_info = os.popen('dmesg').read()
+ if dmesg_info != "":
+ lines = dmesg_info.split('\n')
+ for i in range(0, len(lines)):
+ if lines[i].endswith('CPU'):
+ groups = lines[i+1].split("groups:")
+ group_info = groups[1]
+ if group_info.find("(") != -1:
+ openindex=group_info.index("(")
+ closeindex=group_info.index(")")
+ group_info=group_info.replace\
+ (group_info[openindex:closeindex+1],"")
+
+ subgroup = group_info.split(",")
+ for j in range(0, len(subgroup)):
+ cpu_group = expand_range(subgroup[j])
+ status = validate_cpugrp_map(cpu_group, sched_mc_level,\
+ sched_smt_level)
+ if status == 1:
+ if is_quad_core() == 1:
+ if int(sched_mc_level) == 0:
+ return(0)
+ else:
+ return(1)
+ else:
+ return(1)
+ return(0)
+ else:
+ return(1)
+ except Exception, details:
+ print "Reading dmesg failed", details
+ sys.exit(1)
+
+def get_cpu_utilization(cpu):
+ ''' Return cpu utilization of cpu_id
+ '''
+ try:
+ for l in sorted(stats_percentage.keys()):
+ if cpu == stats_percentage[l][0]:
+ return stats_percentage[l][1]
+ return -1
+ except Exception, details:
+ print "Exception in get_cpu_utilization", details
+ sys.exit(1)
+
+def validate_cpu_consolidation(stress, work_ld, sched_mc_level, sched_smt_level):
+ ''' Verify if cpu's on which threads executed belong to same
+ package
+ '''
+ cpus_utilized = list()
+ threads = get_job_count(stress, work_ld, sched_smt_level)
+ try:
+ for l in sorted(stats_percentage.keys()):
+ #modify threshold
+ cpu_id = stats_percentage[l][0].split("cpu")
+ if cpu_id[1] == '':
+ continue
+ if int(cpu_id[1]) in cpus_utilized:
+ continue
+ if is_hyper_threaded():
+ if work_ld == "kernbench" and sched_smt_level < sched_mc_level:
+ siblings = get_siblings(cpu_id[1])
+ if siblings != "":
+ sib_list = siblings.split()
+ utilization = int(stats_percentage[l][1])
+ for i in range(0, len(sib_list)):
+ utilization += int(get_cpu_utilization("cpu%s" %sib_list[i]))
+ else:
+ utilization = stats_percentage[l][1]
+ if utilization > 40:
+ cpus_utilized.append(int(cpu_id[1]))
+ if siblings != "":
+ for i in range(0, len(sib_list)):
+ cpus_utilized.append(int(sib_list[i]))
+ else:
+ # This threshold wuld be modified based on results
+ if stats_percentage[l][1] > 40:
+ cpus_utilized.append(int(cpu_id[1]))
+ else:
+ if work_ld == "kernbench" :
+ if stats_percentage[l][1] > 50:
+ cpus_utilized.append(int(cpu_id[1]))
+ else:
+ if stats_percentage[l][1] > 70:
+ cpus_utilized.append(int(cpu_id[1]))
+ cpus_utilized.sort()
+ print "INFO: CPU's utilized ", cpus_utilized
+
+ # If length of CPU's utilized is not = number of jobs exit with 1
+ if len(cpus_utilized) < threads:
+ return 1
+
+ status = validate_cpugrp_map(cpus_utilized, sched_mc_level, \
+ sched_smt_level)
+ if status == 1:
+ print "INFO: CPUs utilized is not in same package or core"
+
+ return(status)
+ except Exception, details:
+ print "Exception in validate_cpu_consolidation: ", details
+ sys.exit(1)
+
+def get_cpuid_max_intr_count():
+ '''Return the cpu id's of two cpu's with highest number of intr'''
+ try:
+ highest = 0
+ second_highest = 0
+ cpus_utilized = []
+
+ #Skipping CPU0 as it is generally high
+ for i in range(1, cpu_count):
+ if int(intr_stop[i]) > int(highest):
+ if highest != 0:
+ second_highest = highest
+ cpu2_max_intr = cpu1_max_intr
+ highest = int(intr_stop[i])
+ cpu1_max_intr = i
+ else:
+ if int(intr_stop[i]) > int(second_highest):
+ second_highest = int(intr_stop[i])
+ cpu2_max_intr = i
+ cpus_utilized.append(cpu1_max_intr)
+ cpus_utilized.append(cpu2_max_intr)
+
+ for i in range(1, cpu_count):
+ if i != cpu1_max_intr and i != cpu2_max_intr:
+ diff = second_highest - intr_stop[i]
+ ''' Threshold of difference has to be manipulated '''
+ if diff < 10000:
+ print "INFO: Diff in interrupt count is below threshold"
+ cpus_utilized = []
+ return cpus_utilized
+ print "INFO: Interrupt count in other CPU's low as expected"
+ return cpus_utilized
+ except Exception, details:
+ print "Exception in get_cpuid_max_intr_count: ", details
+ sys.exit(1)
+
+def validate_ilb (sched_mc_level, sched_smt_level):
+ ''' Validate if ilb is running in same package where work load is running
+ '''
+ try:
+ cpus_utilized = get_cpuid_max_intr_count()
+ if not cpus_utilized:
+ return 1
+
+ status = validate_cpugrp_map(cpus_utilized, sched_mc_level, sched_smt_level)
+ return status
+ except Exception, details:
+ print "Exception in validate_ilb: ", details
+ sys.exit(1)
+
+def reset_schedmc():
+ ''' Routine to reset sched_mc_power_savings to Zero level
+ '''
+ try:
+ os.system('echo 0 > \
+ /sys/devices/system/cpu/sched_mc_power_savings 2>/dev/null')
+ except OSError, e:
+ print "Could not set sched_mc_power_savings to 0", e
+ sys.exit(1)
+
+def reset_schedsmt():
+ ''' Routine to reset sched_smt_power_savings to Zero level
+ '''
+ try:
+ os.system('echo 0 > \
+ /sys/devices/system/cpu/sched_smt_power_savings 2>/dev/null')
+ except OSError, e:
+ print "Could not set sched_smt_power_savings to 0", e
+ sys.exit(1)
+
+def stop_wkld(work_ld):
+ ''' Kill workload triggered in background
+ '''
+ try:
+ os.system('pkill %s 2>/dev/null' %work_ld)
+ if work_ld == "kernbench":
+ os.system('pkill make 2>/dev/null')
+ except OSError, e:
+ print "Exception in stop_wkld", e
+ sys.exit(1)
diff --git a/testcases/kernel/power_management/lib/sched_mc.py b/testcases/kernel/power_management/lib/sched_mc.py
deleted file mode 100755
index 24285eb..0000000
--- a/testcases/kernel/power_management/lib/sched_mc.py
+++ /dev/null
@@ -1,872 +0,0 @@
-#!/usr/bin/python
-''' Reusable functions related to sched mc FVT are put together
-'''
-
-import os
-import sys
-import re
-from time import time
-
-__author__ = "Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>"
-__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
-
-
-cpu_map = {}
-stats_start = {}
-stats_stop = {}
-stats_percentage = {}
-intr_start = []
-intr_stop = []
-cpu_count = 0
-socket_count = 0
-cpu1_max_intr = 0
-cpu2_max_intr = 0
-intr_stat_timer_0 = []
-siblings_list = []
-
-def clear_dmesg():
- '''
- Clears dmesg
- '''
- try:
- os.system('dmesg -c >/dev/null')
- except OSError, e:
- print 'Clearing dmesg failed', e
- sys.exit(1)
-
-def count_num_cpu():
- ''' Returns number of cpu's in system
- '''
- try:
- cpuinfo = open('/proc/cpuinfo', 'r')
- global cpu_count
- for line in cpuinfo:
- if line.startswith('processor'):
- cpu_count += 1
- cpuinfo.close()
- except IOError, e:
- print "Could not get cpu count", e
- sys.exit(1)
-
-def count_num_sockets():
- ''' Returns number of cpu's in system
- '''
- socket_list = []
- global socket_count
- try:
- for i in range(0, cpu_count):
- phy_pkg_file = '/sys/devices/system/cpu/cpu%s' % i
- phy_pkg_file += '/topology/physical_package_id'
- socket_id = open(phy_pkg_file).read().rstrip()
- if socket_id not in socket_list:
- socket_list.append(socket_id)
- socket_count = socket_count + 1
- except Exception, details:
- print "INFO: Failed to get number of sockets in system", details
- sys.exit(1)
-
-def is_multi_socket():
- '''Return 1 if the system is multi socket else return 0
- '''
- try:
- if socket_count > 1:
- return 1
- else:
- return 0
- except Exception:
- print "Failed to check if system is multi socket system"
- sys.exit(1)
-
-def is_hyper_threaded():
- '''Return 1 if the system is hyper threaded else return 0
- '''
- try:
- file_cpuinfo = open("/proc/cpuinfo", 'r')
- for line in file_cpuinfo:
- if line.startswith('siblings'):
- siblings = line.split(":")
- if line.startswith('cpu cores'):
- cpu_cores = line.split(":")
- break
- if int( siblings[1] ) / int( cpu_cores[1] )> 1:
- file_cpuinfo.close()
- return 1
- else:
- return 0
- except Exception:
- print "Failed to check if system is hyper-threaded"
- sys.exit(1)
-
-def is_multi_core():
- ''' Return true if system has sockets has multiple cores
- '''
-
- try:
- file_cpuinfo = open("/proc/cpuinfo", 'r')
- for line in file_cpuinfo:
- if line.startswith('siblings'):
- siblings = line.split(":")
- if line.startswith('cpu cores'):
- cpu_cores = line.split(":")
- break
-
- if int( siblings[1] ) == int( cpu_cores[1] ):
- if int( cpu_cores[1] ) > 1:
- multi_core = 1
- else:
- multi_core = 0
- else:
- num_of_cpus = int(siblings[1]) / int(cpu_cores[1])
- if num_of_cpus > 1:
- multi_core = 1
- else:
- multi_core = 0
- file_cpuinfo.close()
- return multi_core
- except Exception:
- print "Failed to check if system is multi core system"
- sys.exit(1)
-
-def get_hyper_thread_count():
- ''' Return number of threads in CPU. For eg for x3950 this function
- would return 2. In future if 4 threads are supported in CPU, this
- routine would return 4
- '''
- try:
- file_cpuinfo = open("/proc/cpuinfo", 'r')
- for line in file_cpuinfo:
- if line.startswith('siblings'):
- siblings = line.split(":")
- if line.startswith('cpu cores'):
- cpu_cores = line.split(":")
- break
- return( int( siblings[1] ) / int( cpu_cores[1] ) )
- except Exception:
- print "Failed to check if system is hyper-threaded"
- sys.exit(1)
-
-def map_cpuid_pkgid():
- ''' Routine to map physical package id to cpu id
- '''
- if is_hyper_threaded():
- core_info = {}
- try:
- for i in range(0, cpu_count):
- phy_pkg_file = '/sys/devices/system/cpu/cpu%s' % i
- phy_pkg_file += '/topology/physical_package_id'
- core_file = '/sys/devices/system/cpu/cpu%s' % i
- core_file += '/topology/core_id'
- core_id = open(core_file).read().rstrip()
- cpu_phy_id = open(phy_pkg_file).read().rstrip()
- if not cpu_phy_id in cpu_map.keys():
- core_info = {}
- else:
- core_info = cpu_map[cpu_phy_id]
- if not core_id in core_info.keys():
- core_info[core_id] = [i]
- else:
- core_info[core_id].append(i)
- cpu_map[cpu_phy_id] = core_info
- except Exception, details:
- print "Package, core & cpu map table creation failed", e
- sys.exit(1)
- else:
- for i in range(0, cpu_count):
- try:
- phy_pkg_file = '/sys/devices/system/cpu/cpu%s' %i
- phy_pkg_file += '/topology/physical_package_id'
- cpu_phy_id = open(phy_pkg_file).read().rstrip()
- if not cpu_phy_id in cpu_map.keys():
- cpu_map[cpu_phy_id] = [i]
- else:
- cpu_map[cpu_phy_id].append(i)
- except IOError, e:
- print "Mapping of CPU to pkg id failed", e
- sys.exit(1)
-
-
-def generate_sibling_list():
- ''' Routine to generate siblings list
- '''
- try:
- for i in range(0, cpu_count):
- siblings_file = '/sys/devices/system/cpu/cpu%s' % i
- siblings_file += '/topology/thread_siblings_list'
- threads_sibs = open(siblings_file).read().rstrip()
- thread_ids = threads_sibs.split("-")
-
- if not thread_ids in siblings_list:
- siblings_list.append(thread_ids)
- except Exception, details:
- print "Exception in generate_siblings_list", details
- sys.exit(1)
-
-def get_siblings(cpu_id):
- ''' Return siblings of cpu_id
- '''
- try:
- cpus = ""
- for i in range(0, len(siblings_list)):
- for cpu in siblings_list[i]:
- if cpu_id == cpu:
- for j in siblings_list[i]:
- # Exclude cpu_id in the list of siblings
- if j != cpu_id:
- cpus += j
- return cpus
- return cpus
- except Exception, details:
- print "Exception in get_siblings", details
- sys.exit(1)
-
-def get_proc_data(stats_list):
- ''' Read /proc/stat info and store in dictionary
- '''
- try:
- file_procstat = open("/proc/stat", 'r')
- for line in file_procstat:
- if line.startswith('cpu'):
- data = line.split()
- stats_list[data[0]] = data
- file_procstat.close()
- except OSError, e:
- print "Could not read statistics", e
- sys.exit(1)
-
-def get_proc_loc_count(loc_stats):
- ''' Read /proc/interrupts info and store in list
- '''
- try:
- file_procstat = open("/proc/interrupts", 'r')
- for line in file_procstat:
- if line.startswith(' LOC:') or line.startswith('LOC:'):
- data = line.split()
- for i in range(0, cpu_count):
- # To skip LOC
- loc_stats.append(data[i+1])
- file_procstat.close()
- return
- except Exception, details:
- print "Could not read interrupt statistics", details
- sys.exit(1)
-
-
-def set_sched_mc_power(sched_mc_level):
- ''' Routine to set sched_mc_power_savings to required level
- '''
- try:
- os.system('echo %s > \
- /sys/devices/system/cpu/sched_mc_power_savings 2>/dev/null'
- % sched_mc_level)
-
- get_proc_data(stats_start)
- except OSError, e:
- print "Could not set sched_mc_power_savings to", sched_mc_level, e
- sys.exit(1)
-
-def set_sched_smt_power(sched_smt_level):
- ''' Routine to set sched_smt_power_savings to required level
- '''
- try:
- os.system('echo %s > \
- /sys/devices/system/cpu/sched_smt_power_savings 2>/dev/null'
- % sched_smt_level)
-
- get_proc_data(stats_start)
- except OSError, e:
- print "Could not set sched_smt_power_savings to", sched_smt_level, e
- sys.exit(1)
-
-def set_timer_migration_interface(value):
- ''' Set value of timer migration interface to a value
- passed as argument
- '''
- try:
- os.system('echo %s > \
- /proc/sys/kernel/timer_migration 2>/dev/null' % value)
- except OSError, e:
- print "Could not set timer_migration to ", value, e
- sys.exit(1)
-
-def get_job_count(stress, workload, sched_smt):
- ''' Returns number of jobs/threads to be triggered
- '''
-
- try:
- if stress == "thread":
- threads = get_hyper_thread_count()
- if stress == "partial":
- threads = cpu_count / socket_count
- if is_hyper_threaded():
- if workload == "ebizzy" and int(sched_smt) ==0:
- threads = threads / get_hyper_thread_count()
- if workload == "kernbench" and int(sched_smt) < 2:
- threads = threads / get_hyper_thread_count()
- if stress == "full":
- threads = cpu_count
- if stress == "single_job":
- threads = 1
- duration = 180
- return threads
- except Exception, details:
- print "get job count failed ", details
- sys.exit(1)
-
-def trigger_ebizzy (sched_smt, stress, duration, background, pinned):
- ''' Triggers ebizzy workload for sched_mc=1
- testing
- '''
- try:
- threads = get_job_count(stress, "ebizzy", sched_smt)
- workload = "ebizzy"
- olddir = os.getcwd()
- installdir = '%s/utils/benchmark' % os.environ['LTPROOT']
- if os.path.exists(installdir):
- path = '%s/utils/benchmark' % os.environ['LTPROOT']
- os.chdir(path)
- wklds_avlbl = list()
- workload_dir = ""
-
- # Use the latest version of similar workload available
- for file_name in os.listdir('.'):
- if file_name.find(workload) != -1:
- wklds_avlbl.append(file_name)
-
- wklds_avlbl.sort()
- workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
- if workload_dir != "":
- new_path = os.path.join(path,"%s" % workload_dir)
- os.chdir(new_path)
- else:
- print "INFO: ebizzy benchmark not found"
- sys.exit(1)
- else:
- path = '%s/testcases/bin' % os.environ['LTPROOT']
- os.chdir(path)
- workload_file = ""
- for file_name in os.listdir('.'):
- if file_name == workload:
- workload_file = file_name
- break
- if workload_file == "":
- print "INFO: ebizzy benchmark not found"
- sys.exit(1)
- get_proc_data(stats_start)
- get_proc_loc_count(intr_start)
- try:
- if background == "yes":
- succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null &'
- % (threads, duration))
- else:
- if pinned == "yes":
- succ = os.system('taskset -c %s ./ebizzy -t%s -s4096 -S %s >/dev/null'
- % (cpu_count -1, threads, duration))
- else:
- succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null'
- % (threads, duration))
-
- if succ == 0:
- print "INFO: ebizzy workload triggerd"
- os.chdir(olddir)
- #Commented bcoz it doesnt make sense to capture it when workload triggered
- #in background
- #get_proc_loc_count(intr_stop)
- #get_proc_data(stats_stop)
- else:
- print "INFO: ebizzy workload triggerd failed"
- os.chdir(olddir)
- sys.exit(1)
- except Exception, details:
- print "Ebizzy workload trigger failed ", details
- sys.exit(1)
- except Exception, details:
- print "Ebizzy workload trigger failed ", details
- sys.exit(1)
-
-def trigger_kernbench (sched_smt, stress, background, pinned, perf_test):
- ''' Trigger load on system like kernbench.
- Copys existing copy of LTP into as LTP2 and then builds it
- with make -j
- '''
- olddir = os.getcwd()
- try:
- threads = get_job_count(stress, "kernbench", sched_smt)
-
- dst_path = "/root"
- workload = "kernbench"
- olddir = os.getcwd()
- installdir = '%s/utils/benchmark' % os.environ['LTPROOT']
- if os.path.exists(installdir):
- path = '%s/utils/benchmark' % os.environ['LTPROOT']
- os.chdir(path)
- wklds_avlbl = list()
- workload_dir = ""
- for file_name in os.listdir('.'):
- if file_name.find(workload) != -1:
- wklds_avlbl.append(file_name)
- if len(wklds_avlbl):
- wklds_avlbl.sort()
- workload_dir = wklds_avlbl[len(wklds_avlbl)-1]
- if workload_dir != "":
- benchmark_path = os.path.join(path,"%s" % workload_dir)
- else:
- print "INFO: kernbench benchmark not found"
- sys.exit(1)
- else:
- path = '%s/testcases/bin' % os.environ['LTPROOT']
- os.chdir(path)
- workload_file = ""
- for file_name in os.listdir('.'):
- if file_name == workload:
- workload_file = file_name
- break
- if workload_file != "":
- benchmark_path = path
- else:
- print "INFO: kernbench benchmark not found"
- sys.exit(1)
-
- os.chdir(dst_path)
- linux_source_dir=""
- for file_name in os.listdir('.'):
- if file_name.find("linux-2.6") != -1 and os.path.isdir(file_name):
- linux_source_dir=file_name
- break
- if linux_source_dir != "":
- os.chdir(linux_source_dir)
- else:
- print "INFO: Linux kernel source not found in /root. Workload\
- Kernbench cannot be executed"
- sys.exit(1)
-
- get_proc_data(stats_start)
- get_proc_loc_count(intr_start)
- if pinned == "yes":
- os.system ( 'taskset -c %s %s/kernbench -o %s -M -H -n 1 \
- >/dev/null 2>&1 &' % (cpu_count-1, benchmark_path, threads))
-
- # We have to delete import in future
- import time
- time.sleep(240)
- stop_wkld("kernbench")
- else:
- if background == "yes":
- os.system ( '%s/kernbench -o %s -M -H -n 1 >/dev/null 2>&1 &' \
- % (benchmark_path, threads))
- else:
- if perf_test == "yes":
- os.system ( '%s/kernbench -o %s -M -H -n 1 >/dev/null 2>&1' \
- % (benchmark_path, threads))
- else:
- os.system ( '%s/kernbench -o %s -M -H -n 1 >/dev/null 2>&1 &' \
- % (benchmark_path, threads))
- # We have to delete import in future
- import time
- time.sleep(240)
- stop_wkld("kernbench")
-
- print "INFO: Workload kernbench triggerd"
- os.chdir(olddir)
- except Exception, details:
- print "Workload kernbench trigger failed ", details
- sys.exit(1)
-
-def trigger_workld(sched_smt, workload, stress, duration, background, pinned, perf_test):
- ''' Triggers workload passed as argument. Number of threads
- triggered is based on stress value.
- '''
- try:
- if workload == "ebizzy":
- trigger_ebizzy (sched_smt, stress, duration, background, pinned)
- if workload == "kernbench":
- trigger_kernbench (sched_smt, stress, background, pinned, perf_test)
- except Exception, details:
- print "INFO: Trigger workload failed", details
- sys.exit(1)
-
-def generate_report():
- ''' Generate report of CPU utilization
- '''
- cpu_labels = ('cpu', 'user', 'nice', 'system', 'idle', 'iowait', 'irq',
- 'softirq', 'x', 'y')
- if (not os.path.exists('/procstat')):
- os.mkdir('/procstat')
-
- get_proc_data(stats_stop)
-
- reportfile = open('/procstat/cpu-utilisation', 'a')
- debugfile = open('/procstat/cpu-utilisation.debug', 'a')
- for l in stats_stop:
- percentage_list = []
- total = 0
- for i in range(1, len(stats_stop[l])):
- stats_stop[l][i] = int(stats_stop[l][i]) - int(stats_start[l][i])
- total += stats_stop[l][i]
- percentage_list.append(l)
- for i in range(1, len(stats_stop[l])):
- percentage_list.append(float(stats_stop[l][i])*100/total)
-
- stats_percentage[l] = percentage_list
-
- for i in range(0, len(cpu_labels)):
- print >> debugfile, cpu_labels[i], '\t',
- print >> debugfile
- for l in sorted(stats_stop.keys()):
- print >> debugfile, l, '\t',
- for i in range(1, len(stats_stop[l])):
- print >> debugfile, stats_stop[l][i], '\t',
- print >> debugfile
-
- for i in range(0, len(cpu_labels)):
- print >> reportfile, cpu_labels[i], '\t',
- print >> reportfile
- for l in sorted(stats_percentage.keys()):
- print >> reportfile, l, '\t',
- for i in range(1, len(stats_percentage[l])):
- print >> reportfile, " %3.4f" % stats_percentage[l][i],
- print >> reportfile
-
- #Now get the package ID information
- try:
- print >> debugfile, "cpu_map: ", cpu_map
- keyvalfile = open('/procstat/keyval', 'a')
- print >> keyvalfile, "nr_packages=%d" % len(cpu_map)
- print >> keyvalfile, "system-idle=%3.4f" % (stats_percentage['cpu'][4])
- for pkg in sorted(cpu_map.keys()):
- if is_hyper_threaded():
- for core in sorted(cpu_map[pkg].keys()):
- total_idle = 0
- total = 0
- for cpu in cpu_map[pkg][core]:
- total_idle += stats_stop["cpu%d" % cpu][4]
- for i in range(1, len(stats_stop["cpu%d" % cpu])):
- total += stats_stop["cpu%d" % cpu][i]
- else:
- total_idle = 0
- total = 0
- for cpu in cpu_map[pkg]:
- total_idle += stats_stop["cpu%d" % cpu][4]
- for i in range(1, len(stats_stop["cpu%d" % cpu])):
- total += stats_stop["cpu%d" % cpu][i]
- print >> reportfile, "Package: ", pkg, "Idle %3.4f%%" \
- % (float(total_idle)*100/total)
- print >> keyvalfile, "package-%s=%3.4f" % \
- (pkg, (float(total_idle)*100/total))
- except Exception, details:
- print "Generating utilization report failed: ", details
- sys.exit(1)
-
- #Add record delimiter '\n' before closing these files
- print >> debugfile
- debugfile.close()
- print >> reportfile
- reportfile.close()
- print >> keyvalfile
- keyvalfile.close()
-
-def generate_loc_intr_report():
- ''' Generate interrupt report of CPU's
- '''
- try:
- if (not os.path.exists('/procstat')):
- os.mkdir('/procstat')
-
- get_proc_loc_count(intr_stop)
-
- reportfile = open('/procstat/cpu-loc_interrupts', 'a')
- print >> reportfile, "=============================================="
- print >> reportfile, " Local timer interrupt stats "
- print >> reportfile, "=============================================="
-
- for i in range(0, cpu_count):
- intr_stop[i] = int(intr_stop[i]) - int(intr_start[i])
- print >> reportfile, "CPU%s: %s" %(i, intr_stop[i])
- print >> reportfile
- reportfile.close()
- except Exception, details:
- print "Generating interrupt report failed: ", details
- sys.exit(1)
-
-def record_loc_intr_count():
- ''' Record Interrupt statistics when timer_migration
- was disabled
- '''
- try:
- global intr_start, intr_stop
- for i in range(0, cpu_count):
- intr_stat_timer_0.append(intr_stop[i])
- intr_start = []
- intr_stop = []
- except Exception, details:
- print "INFO: Record interrupt statistics when timer_migration=0",details
-
-def expand_range(range_val):
- '''
- Expand the range of value into actual numbers
- '''
- ids_list = list()
- try:
- sep_comma = range_val.split(",")
- for i in range(0, len(sep_comma)):
- hyphen_values = sep_comma[i].split("-")
- if len(hyphen_values) == 1:
- ids_list.append(int(hyphen_values[0]))
- else:
- for j in range(int(hyphen_values[0]), int(hyphen_values[1])+1):
- ids_list.append(j)
- return(ids_list)
- except Exception, details:
- print "INFO: expand_pkg_grps failed ", details
-
-def is_quad_core():
- '''
- Read /proc/cpuinfo and check if system is Quad core
- '''
- try:
- cpuinfo = open('/proc/cpuinfo', 'r')
- for line in cpuinfo:
- if line.startswith('cpu cores'):
- cores = line.split("cpu cores")
- num_cores = cores[1].split(":")
- cpuinfo.close()
- if int(num_cores[1]) == 4:
- return(1)
- else:
- return(0)
- except IOError, e:
- print "Failed to get cpu core information", e
- sys.exit(1)
-
-def validate_cpugrp_map(cpu_group, sched_mc_level, sched_smt_level):
- '''
- Verify if cpugrp belong to same package
- '''
- modi_cpu_grp = cpu_group[:]
- try:
- if is_hyper_threaded():
- for pkg in sorted(cpu_map.keys()):
- # if CPU utilized is across package this condition will be true
- if len(modi_cpu_grp) != len(cpu_group):
- break
- for core in sorted(cpu_map[pkg].keys()):
- core_cpus = cpu_map[pkg][core]
- if core_cpus == modi_cpu_grp:
- return 0
- else:
- #if CPUs used across the cores
- for i in range(0, len(core_cpus)):
- if core_cpus[i] in modi_cpu_grp:
- modi_cpu_grp.remove(core_cpus[i])
- if len(modi_cpu_grp) == 0:
- return 0
- #This code has to be deleted
- #else:
- # If sched_smt == 0 then its oky if threads run
- # in different cores of same package
- #if sched_smt_level > 0 :
- #return 1
- else:
- for pkg in sorted(cpu_map.keys()):
- pkg_cpus = cpu_map[pkg]
- if len(cpu_group) == len(pkg_cpus):
- if pkg_cpus == cpu_group:
- return(0)
- else:
- if int(cpus_utilized[0]) in cpu_map[pkg] or int(cpus_utilized[1]) in cpu_map[pkg]:
- return(0)
-
- return(1)
-
- except Exception, details:
- print "Exception in validate_cpugrp_map: ", details
- sys.exit(1)
-
-
-def verify_sched_domain_dmesg(sched_mc_level, sched_smt_level):
- '''
- Read sched domain information from dmesg.
- '''
- cpu_group = list()
- try:
- dmesg_info = os.popen('dmesg').read()
- if dmesg_info != "":
- lines = dmesg_info.split('\n')
- for i in range(0, len(lines)):
- if lines[i].endswith('CPU'):
- groups = lines[i+1].split("groups:")
- group_info = groups[1]
- if group_info.find("(") != -1:
- openindex=group_info.index("(")
- closeindex=group_info.index(")")
- group_info=group_info.replace\
- (group_info[openindex:closeindex+1],"")
-
- subgroup = group_info.split(",")
- for j in range(0, len(subgroup)):
- cpu_group = expand_range(subgroup[j])
- status = validate_cpugrp_map(cpu_group, sched_mc_level,\
- sched_smt_level)
- if status == 1:
- if is_quad_core() == 1:
- if int(sched_mc_level) == 0:
- return(0)
- else:
- return(1)
- else:
- return(1)
- return(0)
- else:
- return(1)
- except Exception, details:
- print "Reading dmesg failed", details
- sys.exit(1)
-
-def get_cpu_utilization(cpu):
- ''' Return cpu utilization of cpu_id
- '''
- try:
- for l in sorted(stats_percentage.keys()):
- if cpu == stats_percentage[l][0]:
- return stats_percentage[l][1]
- return -1
- except Exception, details:
- print "Exception in get_cpu_utilization", details
- sys.exit(1)
-
-def validate_cpu_consolidation(stress, work_ld, sched_mc_level, sched_smt_level):
- ''' Verify if cpu's on which threads executed belong to same
- package
- '''
- cpus_utilized = list()
- threads = get_job_count(stress, work_ld, sched_smt_level)
- try:
- for l in sorted(stats_percentage.keys()):
- #modify threshold
- cpu_id = stats_percentage[l][0].split("cpu")
- if cpu_id[1] == '':
- continue
- if int(cpu_id[1]) in cpus_utilized:
- continue
- if is_hyper_threaded():
- if work_ld == "kernbench" and sched_smt_level < sched_mc_level:
- siblings = get_siblings(cpu_id[1])
- if siblings != "":
- sib_list = siblings.split()
- utilization = int(stats_percentage[l][1])
- for i in range(0, len(sib_list)):
- utilization += int(get_cpu_utilization("cpu%s" %sib_list[i]))
- else:
- utilization = stats_percentage[l][1]
- if utilization > 40:
- cpus_utilized.append(int(cpu_id[1]))
- if siblings != "":
- for i in range(0, len(sib_list)):
- cpus_utilized.append(int(sib_list[i]))
- else:
- # This threshold wuld be modified based on results
- if stats_percentage[l][1] > 40:
- cpus_utilized.append(int(cpu_id[1]))
- else:
- if work_ld == "kernbench" :
- if stats_percentage[l][1] > 50:
- cpus_utilized.append(int(cpu_id[1]))
- else:
- if stats_percentage[l][1] > 70:
- cpus_utilized.append(int(cpu_id[1]))
- cpus_utilized.sort()
- print "INFO: CPU's utilized ", cpus_utilized
-
- # If length of CPU's utilized is not = number of jobs exit with 1
- if len(cpus_utilized) < threads:
- return 1
-
- status = validate_cpugrp_map(cpus_utilized, sched_mc_level, \
- sched_smt_level)
- if status == 1:
- print "INFO: CPUs utilized is not in same package or core"
-
- return(status)
- except Exception, details:
- print "Exception in validate_cpu_consolidation: ", details
- sys.exit(1)
-
-def get_cpuid_max_intr_count():
- '''Return the cpu id's of two cpu's with highest number of intr'''
- try:
- highest = 0
- second_highest = 0
- cpus_utilized = []
-
- #Skipping CPU0 as it is generally high
- for i in range(1, cpu_count):
- if int(intr_stop[i]) > int(highest):
- if highest != 0:
- second_highest = highest
- cpu2_max_intr = cpu1_max_intr
- highest = int(intr_stop[i])
- cpu1_max_intr = i
- else:
- if int(intr_stop[i]) > int(second_highest):
- second_highest = int(intr_stop[i])
- cpu2_max_intr = i
- cpus_utilized.append(cpu1_max_intr)
- cpus_utilized.append(cpu2_max_intr)
-
- for i in range(1, cpu_count):
- if i != cpu1_max_intr and i != cpu2_max_intr:
- diff = second_highest - intr_stop[i]
- ''' Threshold of difference has to be manipulated '''
- if diff < 10000:
- print "INFO: Diff in interrupt count is below threshold"
- cpus_utilized = []
- return cpus_utilized
- print "INFO: Interrupt count in other CPU's low as expected"
- return cpus_utilized
- except Exception, details:
- print "Exception in get_cpuid_max_intr_count: ", details
- sys.exit(1)
-
-def validate_ilb (sched_mc_level, sched_smt_level):
- ''' Validate if ilb is running in same package where work load is running
- '''
- try:
- cpus_utilized = get_cpuid_max_intr_count()
- if not cpus_utilized:
- return 1
-
- status = validate_cpugrp_map(cpus_utilized, sched_mc_level, sched_smt_level)
- return status
- except Exception, details:
- print "Exception in validate_ilb: ", details
- sys.exit(1)
-
-def reset_schedmc():
- ''' Routine to reset sched_mc_power_savings to Zero level
- '''
- try:
- os.system('echo 0 > \
- /sys/devices/system/cpu/sched_mc_power_savings 2>/dev/null')
- except OSError, e:
- print "Could not set sched_mc_power_savings to 0", e
- sys.exit(1)
-
-def reset_schedsmt():
- ''' Routine to reset sched_smt_power_savings to Zero level
- '''
- try:
- os.system('echo 0 > \
- /sys/devices/system/cpu/sched_smt_power_savings 2>/dev/null')
- except OSError, e:
- print "Could not set sched_smt_power_savings to 0", e
- sys.exit(1)
-
-def stop_wkld(work_ld):
- ''' Kill workload triggered in background
- '''
- try:
- os.system('pkill %s 2>/dev/null' %work_ld)
- if work_ld == "kernbench":
- os.system('pkill make 2>/dev/null')
- except OSError, e:
- print "Exception in stop_wkld", e
- sys.exit(1)
diff --git a/testcases/kernel/power_management/pm_cpu_consolidation.py b/testcases/kernel/power_management/pm_cpu_consolidation.py
new file mode 100755
index 0000000..5aa3948
--- /dev/null
+++ b/testcases/kernel/power_management/pm_cpu_consolidation.py
@@ -0,0 +1,145 @@
+#!/usr/bin/python
+''' This Python script interprets various sched stats values.
+ Validates cpu consolidation for given sched_mc_power_saving value
+'''
+
+import os
+import sys
+import time
+LIB_DIR = "%s/lib" % os.path.dirname(__file__)
+sys.path.append(LIB_DIR)
+from optparse import OptionParser
+from pm_sched_mc import *
+
+__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
+
+class Usage(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ usage = "-w"
+ parser = OptionParser(usage)
+ parser.add_option("-v", "--variation_test", dest="vary_mc_smt",
+ default=False, action="store_true", help="Vary sched_mc & sched_smt. \
+ -c and -t inputs are initial value of sched_mc & sched_smt")
+ parser.add_option("-c", "--mc_value", dest="mc_value",
+ default=0, help="Sched mc power saving value 0/1/2")
+ parser.add_option("-t", "--smt_value", dest="smt_value",
+ default=0, help="Sched smt power saving value 0/1/2")
+ parser.add_option("-w", "--workload", dest="work_ld",
+ default="ebizzy", help="Workload can be ebizzy/kernbench")
+ parser.add_option("-s", "--stress", dest="stress",
+ default="partial", help="Load on system is full/partial [i.e 50%]/thread")
+ parser.add_option("-p", "--performance", dest="perf_test",
+ default=False, action="store_true", help="Enable performance test")
+ (options, args) = parser.parse_args()
+
+ try:
+ count_num_cpu()
+ count_num_sockets()
+ if is_hyper_threaded():
+ generate_sibling_list()
+
+ # User should set option -v to test cpu consolidation
+ # resets when sched_mc &(/) sched_smt is disabled when
+ # workload is already running in the system
+
+ if options.vary_mc_smt:
+
+ # Since same code is used for testing package consolidation and core
+ # consolidation is_multi_socket & is_hyper_threaded check is done
+ if is_multi_socket() and is_multi_core() and options.mc_value:
+ set_sched_mc_power(options.mc_value)
+
+ if is_hyper_threaded() and options.smt_value:
+ set_sched_smt_power(options.smt_value)
+
+ #Generate arguments for trigger workload, run workload in background
+ map_cpuid_pkgid()
+ background="yes"
+ duration=360
+ pinned="no"
+ if int(options.mc_value) < 2 and int(options.smt_value) < 2:
+ trigger_ebizzy (options.smt_value, "partial", duration, background, pinned)
+ work_ld="ebizzy"
+ #Wait for 120 seconds and then validate cpu consolidation works
+ #When sched_mc & sched_smt is set
+ import time
+ time.sleep(120)
+ else:
+ #Wait for 120 seconds and then validate cpu consolidation works
+ #When sched_mc & sched_smt is set
+ trigger_kernbench (options.smt_value, "partial", background, pinned, "no")
+ work_ld="kernbench"
+ import time
+ time.sleep(300)
+
+ generate_report()
+ status = validate_cpu_consolidation("partial", work_ld, options.mc_value, options.smt_value)
+ if status == 0:
+ print "INFO: Consolidation worked sched_smt &(/) sched_mc is set"
+ #Disable sched_smt & sched_mc interface values
+ if options.vary_mc_smt and options.mc_value > 0:
+ set_sched_mc_power(0)
+ mc_value = options.mc_value
+ else:
+ mc_value = 0
+ if options.vary_mc_smt and options.smt_value > 0 and is_hyper_threaded():
+ set_sched_smt_power(0)
+ smt_value = options.smt_value
+ else:
+ smt_value = 0
+
+ if work_ld == "kernbench":
+ time.sleep(240)
+ else:
+ time.sleep(120)
+
+ generate_report()
+ status = validate_cpu_consolidation("partial", work_ld, mc_value, smt_value)
+ if background == "yes":
+ stop_wkld(work_ld)
+ #CPU consolidation should fail as sched_mc &(/) sched_smt is disabled
+ if status == 1:
+ return(0)
+ else:
+ return(1)
+ else:
+ print "INFO: CPU consolidation failed when sched_mc &(/) \
+sched_smt was enabled. This is pre-requisite to proceed"
+ return(status)
+ else:
+ #The else part of the code validates behaviour of sched_mc
+ # and sched_smt set to 0, 1 & 2
+ if is_multi_socket():
+ set_sched_mc_power(options.mc_value)
+ if is_hyper_threaded():
+ set_sched_smt_power(options.smt_value)
+ map_cpuid_pkgid()
+ print "INFO: Created table mapping cpu to package"
+ background="no"
+ duration=60
+ pinned ="no"
+
+ if options.perf_test:
+ perf_test="yes"
+ else:
+ perf_test="no"
+
+ trigger_workld( options.smt_value, options.work_ld, options.stress, duration, background, pinned, perf_test)
+ generate_report()
+ status = validate_cpu_consolidation(options.stress, options.work_ld,options.mc_value, options.smt_value)
+ reset_schedmc()
+ if is_hyper_threaded():
+ reset_schedsmt()
+ return(status)
+ except Exception, details:
+ print "INFO: CPU consolidation failed", details
+ return(1)
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/testcases/kernel/power_management/pm_get_sched_values.c b/testcases/kernel/power_management/pm_get_sched_values.c
new file mode 100644
index 0000000..5409971
--- /dev/null
+++ b/testcases/kernel/power_management/pm_get_sched_values.c
@@ -0,0 +1,50 @@
+/************************************************************************
+* Copyright (c) International Business Machines Corp., 2008
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+* the GNU General Public License for more details.
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+***************************************************************************/
+#include <stdio.h>
+#include "test.h"
+
+const char *TCID = "pm_get_sched_values";
+
+int get_supp_sched_mc(void)
+{
+ if (tst_kvercmp(2, 6, 29) < 0)
+ return 1;
+ else
+ return 2;
+}
+
+int get_supp_sched_smt(void)
+{
+ if (tst_kvercmp(2, 6, 29) < 0)
+ return 1;
+ else
+ return 2;
+}
+
+int main(int argc, char **argv)
+{
+ char *param;
+ if (argc == 0)
+ return 1;
+ else {
+ param = argv[1];
+ if (strcmp(param, "sched_mc") == 0)
+ return get_supp_sched_mc();
+ if (strcmp(param, "sched_smt") == 0)
+ return get_supp_sched_smt();
+ }
+}
diff --git a/testcases/kernel/power_management/pm_ilb_test.py b/testcases/kernel/power_management/pm_ilb_test.py
new file mode 100755
index 0000000..3f6ad46
--- /dev/null
+++ b/testcases/kernel/power_management/pm_ilb_test.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+''' This Python script interprets interrupt values.
+ Validates Ideal load balancer runs in same package where workload is running
+'''
+
+import os
+import sys
+LIB_DIR = "%s/lib" % os.path.dirname(__file__)
+sys.path.append(LIB_DIR)
+from optparse import OptionParser
+from pm_sched_mc import *
+
+__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
+
+class Usage(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ usage = "-w"
+ parser = OptionParser(usage)
+ parser.add_option("-c", "--mc_level", dest="mc_level",
+ default=0, help="Sched mc power saving value 0/1/2")
+ parser.add_option("-t", "--smt_level", dest="smt_level",
+ default=0, help="Sched smt power saving value 0/1/2")
+ parser.add_option("-w", "--workload", dest="work_ld",
+ default="ebizzy", help="Workload can be ebizzy/kernbench")
+ (options, args) = parser.parse_args()
+
+ try:
+ count_num_cpu()
+ count_num_sockets()
+ if is_multi_socket():
+ set_sched_mc_power(options.mc_level)
+ if is_hyper_threaded():
+ set_sched_smt_power(options.smt_level)
+ map_cpuid_pkgid()
+ print "INFO: Created table mapping cpu to package"
+ background="no"
+ duration=120
+ pinned="yes"
+
+ trigger_workld(options.smt_level,options.work_ld, "single_job", duration, background, pinned, "no")
+ generate_loc_intr_report()
+ status = validate_ilb(options.mc_level, options.smt_level)
+ reset_schedmc()
+ if is_hyper_threaded():
+ reset_schedsmt()
+ return(status)
+
+ except Exception, details:
+ print "INFO: Idle Load Balancer test failed", details
+ return(1)
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/testcases/kernel/power_management/pm_sched_domain.py b/testcases/kernel/power_management/pm_sched_domain.py
new file mode 100755
index 0000000..a9e62a2
--- /dev/null
+++ b/testcases/kernel/power_management/pm_sched_domain.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+''' This Python script validates sched domain information in dmesg
+ with information in sysfs topology
+'''
+
+import os
+import sys
+LIB_DIR = "%s/lib" % os.path.dirname(__file__)
+sys.path.append(LIB_DIR)
+from pm_sched_mc import *
+from optparse import OptionParser
+
+__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
+
+class Usage(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ usage = "-w"
+ parser = OptionParser(usage)
+ parser.add_option("-c", "--mc_level", dest="mc_level", default=-1,
+ help="Sched mc power saving value 0/1/2")
+ parser.add_option("-t", "--smt_level", dest="smt_level", default=-1,
+ help="Sched smt power saving value 0/1/2")
+ (options, args) = parser.parse_args()
+
+ try:
+ clear_dmesg()
+ count_num_cpu()
+ map_cpuid_pkgid()
+
+ if is_hyper_threaded() and int(options.smt_level) >= 0:
+ set_sched_smt_power(options.smt_level)
+
+ if int(options.mc_level) >= 0:
+ set_sched_mc_power(options.mc_level)
+ if int(options.smt_level) >= 0 or int(options.mc_level) >= 0:
+ status = verify_sched_domain_dmesg(options.mc_level, options.smt_level)
+ reset_schedmc()
+ if is_hyper_threaded():
+ reset_schedsmt()
+ return(status)
+ else:
+ print "INFO: Invalid arguments given"
+ return 1
+ except Exception, details:
+ print "INFO: sched domain test failed: ", details
+ return(1)
+
+# Run test based on the command line arguments
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/testcases/kernel/power_management/runpwtests05.sh b/testcases/kernel/power_management/runpwtests05.sh
index c086e3c..74c9f7c 100755
--- a/testcases/kernel/power_management/runpwtests05.sh
+++ b/testcases/kernel/power_management/runpwtests05.sh
@@ -55,7 +55,7 @@ fi
echo "max sched mc $max_sched_mc"
RC=0
for sched_mc in `seq 0 $max_sched_mc`; do
- sched_domain.py -c $sched_mc; ret=$?
+ pm_sched_domain.py -c $sched_mc; ret=$?
analyze_sched_domain_result $sched_mc $ret; RC=$?
done
if [ $RC -eq 0 ]; then
@@ -67,9 +67,9 @@ fi
# Testcase to validate sched_domain tree
RC=0
for sched_mc in `seq 0 $max_sched_mc`; do
- get_sched_values sched_smt; max_sched_smt=$?
+ pm_get_sched_values sched_smt; max_sched_smt=$?
for sched_smt in `seq 0 $max_sched_smt`; do
- sched_domain.py -c $sched_mc -t $sched_smt; ret=$?
+ pm_sched_domain.py -c $sched_mc -t $sched_smt; ret=$?
analyze_sched_domain_result $sched_mc $ret $sched_smt; RC=$?
done
done
diff --git a/testcases/kernel/power_management/runpwtests_exclusive01.sh b/testcases/kernel/power_management/runpwtests_exclusive01.sh
index 2a7e437..089d3d1 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive01.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive01.sh
@@ -56,7 +56,7 @@ for sched_mc in `seq 0 $max_sched_mc`; do
fi
for repeat_test in `seq 1 10`; do
#Testcase to validate CPU consolidation for sched_mc
- if cpu_consolidation.py -c $sched_mc -w $work_load ; then
+ if pm_cpu_consolidation.py -c $sched_mc -w $work_load ; then
: $(( sched_mc_pass_cnt += 1 ))
fi
done
@@ -81,7 +81,7 @@ for sched_mc in `seq 0 $max_sched_mc`; do
for repeat_test in `seq 1 10`; do
# Testcase to validate CPU consolidation for
# for sched_mc & sched_smt with stress=50%
- if cpu_consolidation.py -c $sched_mc -t $sched_smt \
+ if pm_cpu_consolidation.py -c $sched_mc -t $sched_smt \
-w $work_load ; then
: $(( sched_mc_smt_pass_cnt += 1 ))
fi
diff --git a/testcases/kernel/power_management/runpwtests_exclusive02.sh b/testcases/kernel/power_management/runpwtests_exclusive02.sh
index af08482..1150600 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive02.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive02.sh
@@ -54,7 +54,7 @@ for sched_smt in `seq 0 $max_sched_smt`; do
sched_smt_pass_cnt=0
stress="thread"
for repeat_test in `seq 1 10`; do
- if cpu_consolidation.py -t $sched_smt -w $work_load \
+ if pm_cpu_consolidation.py -t $sched_smt -w $work_load \
-s $stress; then
: $(( sched_smt_pass_cnt += 1 ))
fi
diff --git a/testcases/kernel/power_management/runpwtests_exclusive03.sh b/testcases/kernel/power_management/runpwtests_exclusive03.sh
index 4e3c99e..20d8095 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive03.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive03.sh
@@ -52,7 +52,7 @@ fi
# sched_mc is set to 0.
RC=0
for sched_mc in `seq 1 $max_sched_mc`; do
- if cpu_consolidation.py -v -c $sched_mc; then
+ if pm_cpu_consolidation.py -v -c $sched_mc; then
echo "Test PASS: CPU consolidation test by varying" \
"sched_mc $sched_mc to 0"
else
@@ -74,7 +74,7 @@ RC=0
for sched_mc in `seq 1 $max_sched_mc`; do
for sched_smt in `seq 1 $max_sched_smt`; do
if [ $sched_smt -eq $sched_mc ]; then
- if cpu_consolidation.py -v -c $sched_mc \
+ if pm_cpu_consolidation.py -v -c $sched_mc \
-t $sched_smt; then
echo "Test PASS: CPU consolidation test by" \
"varying sched_mc & sched_smt from" \
diff --git a/testcases/kernel/power_management/runpwtests_exclusive04.sh b/testcases/kernel/power_management/runpwtests_exclusive04.sh
index 7958fc0..080c6b1 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive04.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive04.sh
@@ -38,7 +38,7 @@ fi
# Vary only sched_smt from 1 to 0 when workload is running
# and ensure that tasks do not consolidate to single core
# when sched_smt is set to 0.
-if cpu_consolidation.py -v -t 1; then
+if pm_cpu_consolidation.py -v -t 1; then
tst_resm TPASS "CPU consolidation test by varying sched_smt from 1 to 0"
else
tst_resm TFAIL "CPU consolidation test by varying sched_smt from 1 to 0"
@@ -47,7 +47,7 @@ fi
# Vary only sched_smt from 2 to 0 when workload is running
# and ensure that tasks do not consolidate to single core
# when sched_smt is set to 0.
-if cpu_consolidation.py -v -t 2; then
+if pm_cpu_consolidation.py -v -t 2; then
tst_resm TPASS "CPU consolidation test by varying sched_smt from 2 to 0"
else
tst_resm TFAIL "CPU consolidation test by varying sched_smt from 2 to 0"
diff --git a/testcases/kernel/power_management/runpwtests_exclusive05.sh b/testcases/kernel/power_management/runpwtests_exclusive05.sh
index 186297f..ffb65e4 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive05.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive05.sh
@@ -54,7 +54,7 @@ for sched_mc in `seq 1 $max_sched_mc`; do
work_load="ebizzy"
fi
- ilb_test.py -c $sched_mc -w $work_load
+ pm_ilb_test.py -c $sched_mc -w $work_load
if [ $? -eq 0 ]; then
echo "Test PASS: ILB & workload in same package for" \
"sched_mc=$sched_mc"
@@ -78,7 +78,7 @@ for sched_mc in `seq 1 $max_sched_mc`; do
work_load="ebizzy"
fi
for sched_smt in `seq 1 $max_sched_smt`; do
- ilb_test.py -c $sched_mc -t sched_smt -w $work_load
+ pm_ilb_test.py -c $sched_mc -t sched_smt -w $work_load
if [ $? -eq 0 ]; then
echo "Test PASS: ILB & workload in same package for" \
"sched_mc=$sched_mc & sched_smt=$sched_smt"
diff --git a/testcases/kernel/power_management/sched_domain.py b/testcases/kernel/power_management/sched_domain.py
deleted file mode 100755
index 3d19ac0..0000000
--- a/testcases/kernel/power_management/sched_domain.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-''' This Python script validates sched domain information in dmesg
- with information in sysfs topology
-'''
-
-import os
-import sys
-LIB_DIR = "%s/lib" % os.path.dirname(__file__)
-sys.path.append(LIB_DIR)
-from sched_mc import *
-from optparse import OptionParser
-
-__author__ = "Poornima Nayak <mpnayak@linux.vnet.ibm.com>"
-
-class Usage(Exception):
- def __init__(self, msg):
- self.msg = msg
-
-def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- usage = "-w"
- parser = OptionParser(usage)
- parser.add_option("-c", "--mc_level", dest="mc_level", default=-1,
- help="Sched mc power saving value 0/1/2")
- parser.add_option("-t", "--smt_level", dest="smt_level", default=-1,
- help="Sched smt power saving value 0/1/2")
- (options, args) = parser.parse_args()
-
- try:
- clear_dmesg()
- count_num_cpu()
- map_cpuid_pkgid()
-
- if is_hyper_threaded() and int(options.smt_level) >= 0:
- set_sched_smt_power(options.smt_level)
-
- if int(options.mc_level) >= 0:
- set_sched_mc_power(options.mc_level)
- if int(options.smt_level) >= 0 or int(options.mc_level) >= 0:
- status = verify_sched_domain_dmesg(options.mc_level, options.smt_level)
- reset_schedmc()
- if is_hyper_threaded():
- reset_schedsmt()
- return(status)
- else:
- print "INFO: Invalid arguments given"
- return 1
- except Exception, details:
- print "INFO: sched domain test failed: ", details
- return(1)
-
-# Run test based on the command line arguments
-if __name__ == "__main__":
- sys.exit(main())
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 7/9] power_management: install lib/pm_sched_mc.py into testcases/bin directory
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
` (4 preceding siblings ...)
2015-02-27 8:12 ` [LTP] [PATCH v3 6/9] power_management: prefix files with "pm_" Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-03-02 15:05 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 8/9] power_management: compile testcases/kernel/power_management by default Xing Gu
` (2 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
Install lib/pm_sched_mc.py into testcases/bin instead of
testcases/bin/lib directory, and modify the corresponding
call files, eg. pm_cpu_consolidation.py.
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
testcases/kernel/power_management/Makefile | 10 ++++-----
testcases/kernel/power_management/lib/Makefile | 25 ++++++++++++++++++++++
.../power_management/pm_cpu_consolidation.py | 3 ++-
testcases/kernel/power_management/pm_ilb_test.py | 3 ++-
.../kernel/power_management/pm_sched_domain.py | 3 ++-
5 files changed, 35 insertions(+), 9 deletions(-)
create mode 100644 testcases/kernel/power_management/lib/Makefile
diff --git a/testcases/kernel/power_management/Makefile b/testcases/kernel/power_management/Makefile
index 24f75f8..935f47e 100644
--- a/testcases/kernel/power_management/Makefile
+++ b/testcases/kernel/power_management/Makefile
@@ -13,8 +13,8 @@
## for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
-## along with this program; if not, write to the Free Software ##
-## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
+## along with this program; if not, write to the Free Software Foundation, ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
## ##
################################################################################
@@ -22,10 +22,8 @@ top_srcdir ?= ../../..
include $(top_srcdir)/include/mk/testcases.mk
-vpath %.c $(srcdir):$(top_srcdir)/lib
-
-INSTALL_TARGETS := lib/*.py *.py *.sh
+INSTALL_TARGETS := *.py *.sh
MAKE_DEPS += $(APICMDS_DIR)/tst_kvercmp
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/power_management/lib/Makefile b/testcases/kernel/power_management/lib/Makefile
new file mode 100644
index 0000000..2aadac0
--- /dev/null
+++ b/testcases/kernel/power_management/lib/Makefile
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2015 Fujitsu Ltd.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS := *.py
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/power_management/pm_cpu_consolidation.py b/testcases/kernel/power_management/pm_cpu_consolidation.py
index 5aa3948..72822b7 100755
--- a/testcases/kernel/power_management/pm_cpu_consolidation.py
+++ b/testcases/kernel/power_management/pm_cpu_consolidation.py
@@ -7,7 +7,8 @@ import os
import sys
import time
LIB_DIR = "%s/lib" % os.path.dirname(__file__)
-sys.path.append(LIB_DIR)
+if os.path.exists(LIB_DIR):
+ sys.path.append(LIB_DIR)
from optparse import OptionParser
from pm_sched_mc import *
diff --git a/testcases/kernel/power_management/pm_ilb_test.py b/testcases/kernel/power_management/pm_ilb_test.py
index 3f6ad46..b6a87e8 100755
--- a/testcases/kernel/power_management/pm_ilb_test.py
+++ b/testcases/kernel/power_management/pm_ilb_test.py
@@ -6,7 +6,8 @@
import os
import sys
LIB_DIR = "%s/lib" % os.path.dirname(__file__)
-sys.path.append(LIB_DIR)
+if os.path.exists(LIB_DIR):
+ sys.path.append(LIB_DIR)
from optparse import OptionParser
from pm_sched_mc import *
diff --git a/testcases/kernel/power_management/pm_sched_domain.py b/testcases/kernel/power_management/pm_sched_domain.py
index a9e62a2..96cc355 100755
--- a/testcases/kernel/power_management/pm_sched_domain.py
+++ b/testcases/kernel/power_management/pm_sched_domain.py
@@ -6,7 +6,8 @@
import os
import sys
LIB_DIR = "%s/lib" % os.path.dirname(__file__)
-sys.path.append(LIB_DIR)
+if os.path.exists(LIB_DIR):
+ sys.path.append(LIB_DIR)
from pm_sched_mc import *
from optparse import OptionParser
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 8/9] power_management: compile testcases/kernel/power_management by default
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
` (5 preceding siblings ...)
2015-02-27 8:12 ` [LTP] [PATCH v3 7/9] power_management: install lib/pm_sched_mc.py into testcases/bin directory Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 9/9] power_management: add it into default Xing Gu
2015-03-02 15:09 ` [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Cyril Hrubis
8 siblings, 0 replies; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
configure.ac | 14 --------------
include/mk/features.mk.default | 2 +-
include/mk/features.mk.in | 2 +-
3 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index 794059c..0ca21a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,20 +102,6 @@ fi
# Testsuites knobs
-# testcases/kernel/power_management requires python.
-if test "x$with_python" = xyes; then
- AC_ARG_WITH([power-management-testsuite],
- [AC_HELP_STRING([--with-power-management-testsuite],
- [compile and install the x86 power management testsuite (default=no)])],
- [with_power_management_testsuite=yes],
- )
-fi
-if test "x$with_power_management_testsuite" = xyes; then
- AC_SUBST([WITH_POWER_MANAGEMENT_TESTSUITE],["yes"])
-else
- AC_SUBST([WITH_POWER_MANAGEMENT_TESTSUITE],["no"])
-fi
-
AC_ARG_WITH([open-posix-testsuite],
[AC_HELP_STRING([--with-open-posix-testsuite],
[compile and install the open posix testsuite (default=no)])],
diff --git a/include/mk/features.mk.default b/include/mk/features.mk.default
index c9edc1c..22a0f0e 100644
--- a/include/mk/features.mk.default
+++ b/include/mk/features.mk.default
@@ -38,7 +38,7 @@ HAVE_SECUREBITS := no
ifeq ($(UCLINUX),1)
WITH_POWER_MANAGEMENT_TESTSUITE := no
else
-WITH_POWER_MANAGEMENT_TESTSUITE :=
+WITH_POWER_MANAGEMENT_TESTSUITE := yes
endif
# Enable testcases/open_posix_testsuite's compile and install?
diff --git a/include/mk/features.mk.in b/include/mk/features.mk.in
index 1fd28f8..8030be7 100644
--- a/include/mk/features.mk.in
+++ b/include/mk/features.mk.in
@@ -38,7 +38,7 @@ HAVE_SECUREBITS := @HAVE_SECUREBITS@
ifeq ($(UCLINUX),1)
WITH_POWER_MANAGEMENT_TESTSUITE := no
else
-WITH_POWER_MANAGEMENT_TESTSUITE := @WITH_POWER_MANAGEMENT_TESTSUITE@
+WITH_POWER_MANAGEMENT_TESTSUITE := yes
endif
# Enable testcases/open_posix_testsuite's compile and install?
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [PATCH v3 9/9] power_management: add it into default
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
` (6 preceding siblings ...)
2015-02-27 8:12 ` [LTP] [PATCH v3 8/9] power_management: compile testcases/kernel/power_management by default Xing Gu
@ 2015-02-27 8:12 ` Xing Gu
2015-03-02 15:09 ` [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Cyril Hrubis
8 siblings, 0 replies; 14+ messages in thread
From: Xing Gu @ 2015-02-27 8:12 UTC (permalink / raw)
To: ltp-list
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
---
scenario_groups/default | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scenario_groups/default b/scenario_groups/default
index 3a55702..1e9de48 100644
--- a/scenario_groups/default
+++ b/scenario_groups/default
@@ -19,7 +19,6 @@ fcntl-locktests
connectors
admin_tools
timers
-power_management_tests
numa
hugetlb
commands
@@ -32,3 +31,5 @@ dma_thread_diotest
cpuacct
can
cpuhotplug
+power_management_tests
+power_management_tests_exclusive
--
1.9.3
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [LTP] [PATCH v3 3/9] power_management: split runpwtests.sh into separate testcases
2015-02-27 8:12 ` [LTP] [PATCH v3 3/9] power_management: split runpwtests.sh into separate testcases Xing Gu
@ 2015-03-02 14:49 ` Cyril Hrubis
0 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2015-03-02 14:49 UTC (permalink / raw)
To: Xing Gu; +Cc: ltp-list
Hi!
> --- /dev/null
> +++ b/testcases/kernel/power_management/runpwtests01.sh
> @@ -0,0 +1,49 @@
> +#! /bin/sh
> +#
> +# Copyright (c) International Business Machines Corp., 2001
> +# Author: Nageswara R Sastry <nasastry@in.ibm.com>
> +#
> +# This program is free software; you can redistribute it and#or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
> +# for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software Foundation,
> +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> +#
> +
> +export TCID="Power_Management01"
> +export TST_TOTAL=1
> +
> +. test.sh
> +. pm_include.sh
> +
> +# Checking test environment
> +check_kervel_arch
> +
> +# Checking sched_mc sysfs interface
> +multi_socket=$(is_multi_socket)
> +multi_core=$(is_multi_core)
> +if [ ! -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
> + tst_brkm TCONF "Required kernel configuration for SCHED_MC" \
> + "NOT set"
> +else
> + if [ $multi_socket -ne 0 -a $multi_core -ne 0 ] ; then
> + tst_brkm TCONF "sched_mc_power_savings interface in system" \
> + "which is not a multi socket &(/) multi core"
> + fi
> +fi
> +
> +if test_sched_mc.sh ; then
This script seems to be called only from this script. What is the point
of having it in a separate file?
And the same for the rest of the testcses.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [LTP] [PATCH v3 4/9] power_management: call the function eg. test_sched_mc instead of script test_sched_mc.sh
2015-02-27 8:12 ` [LTP] [PATCH v3 4/9] power_management: call the function eg. test_sched_mc instead of script test_sched_mc.sh Xing Gu
@ 2015-03-02 14:50 ` Cyril Hrubis
0 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2015-03-02 14:50 UTC (permalink / raw)
To: Xing Gu; +Cc: ltp-list
Hi!
> Many scripts eg. test_sched_mc.sh is called only from
> one test eg. runpwtests01.sh. Remove the script code
> into the corresponding test case.
Ah, right here is the change I've been looking for ;).
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench
2015-02-27 8:12 ` [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench Xing Gu
@ 2015-03-02 15:00 ` Cyril Hrubis
0 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2015-03-02 15:00 UTC (permalink / raw)
To: Xing Gu; +Cc: ltp-list
Hi!
> + else:
> + print "INFO: ebizzy benchmark not found"
> + sys.exit(1)
> + else:
> + path = '%s/testcases/bin' % os.environ['LTPROOT']
> + os.chdir(path)
> + workload_file = ""
> + for file_name in os.listdir('.'):
> + if file_name == workload:
> + workload_file = file_name
> + break
> + if workload_file == "":
> + print "INFO: ebizzy benchmark not found"
> + sys.exit(1)
> + get_proc_data(stats_start)
> + get_proc_loc_count(intr_start)
> + try:
> + if background == "yes":
> + succ = os.system('./ebizzy -t%s -s4096 -S %s >/dev/null &'
> + % (threads, duration))
The $LTPROOT/testcases/bin should be in $PATH while LTP is executed. So
why don't we remove all the code that tries to figure the path and just
run os.system('ebizzy ....') and return TCONF if that returned 127?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [LTP] [PATCH v3 7/9] power_management: install lib/pm_sched_mc.py into testcases/bin directory
2015-02-27 8:12 ` [LTP] [PATCH v3 7/9] power_management: install lib/pm_sched_mc.py into testcases/bin directory Xing Gu
@ 2015-03-02 15:05 ` Cyril Hrubis
0 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2015-03-02 15:05 UTC (permalink / raw)
To: Xing Gu; +Cc: ltp-list
Hi!
> include $(top_srcdir)/include/mk/testcases.mk
>
> -vpath %.c $(srcdir):$(top_srcdir)/lib
> -
> -INSTALL_TARGETS := lib/*.py *.py *.sh
> +INSTALL_TARGETS := *.py *.sh
>
> MAKE_DEPS += $(APICMDS_DIR)/tst_kvercmp
>
> -include $(top_srcdir)/include/mk/generic_leaf_target.mk
> +include $(top_srcdir)/include/mk/generic_trunk_target.mk
> diff --git a/testcases/kernel/power_management/lib/Makefile b/testcases/kernel/power_management/lib/Makefile
> new file mode 100644
> index 0000000..2aadac0
> --- /dev/null
> +++ b/testcases/kernel/power_management/lib/Makefile
> @@ -0,0 +1,25 @@
> +#
> +# Copyright (c) 2015 Fujitsu Ltd.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along
> +# with this program; if not, write to the Free Software Foundation, Inc.,
> +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +#
> +
> +top_srcdir ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/env_pre.mk
> +
> +INSTALL_TARGETS := *.py
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/power_management/pm_cpu_consolidation.py b/testcases/kernel/power_management/pm_cpu_consolidation.py
> index 5aa3948..72822b7 100755
> --- a/testcases/kernel/power_management/pm_cpu_consolidation.py
> +++ b/testcases/kernel/power_management/pm_cpu_consolidation.py
> @@ -7,7 +7,8 @@ import os
> import sys
> import time
> LIB_DIR = "%s/lib" % os.path.dirname(__file__)
> -sys.path.append(LIB_DIR)
> +if os.path.exists(LIB_DIR):
> + sys.path.append(LIB_DIR)
> from optparse import OptionParser
> from pm_sched_mc import *
So nothing gets installed into lib/ anymore, right?
Why not just delete the line? Or am I missing something?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc.
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
` (7 preceding siblings ...)
2015-02-27 8:12 ` [LTP] [PATCH v3 9/9] power_management: add it into default Xing Gu
@ 2015-03-02 15:09 ` Cyril Hrubis
8 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2015-03-02 15:09 UTC (permalink / raw)
To: Xing Gu; +Cc: ltp-list
Hi!
Generally this this patchset looks fine, minus the minor issues I've
pointed out.
And we should at least add tst_check_cmds python to testcases that
executes python scripts so that we get better error message.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-03-02 15:10 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27 8:12 [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 2/9] lib/sched_mc.py: add testcase/bin path for searching ebizzy/kernbench Xing Gu
2015-03-02 15:00 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 3/9] power_management: split runpwtests.sh into separate testcases Xing Gu
2015-03-02 14:49 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 4/9] power_management: call the function eg. test_sched_mc instead of script test_sched_mc.sh Xing Gu
2015-03-02 14:50 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 5/9] power_management: delete unused files Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 6/9] power_management: prefix files with "pm_" Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 7/9] power_management: install lib/pm_sched_mc.py into testcases/bin directory Xing Gu
2015-03-02 15:05 ` Cyril Hrubis
2015-02-27 8:12 ` [LTP] [PATCH v3 8/9] power_management: compile testcases/kernel/power_management by default Xing Gu
2015-02-27 8:12 ` [LTP] [PATCH v3 9/9] power_management: add it into default Xing Gu
2015-03-02 15:09 ` [LTP] [PATCH v3 1/9] kernel/power_management: fix no_of_cpus error of change_govr.sh etc Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox