Create a global variable that will look for number of cpus for a platform and use it in multiple functions to make the code simplier to read.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org --- cpufreq/cpufreq_05.sh | 6 +++--- cpuhotplug/cpuhotplug_sanity.sh | 1 - include/functions.sh | 13 +++++-------- include/thermal_functions.sh | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh index 93fce78..1f0dd8d 100755 --- a/cpufreq/cpufreq_05.sh +++ b/cpufreq/cpufreq_05.sh @@ -62,7 +62,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondem if [ -z "$supported" ]; then log_skip "ondemand not supported" else - for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + for cpu in $cpus; do switch_ondemand $cpu done check_governor $cpu 'ondemand' @@ -72,7 +72,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "conse if [ -z "$supported" ]; then log_skip "conservative not supported" else - for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + for cpu in $cpus; do switch_conservative $cpu done check_governor $cpu 'conservative' @@ -82,7 +82,7 @@ supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "users if [ -z "$supported" ]; then log_skip "userspace not supported" else - for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + for cpu in $cpus; do switch_userspace $cpu done
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh index d9b6af8..2ad24ff 100755 --- a/cpuhotplug/cpuhotplug_sanity.sh +++ b/cpuhotplug/cpuhotplug_sanity.sh @@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
- cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then diff --git a/include/functions.sh b/include/functions.sh index e0f08fb..74b2294 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh}) PREFIX=$TEST_NAME INC=0 CPU= +cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") pass_count=0 fail_count=0 skip_count=0 @@ -86,7 +87,6 @@ for_each_cpu() { local func=$1 shift 1
- cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") for cpu in $cpus; do INC=0 CPU=/$cpu @@ -339,8 +339,8 @@ save_governors() { governors_backup= local index=0
- for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do - governors_backup[$index]=$(cat $CPU_PATH/$i/cpufreq/scaling_governor) + for cpu in $cpus; do + governors_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_governor) index=$((index + 1)) done } @@ -350,9 +350,9 @@ restore_governors() { local index=0 local oldgov=
- for i in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + for cpu in $cpus; do oldgov=${governors_backup[$index]} - echo $oldgov > $CPU_PATH/$i/cpufreq/scaling_governor + echo $oldgov > $CPU_PATH/$cpu/cpufreq/scaling_governor index=$((index + 1)) done } @@ -361,8 +361,6 @@ save_frequencies() {
frequencies_backup= local index=0 - local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") - local cpu=
for cpu in $cpus; do frequencies_backup[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_cur_freq) @@ -374,7 +372,6 @@ restore_frequencies() {
local index=0 local oldfreq= - local cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
for cpu in $cpus; do oldfreq=${frequencies_backup[$index]} diff --git a/include/thermal_functions.sh b/include/thermal_functions.sh index a51240b..c25e1d8 100644 --- a/include/thermal_functions.sh +++ b/include/thermal_functions.sh @@ -184,7 +184,7 @@ check_scaling_freq() { local index=0
local flag=0 - for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + for cpu in $cpus; do if [ $before_freq_list[$index] -ne $afterf_req_list[$index] ] ; then flag=1 fi @@ -197,7 +197,7 @@ store_scaling_maxfreq() { scale_freq= local index=0
- for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + for cpu in $cpus; do scale_freq[$index]=$(cat $CPU_PATH/$cpu/cpufreq/scaling_max_freq) index=$((index + 1)) done
On Fri, Aug 8, 2014 at 7:05 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Create a global variable that will look for number of cpus for a platform and use it in multiple functions to make the code simplier to read.
Agree with the patch.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh index d9b6af8..2ad24ff 100755 --- a/cpuhotplug/cpuhotplug_sanity.sh +++ b/cpuhotplug/cpuhotplug_sanity.sh @@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then
diff --git a/include/functions.sh b/include/functions.sh index e0f08fb..74b2294 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh}) PREFIX=$TEST_NAME INC=0 CPU= +cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
Let's fix this properly while we're at it. We already have boards with more than 10 cpus now - D01.
Regards, Amit
On Friday 08 August 2014 10:43 AM, Amit Kucheria wrote:
On Fri, Aug 8, 2014 at 7:05 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Create a global variable that will look for number of cpus for a platform and use it in multiple functions to make the code simplier to read.
Agree with the patch.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh index d9b6af8..2ad24ff 100755 --- a/cpuhotplug/cpuhotplug_sanity.sh +++ b/cpuhotplug/cpuhotplug_sanity.sh @@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then
diff --git a/include/functions.sh b/include/functions.sh index e0f08fb..74b2294 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh}) PREFIX=$TEST_NAME INC=0 CPU= +cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
Let's fix this properly while we're at it. We already have boards with more than 10 cpus now - D01.
- Its fine, it will work. The sqare brackets filters the pattern, e.g. with this filter
cpu1 and also all cpu1*** will be filtered IN.
- Issue with this filter here is it will return cpu is improper order, as
cpu0 cpu1 cpu10 cpu11 cpu12 cpu13 cpu14 cpu15 cpu2 cpu3 cpu4
so here after cpu1, cpu10 will be processed instead of logically cpu2. We can sort using *-v* option of ls here to get cpus sequentially
cpus=$(ls -1v $CPU_PATH | grep "cpu[0-9].*")
Regards, Amit
On 08/08/14 14:32, Sanjay Singh Rawat wrote:
On Friday 08 August 2014 10:43 AM, Amit Kucheria wrote:
On Fri, Aug 8, 2014 at 7:05 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Create a global variable that will look for number of cpus for a platform and use it in multiple functions to make the code simplier to read.
Agree with the patch.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh index d9b6af8..2ad24ff 100755 --- a/cpuhotplug/cpuhotplug_sanity.sh +++ b/cpuhotplug/cpuhotplug_sanity.sh @@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then
diff --git a/include/functions.sh b/include/functions.sh index e0f08fb..74b2294 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh}) PREFIX=$TEST_NAME INC=0 CPU= +cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
Let's fix this properly while we're at it. We already have boards with more than 10 cpus now - D01.
- Its fine, it will work. The sqare brackets filters the pattern, e.g.
with this filter
cpu1 and also all cpu1*** will be filtered IN.
- Issue with this filter here is it will return cpu is improper order, as
cpu0 cpu1 cpu10 cpu11 cpu12 cpu13 cpu14 cpu15 cpu2 cpu3 cpu4
so here after cpu1, cpu10 will be processed instead of logically cpu2. We can sort using *-v* option of ls here to get cpus sequentially
cpus=$(ls -1v $CPU_PATH | grep "cpu[0-9].*")
It might be worth checking that the CPUs you find are online. In an IKS system half the CPUs are offline.
--Chris
On Fri, Aug 8, 2014 at 7:02 PM, Sanjay Singh Rawat sanjay.rawat@linaro.org wrote:
On Friday 08 August 2014 10:43 AM, Amit Kucheria wrote:
On Fri, Aug 8, 2014 at 7:05 AM, Lisa Nguyen lisa.nguyen@linaro.org wrote:
Create a global variable that will look for number of cpus for a platform and use it in multiple functions to make the code simplier to read.
Agree with the patch.
Signed-off-by: Lisa Nguyen lisa.nguyen@linaro.org
diff --git a/cpuhotplug/cpuhotplug_sanity.sh b/cpuhotplug/cpuhotplug_sanity.sh index d9b6af8..2ad24ff 100755 --- a/cpuhotplug/cpuhotplug_sanity.sh +++ b/cpuhotplug/cpuhotplug_sanity.sh @@ -33,7 +33,6 @@ fi
check_cpuhotplug_sysfs_entry() {
cpus=$(ls $CPU_PATH | grep "cpu[0-9].*") cpunum=$(ls $CPU_PATH | grep "cpu[0-9].*" -c)
if [ $cpunum -eq 1 ]; then
diff --git a/include/functions.sh b/include/functions.sh index e0f08fb..74b2294 100644 --- a/include/functions.sh +++ b/include/functions.sh @@ -30,6 +30,7 @@ TEST_NAME=$(basename ${0%.sh}) PREFIX=$TEST_NAME INC=0 CPU= +cpus=$(ls $CPU_PATH | grep "cpu[0-9].*")
Let's fix this properly while we're at it. We already have boards with more than 10 cpus now - D01.
- Its fine, it will work. The sqare brackets filters the pattern, e.g. with
this filter
Right. I misread the regex. What's new.
cpu1 and also all cpu1*** will be filtered IN.
- Issue with this filter here is it will return cpu is improper order, as
cpu0 cpu1 cpu10 cpu11 cpu12 cpu13 cpu14 cpu15 cpu2 cpu3 cpu4
so here after cpu1, cpu10 will be processed instead of logically cpu2. We can sort using *-v* option of ls here to get cpus sequentially
cpus=$(ls -1v $CPU_PATH | grep "cpu[0-9].*")
Regards, Amit
-- sanjay