From: Poornima Nayak <mpnayak@linux.vnet.ibm.com>
To: ltp-list@lists.sourceforge.net, arun@linux.vnet.ibm.com,
svaidy@linux.vnet.ibm.com, ego@in.ibm.com
Subject: [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs
Date: Thu, 24 Dec 2009 23:45:42 +0530 [thread overview]
Message-ID: <20091224181542.12571.16299.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20091224181532.12571.74576.sendpatchset@localhost.localdomain>
Patch to learn topology of system through sysfs.
Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>
diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/power_management/pm_include.sh ltp-intermediate-20091209.fixes/testcases/kernel/power_management/pm_include.sh
--- ltp-intermediate-20091209.orig/testcases/kernel/power_management/pm_include.sh 2009-12-09 13:18:25.000000000 +0530
+++ ltp-intermediate-20091209.fixes/testcases/kernel/power_management/pm_include.sh 2009-12-24 23:17:37.798995821 +0530
@@ -69,9 +69,24 @@ get_supporting_govr() {
}
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 $?
+ entries=`cat /sys/devices/system/cpu/cpu0/topology/thread_siblings`
+ count=`echo $entries | awk -F"," '{ print NF }'`
+ cpucount=0
+ for ((i=1;i<=$count;i++))
+ do
+
+ cpumask=`echo $entries | awk -v x=$i 'BEGIN{FS=","} {print $x}'`
+ while [ $cpumask -gt 0 ]
+ do
+ ((cpucount=cpucount+1))
+ ((cpumask=$cpumask>>1))
+ done
+ done
+ if [ $cpucount -gt 1 ]; then
+ return 0
+ else
+ return 1
+ fi
}
check_input() {
@@ -110,26 +125,38 @@ is_multi_socket() {
[ $no_of_sockets -gt 1 ] ; return $?
}
+get_core_sibling_count() {
+ entries=`cat /sys/devices/system/cpu/cpu0/topology/core_siblings`
+ count=`echo $entries | awk -F"," '{ print NF }'`
+ cpucount=0
+ for ((i=1;i<=$count;i++))
+ do
+ cpumask=`echo $entries | awk -v x=$i 'BEGIN{FS=","} {print $x}'`
+ while [ $cpumask -gt 0 ]
+ do
+ ((cpucount=cpucount+1))
+ ((cpumask=$cpumask>>1))
+ done
+ done
+ echo $cpucount
+}
+
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 $?
- else
- : $(( num_of_cpus = siblings / cpu_cores ))
- [ $num_of_cpus -gt 1 ]; return $?
+ sibling_cnt=$(get_core_sibling_count)
+ if [ $sibling_cnt -gt 1 ]; then
+ return 0
+ else
+ return 1
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':'`
- if [ $siblings -eq $cpu_cores ]; then
- [ $cpu_cores -eq 2 ]; return $?
- else
- : $(( num_of_cpus = siblings / cpu_cores ))
- [ $num_of_cpus -eq 2 ]; return $?
- fi
+ sibling_cnt=$(get_core_sibling_count)
+ if [ $sibling_cnt -eq 2 ]; then
+ return 0
+ else
+ return 1
+ fi
}
get_kernel_version() {
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2009-12-24 18:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-24 18:15 [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power Poornima Nayak
2009-12-24 18:15 ` Poornima Nayak [this message]
2009-12-24 20:11 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Garrett Cooper
2010-01-11 4:25 ` Gautham R Shenoy
2009-12-24 18:15 ` [LTP] [Patch 3/4]Python functions modified to run on Power platform Poornima Nayak
2009-12-24 20:37 ` Garrett Cooper
2010-01-11 4:50 ` Gautham R Shenoy
2009-12-24 18:16 ` [LTP] [Patch 4/4]Readme modified based on review comments Poornima Nayak
2009-12-24 20:04 ` Garrett Cooper
2009-12-24 20:21 ` [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power Garrett Cooper
2010-01-08 7:20 ` Poornima Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091224181542.12571.16299.sendpatchset@localhost.localdomain \
--to=mpnayak@linux.vnet.ibm.com \
--cc=arun@linux.vnet.ibm.com \
--cc=ego@in.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=svaidy@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox