On 27 February 2015 at 01:32, Mike Turquette <mturque...@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.bas...@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 _______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev