On 24 March 2015 at 07:34, Amit Kucheria <amit.kuche...@linaro.org> wrote:
> On Wed, Mar 11, 2015 at 1:08 AM, Larry Bassel <larry.bas...@linaro.org> wrote:
>> On 10 Mar 15 12:30, Lisa Nguyen wrote:
>>> On 3 March 2015 at 13:02, Larry Bassel <larry.bas...@linaro.org> wrote:
>>> >
>>> > Add test which checks and prints scheduler domain flags.
>>> >
>>> > Signed-off-by: Larry Bassel <larry.bas...@linaro.org>
>>> > ---
>>> >  cputopology/cputopology_03.sh  | 109 
>>> > +++++++++++++++++++++++++++++++++++++++++
>>> >  cputopology/cputopology_03.txt |   1 +
>>> >  2 files changed, 110 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..bfff5de
>>> > --- /dev/null
>>> > +++ b/cputopology/cputopology_03.sh
>>> > @@ -0,0 +1,109 @@
>>> > +#!/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.bas...@linaro.org>
>>> > +#
>>> > +
>>> > +# URL : 
>>> > https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/PmQaSpecification#cputopology_03
>>> > +
>>> > +. ../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
>>> > +}
>>> > +
>>> > +are_flags_set() {
>>> > +    val=$1
>>> > +    domain_num=$2
>>> > +
>>> > +    # flag value, flag description
>>> > +    set -- 0x80  "domain$domain_num share cpu capacity flag" 0x100  
>>> > "domain$domain_num share power domain flag" 0x200  "domain$domain_num 
>>> > share cpu package resources flag"
>>> > +
>>> > +    if [ $(($# % 2)) -ne 0 ]; then
>>> > +        echo "WARNING: malformed flag value, description in test"
>>> > +    fi
>>> > +
>>> > +    nflags=$(($# / 2))
>>> > +    i=1
>>> > +
>>> > +    while [ $i -le $nflags ] ; do
>>> > +       flagval=$((2*i-1))
>>> > +        eval "var1=\${$flagval}"
>>> > +       flagstr=$((2*i))
>>> > +        eval "var2=\${$flagstr}"
>>> > +        is_flag_set $val "$var1" "$var2"
>>> > +       i=$(( i + 1))
>>> > +    done
>>> > +}
>>> > +
>>> > +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
>>> > +
>>> > +    mask=$((0x7fff))
>>> > +    unexpected_bits=$((val & ~mask))
>>> > +
>>> > +    if [ $unexpected_bits -ne 0 ]; then
>>> > +        printf "NOTE: unexpected flag bits 0x%x set\n" $unexpected_bits
>>> > +    fi
>>> > +
>>> > +    are_flags_set $val $domain_num
>>> > +}
>>> > +
>>> > +check_all_sched_domain_flags() {
>>> > +
>>> > +    sched_domain_0_path=/proc/sys/kernel/sched_domain/cpu0
>>> > +
>>> > +    if [ ! -d $sched_domain_0_path ]; then
>>> > +        log_skip "no sched_domain directory present"
>>> > +       return
>>> > +    fi
>>> > +
>>> > +    n=0
>>> > +
>>> > +    
>>> > sched_domain_flags_path=/proc/sys/kernel/sched_domain/$1/domain0/flags
>>> > +
>>> > +    while [ -e $sched_domain_flags_path ]; do
>>> > +        check_sched_domain_flags $1 $n
>>> > +       n=$(( n + 1))
>>> > +        
>>> > sched_domain_flags_path=/proc/sys/kernel/sched_domain/$1/domain$n/flags
>>> > +    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
>>> >
>>>
>>> Hi Larry,
>>>
>>> I ran your script on the chromebook2 with mainline v4 quickly, and
>>> these are the results I get:
>>>
>>> root@linaro-developer:~/pm-qa/cputopology# ./cputopology_03.sh
>>> cputopology_03.0/cpu0: checking sched_domain_flags (domain 0)...            
>>> Ok
>>> domain0 flag 0x102f
>>> domain0 share cpu capacity flag not set
>>> domain0 share power domain flag not set
>>> domain0 share cpu package resources flag not set
>>> cputopology_03.0/cpu1: checking sched_domain_flags (domain 0)...            
>>> Ok
>>> domain0 flag 0x102f
>>> domain0 share cpu capacity flag not set
>>> domain0 share power domain flag not set
>>> domain0 share cpu package resources flag not set
>>> cputopology_03.0/cpu2: checking sched_domain_flags (domain 0)...            
>>> Ok
>>> domain0 flag 0x102f
>>> domain0 share cpu capacity flag not set
>>> domain0 share power domain flag not set
>>> domain0 share cpu package resources flag not set
>>> cputopology_03.0/cpu3: checking sched_domain_flags (domain 0)...            
>>> Ok
>>> domain0 flag 0x102f
>>> domain0 share cpu capacity flag not set
>>> domain0 share power domain flag not set
>>> domain0 share cpu package resources flag not set
>>>
>>> cputopology_03: pass
>>>
>>> I'm not sure if printing the domain0 flag is still necessary except
>>> for debugging, but I'll let others comment.
>>
>> I think someone wanted all flags interpreted, personally
>> I think this is overkill since the test IMHO should be focused
>> on flags important to EAS, printing the flag value is a compromise
>> between nothing and full interpretation.
>>
>>>
>>> One question that I may have forgotten to ask you earlier: How did you
>>> define a test failure? AFAICT, I get the impression that the test
>>> "passes" every time, or if it will skip if the sched_domain directory
>>> doesn't exist. I haven't come across an instance where a subtest
>>> fails.
>>
>> Yes, I think the test isn't so much a pass/fail one than an informational
>> one and the person running the test would need to know if the flag
>> settings make sense. Do (any of you) have any better ideas here? Perhaps
>> if the directory doesn't exist it should be a fail (if the EAS patches
>> creating this directory weren't applied or were not working properly,
>> the directory would not exist).
>
> I think the sched_domain directory is always present. Vincent?

It's present only with debug config

>
> I think the power domain flag is the interesting one for EAS but I'll
> defer to Vincent on whether we need to care about the others - e.g. we
> in case of cpu capacity we care about the values they're set to.

We are interested in the 3 flags that are tested by the script: share
capacity,share resources and share power domain
These flags reflect the soc topology

Vincent

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to