Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org --- cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +# + +# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm... + +. ../include/functions.sh + +is_flag_set() { + flag=$1 + mask=$2 + message=$3 + + value=$(( $flag & $mask )) + + if [ $value -ne 0 ]; then + echo "$message set" + else + echo "$message not set" + fi +} + +check_sched_domain_flags() { + + cpu_num=$1 + domain_num=$2 + + sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags + val=$(cat $sched_domain_flags) + + check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1"" + printf "domain$domain_num flag 0x%x\n" $val + + is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag" + is_flag_set $val 0x100 "domain$domain_num share power domain flag" + is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag" +} + +check_all_sched_domain_flags() { + + n=0 + + if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then + return + fi + + while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do + check_sched_domain_flags $1 $n + n=$(( n + 1)) + done +} + +for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@ +test that the sched_domain files are present and show the topology related flags
[Adding Mike Turquette as another possible reviewer]
On 7 February 2015 at 16:08, Larry Bassel larry.bassel@linaro.org wrote:
Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org
cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +#
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
+. ../include/functions.sh
+is_flag_set() {
- flag=$1
- mask=$2
- message=$3
- value=$(( $flag & $mask ))
- if [ $value -ne 0 ]; then
echo "$message set"
- else
echo "$message not set"
- fi
+}
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
+}
+check_all_sched_domain_flags() {
- n=0
- if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
return
- fi
That looks weird with the ! hanging outside of the expression; it's usually inside the [ ]. Can you store the /proc/sys/kernel/sched_domain/cpu0 path into a variable? It'd make that small code block nicer and easier to maintain if the path needs to be changed in the future.
Also, please use the log_skip function to display an "error" message to stdout before the return keyword if the directory doesn't exist.
- while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
check_sched_domain_flags $1 $n
n=$(( n + 1))
- done
+}
Again, if there's a way to store the path into a variable, it'd be nice.
+for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@
+test that the sched_domain files are present and show the topology related flags
1.9.1
Amit, Daniel, Vincent, or Mike, can you guys run Larry's script to see if his tests make sense? I can't accept Larry's patch without another person's ack or reviewed-by and in need of a second opinion. Thanks.
On 24 February 2015 at 01:58, Lisa Nguyen lisa.nguyen@linaro.org wrote:
[Adding Mike Turquette as another possible reviewer]
On 7 February 2015 at 16:08, Larry Bassel larry.bassel@linaro.org wrote:
Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org
cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +#
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
+. ../include/functions.sh
+is_flag_set() {
- flag=$1
- mask=$2
- message=$3
- value=$(( $flag & $mask ))
- if [ $value -ne 0 ]; then
echo "$message set"
- else
echo "$message not set"
- fi
+}
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
+}
+check_all_sched_domain_flags() {
- n=0
- if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
return
- fi
That looks weird with the ! hanging outside of the expression; it's usually inside the [ ]. Can you store the /proc/sys/kernel/sched_domain/cpu0 path into a variable? It'd make that small code block nicer and easier to maintain if the path needs to be changed in the future.
Also, please use the log_skip function to display an "error" message to stdout before the return keyword if the directory doesn't exist.
- while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
check_sched_domain_flags $1 $n
n=$(( n + 1))
- done
+}
Again, if there's a way to store the path into a variable, it'd be nice.
+for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@
+test that the sched_domain files are present and show the topology related flags
1.9.1
Amit, Daniel, Vincent, or Mike, can you guys run Larry's script to see if his tests make sense? I can't accept Larry's patch without another person's ack or reviewed-by and in need of a second opinion. Thanks.
I'm going to test it on my cb2 tomorrow and will give you a feedback
On 24 February 2015 at 21:53, Vincent Guittot vincent.guittot@linaro.org wrote:
On 24 February 2015 at 01:58, Lisa Nguyen lisa.nguyen@linaro.org wrote:
[Adding Mike Turquette as another possible reviewer]
On 7 February 2015 at 16:08, Larry Bassel larry.bassel@linaro.org wrote:
Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org
cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +#
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
+. ../include/functions.sh
+is_flag_set() {
- flag=$1
- mask=$2
- message=$3
- value=$(( $flag & $mask ))
- if [ $value -ne 0 ]; then
echo "$message set"
- else
echo "$message not set"
- fi
+}
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
+}
+check_all_sched_domain_flags() {
- n=0
- if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
return
- fi
That looks weird with the ! hanging outside of the expression; it's usually inside the [ ]. Can you store the /proc/sys/kernel/sched_domain/cpu0 path into a variable? It'd make that small code block nicer and easier to maintain if the path needs to be changed in the future.
Also, please use the log_skip function to display an "error" message to stdout before the return keyword if the directory doesn't exist.
- while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
check_sched_domain_flags $1 $n
n=$(( n + 1))
- done
+}
Again, if there's a way to store the path into a variable, it'd be nice.
+for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@
+test that the sched_domain files are present and show the topology related flags
1.9.1
Amit, Daniel, Vincent, or Mike, can you guys run Larry's script to see if his tests make sense? I can't accept Larry's patch without another person's ack or reviewed-by and in need of a second opinion. Thanks.
I'm going to test it on my cb2 tomorrow and will give you a feedback
testing the script and the output is not as straight forward as I was expecting. The script has some dependency with other one that i don't have. Is there a simple way to get the minimal scripts to run this one ? IIUC, the script needs ../include/functions.sh which provides some helper function. can lisa or larry make this script available somewhere ?
Regards, Vincent
On 25 February 2015 at 05:52, Vincent Guittot vincent.guittot@linaro.org wrote:
On 24 February 2015 at 21:53, Vincent Guittot vincent.guittot@linaro.org wrote:
On 24 February 2015 at 01:58, Lisa Nguyen lisa.nguyen@linaro.org wrote:
[Adding Mike Turquette as another possible reviewer]
On 7 February 2015 at 16:08, Larry Bassel larry.bassel@linaro.org wrote:
Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org
cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +#
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
+. ../include/functions.sh
+is_flag_set() {
- flag=$1
- mask=$2
- message=$3
- value=$(( $flag & $mask ))
- if [ $value -ne 0 ]; then
echo "$message set"
- else
echo "$message not set"
- fi
+}
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
+}
+check_all_sched_domain_flags() {
- n=0
- if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
return
- fi
That looks weird with the ! hanging outside of the expression; it's usually inside the [ ]. Can you store the /proc/sys/kernel/sched_domain/cpu0 path into a variable? It'd make that small code block nicer and easier to maintain if the path needs to be changed in the future.
Also, please use the log_skip function to display an "error" message to stdout before the return keyword if the directory doesn't exist.
- while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
check_sched_domain_flags $1 $n
n=$(( n + 1))
- done
+}
Again, if there's a way to store the path into a variable, it'd be nice.
+for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@
+test that the sched_domain files are present and show the topology related flags
1.9.1
Amit, Daniel, Vincent, or Mike, can you guys run Larry's script to see if his tests make sense? I can't accept Larry's patch without another person's ack or reviewed-by and in need of a second opinion. Thanks.
I'm going to test it on my cb2 tomorrow and will give you a feedback
testing the script and the output is not as straight forward as I was expecting. The script has some dependency with other one that i don't have. Is there a simple way to get the minimal scripts to run this one ? IIUC, the script needs ../include/functions.sh which provides some helper function. can lisa or larry make this script available somewhere ?
Vincent,
I've attached Larry's script and the functions.sh file with some modifications to avoid downloading the entire PM-QA test suite. Put them in the same directory, and run `sudo ./cputopology_03.sh`. Let me know if you're still having trouble.
On 25 February 2015 at 20:02, Lisa Nguyen lisa.nguyen@linaro.org wrote:
On 25 February 2015 at 05:52, Vincent Guittot vincent.guittot@linaro.org wrote:
On 24 February 2015 at 21:53, Vincent Guittot vincent.guittot@linaro.org wrote:
On 24 February 2015 at 01:58, Lisa Nguyen lisa.nguyen@linaro.org wrote:
[Adding Mike Turquette as another possible reviewer]
On 7 February 2015 at 16:08, Larry Bassel larry.bassel@linaro.org wrote:
Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org
cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +#
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
+. ../include/functions.sh
+is_flag_set() {
- flag=$1
- mask=$2
- message=$3
- value=$(( $flag & $mask ))
- if [ $value -ne 0 ]; then
echo "$message set"
- else
echo "$message not set"
- fi
+}
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
+}
+check_all_sched_domain_flags() {
- n=0
- if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
return
- fi
That looks weird with the ! hanging outside of the expression; it's usually inside the [ ]. Can you store the /proc/sys/kernel/sched_domain/cpu0 path into a variable? It'd make that small code block nicer and easier to maintain if the path needs to be changed in the future.
Also, please use the log_skip function to display an "error" message to stdout before the return keyword if the directory doesn't exist.
- while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
check_sched_domain_flags $1 $n
n=$(( n + 1))
- done
+}
Again, if there's a way to store the path into a variable, it'd be nice.
+for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@
+test that the sched_domain files are present and show the topology related flags
1.9.1
Amit, Daniel, Vincent, or Mike, can you guys run Larry's script to see if his tests make sense? I can't accept Larry's patch without another person's ack or reviewed-by and in need of a second opinion. Thanks.
I'm going to test it on my cb2 tomorrow and will give you a feedback
testing the script and the output is not as straight forward as I was expecting. The script has some dependency with other one that i don't have. Is there a simple way to get the minimal scripts to run this one ? IIUC, the script needs ../include/functions.sh which provides some helper function. can lisa or larry make this script available somewhere ?
Vincent,
I've attached Larry's script and the functions.sh file with some modifications to avoid downloading the entire PM-QA test suite. Put them in the same directory, and run `sudo ./cputopology_03.sh`. Let me know if you're still having trouble.
Thanks, it works fine.
the output of the script looks ok for me. Let wait for the next version of larry's script that will replace hardcoded tests
Regards, Vincent
On 8 February 2015 at 01:08, Larry Bassel larry.bassel@linaro.org wrote:
Add test which checks and prints scheduler domain flags.
Signed-off-by: Larry Bassel larry.bassel@linaro.org
cputopology/cputopology_03.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ cputopology/cputopology_03.txt | 1 + 2 files changed, 75 insertions(+) create mode 100755 cputopology/cputopology_03.sh create mode 100644 cputopology/cputopology_03.txt
diff --git a/cputopology/cputopology_03.sh b/cputopology/cputopology_03.sh new file mode 100755 index 0000000..0fc2771 --- /dev/null +++ b/cputopology/cputopology_03.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# +# PM-QA validation test suite for the power management on Linux +# +# Copyright (C) 2015, Linaro Limited. +# +# 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. +# +# Contributors: +# Larry Bassel larry.bassel@linaro.org +#
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/Pm...
+. ../include/functions.sh
+is_flag_set() {
- flag=$1
- mask=$2
- message=$3
- value=$(( $flag & $mask ))
- if [ $value -ne 0 ]; then
echo "$message set"
- else
echo "$message not set"
- fi
+}
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
could you use a list of masks to be tested against $val instead of hard coding them ? the number of flags to be tested should increase with eas patchset
+}
+check_all_sched_domain_flags() {
- n=0
move the init of n after the test below. init of n is not needed if we return prematurely
- if ! [ -d /proc/sys/kernel/sched_domain/cpu0 ]; then
return
- fi
- while [ -e /proc/sys/kernel/sched_domain/$1/domain$n/flags ]; do
check_sched_domain_flags $1 $n
n=$(( n + 1))
- done
+}
+for_each_cpu check_all_sched_domain_flags 1 || exit 1 +test_status_show diff --git a/cputopology/cputopology_03.txt b/cputopology/cputopology_03.txt new file mode 100644 index 0000000..e43de69 --- /dev/null +++ b/cputopology/cputopology_03.txt @@ -0,0 +1 @@
+test that the sched_domain files are present and show the topology related flags
1.9.1
On 24 Feb 15 21:53, Vincent Guittot wrote:
On 8 February 2015 at 01:08, Larry Bassel larry.bassel@linaro.org wrote:
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
could you use a list of masks to be tested against $val instead of hard coding them ? the number of flags to be tested should increase with eas patchset
Yes, this is a good idea. What is the best (i.e. cleanest/most maintainable/most portable) way of doing this in a shell script? Arrays of masks and corresponding strings? I think I remember Lisa telling me that arrays aren't portable as they are not in all shells.
Thanks.
Larry
Quoting Larry Bassel (2015-02-24 13:50:51)
On 24 Feb 15 21:53, Vincent Guittot wrote:
On 8 February 2015 at 01:08, Larry Bassel larry.bassel@linaro.org wrote:
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
could you use a list of masks to be tested against $val instead of hard coding them ? the number of flags to be tested should increase with eas patchset
Yes, this is a good idea. What is the best (i.e. cleanest/most maintainable/most portable) way of doing this in a shell script?
SD flags are not exported to userspace so we can't scrape them at run-time from /usr/include/linux/sched.h. That would be the most future-proof way of doing it, but would require packaging kernel headers, etc.
Arrays of masks and corresponding strings? I think I remember Lisa telling me that arrays aren't portable as they are not in all shells.
The current implementation isn't very future-proof. If the definition of a flag is missing from the script then it is silently ignored. A better way is to iterate over every bit in the 32-bit flag mask and print out whether that bit is set or unset, and also a human-friendly definition if that is known. But not having the human-readable definition should not exclude the numeric value from being displayed since we might create new flags as Vincent suggested.
More realistically it looks like all of the current flags fit in the bottom 16 bits of the flag mask, so maybe we can just print the first 16 bits instead of 32. Maybe something like:
for i in $(seq 16); do is_flag_set $val $i; done
Where is_flag_set prints whether bit $i is set or unset in $val. is_flag_set can also maintain the table/array of human-readable flags for well-defined definitions that we consider to be stable/unchanging.
Regards, Mike
Thanks.
Larry
linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev
On 27 February 2015 at 01:32, Mike Turquette mturquette@linaro.org wrote:
Quoting Larry Bassel (2015-02-24 13:50:51)
On 24 Feb 15 21:53, Vincent Guittot wrote:
On 8 February 2015 at 01:08, Larry Bassel larry.bassel@linaro.org wrote:
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
could you use a list of masks to be tested against $val instead of hard coding them ? the number of flags to be tested should increase with eas patchset
Yes, this is a good idea. What is the best (i.e. cleanest/most maintainable/most portable) way of doing this in a shell script?
SD flags are not exported to userspace so we can't scrape them at run-time from /usr/include/linux/sched.h. That would be the most future-proof way of doing it, but would require packaging kernel headers, etc.
Arrays of masks and corresponding strings? I think I remember Lisa telling me that arrays aren't portable as they are not in all shells.
The current implementation isn't very future-proof. If the definition of a flag is missing from the script then it is silently ignored. A better way is to iterate over every bit in the 32-bit flag mask and print out whether that bit is set or unset, and also a human-friendly definition if that is known. But not having the human-readable definition should not exclude the numeric value from being displayed since we might create new flags as Vincent suggested.
In fact, the flag value is already displayed by the script before analysing the bit we are interested in and i'm not sure that we want to display all the flags as some are set out of our control or irrelevant for the test. Nevetheless, we can test the sched_domain flags and compare it with a defined bitmask so we can display a warning if a new unknow flag appears
Regards
More realistically it looks like all of the current flags fit in the bottom 16 bits of the flag mask, so maybe we can just print the first 16 bits instead of 32. Maybe something like:
for i in $(seq 16); do is_flag_set $val $i; done
Where is_flag_set prints whether bit $i is set or unset in $val. is_flag_set can also maintain the table/array of human-readable flags for well-defined definitions that we consider to be stable/unchanging.
Regards, Mike
Thanks.
Larry
linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev
Quoting Vincent Guittot (2015-02-27 00:39:53)
On 27 February 2015 at 01:32, Mike Turquette mturquette@linaro.org wrote:
Quoting Larry Bassel (2015-02-24 13:50:51)
On 24 Feb 15 21:53, Vincent Guittot wrote:
On 8 February 2015 at 01:08, Larry Bassel larry.bassel@linaro.org wrote:
+check_sched_domain_flags() {
- cpu_num=$1
- domain_num=$2
- sched_domain_flags=/proc/sys/kernel/sched_domain/$cpu_num/domain$domain_num/flags
- val=$(cat $sched_domain_flags)
- check "sched_domain_flags (domain $domain_num)" "test "$val" != "-1""
- printf "domain$domain_num flag 0x%x\n" $val
- is_flag_set $val 0x80 "domain$domain_num share cpu capacity flag"
- is_flag_set $val 0x100 "domain$domain_num share power domain flag"
- is_flag_set $val 0x200 "domain$domain_num share cpu package resources flag"
could you use a list of masks to be tested against $val instead of hard coding them ? the number of flags to be tested should increase with eas patchset
Yes, this is a good idea. What is the best (i.e. cleanest/most maintainable/most portable) way of doing this in a shell script?
SD flags are not exported to userspace so we can't scrape them at run-time from /usr/include/linux/sched.h. That would be the most future-proof way of doing it, but would require packaging kernel headers, etc.
Arrays of masks and corresponding strings? I think I remember Lisa telling me that arrays aren't portable as they are not in all shells.
The current implementation isn't very future-proof. If the definition of a flag is missing from the script then it is silently ignored. A better way is to iterate over every bit in the 32-bit flag mask and print out whether that bit is set or unset, and also a human-friendly definition if that is known. But not having the human-readable definition should not exclude the numeric value from being displayed since we might create new flags as Vincent suggested.
In fact, the flag value is already displayed by the script before analysing the bit we are interested in and i'm not sure that we want to display all the flags as some are set out of our control or irrelevant for the test. Nevetheless, we can test the sched_domain flags and compare it with a defined bitmask so we can display a warning if a new unknow flag appears
Yes that sounds good. It allows us to catch new flags but removes the noise from stable flags that we are not interested in. Do you have the bit mask of "stable and uninteresting flags"?
Regards, Mike
Regards
More realistically it looks like all of the current flags fit in the bottom 16 bits of the flag mask, so maybe we can just print the first 16 bits instead of 32. Maybe something like:
for i in $(seq 16); do is_flag_set $val $i; done
Where is_flag_set prints whether bit $i is set or unset in $val. is_flag_set can also maintain the table/array of human-readable flags for well-defined definitions that we consider to be stable/unchanging.
Regards, Mike
Thanks.
Larry
linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev