public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power
@ 2009-12-24 18:15 Poornima Nayak
  2009-12-24 18:15 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Poornima Nayak @ 2009-12-24 18:15 UTC (permalink / raw)
  To: ltp-list, svaidy, ego, arun

Patch to enable Power management testcases in LTP to run on Power platform

Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>

diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/power_management/runpwtests.sh ltp-intermediate-20091209.fixes/testcases/kernel/power_management/runpwtests.sh
--- ltp-intermediate-20091209.orig/testcases/kernel/power_management/runpwtests.sh	2009-12-09 13:18:25.000000000 +0530
+++ ltp-intermediate-20091209.fixes/testcases/kernel/power_management/runpwtests.sh	2009-12-24 23:16:39.859044825 +0530
@@ -28,10 +28,21 @@
 # History:      26 Aug 2008 - Created this file
 # 03 Nov 2008 - Added CPUIDLE sysfs testcase
 #
+# Function:     main
+#
+# Description:  - Execute all tests, exit with test status.
+#
+# Exit:         - zero on success
+#               - non-zero on failure.
+#
+
+#List of reusable functions defined in pm_include.sh
+. ./pm_include.sh
+
+RC=0            #Return status
 
 # Exporting Required variables
 export TST_TOTAL=1
-#LTPTMP=${TMP}
 export PATH=${PATH}:.
 export TCID="Power_Management"
 export TST_COUNT=0
@@ -40,48 +51,39 @@ export analysis="/proctstat"
 
 YES=0
 NO=1
-#List of reusable functions defined in pm_include.sh
-. ./pm_include.sh
-
-# Function:     main
-#
-# Description:  - Execute all tests, exit with test status.
-#
-# Exit:         - zero on success
-#               - non-zero on failure.
-#
-RC=0		#Return status
 
 # Checking required kernel version and architecture
 tst_kvercmp 2 6 21; rc=$?
 if [ $rc -ne 1 -a $rc -ne 2 ] ; then
-	tst_resm TCONF "Kernel version not supported; not running testcases"
-	exit 0
+        tst_resm TCONF "Kernel version not supported; not running testcases"
+        exit 0
 else
-	case "$(uname -m)" in
-	i[4-6]86|x86_64)
+        case "$(uname -m)" in
+        i[4-6]86|x86_64)
+                ;;
+        powerpc|ppc|powerpc64|ppc64)
 		;;
-	*)
-		tst_resm TCONF "Arch not supported; not running testcases"
-		exit 0
-		;;
-	esac
+        *)
+                tst_resm TCONF "Arch not supported; not running testcases"
+                exit 0
+                ;;
+        esac
 fi
 
 tst_kvercmp 2 6 29; rc=$?
 if [ $rc -eq 2 ] ; then
-	max_sched_mc=2
-	max_sched_smt=2
+        max_sched_mc=2
+        max_sched_smt=2
 else
-	max_sched_mc=1
-	max_sched_smt=1
+        max_sched_mc=1
+        max_sched_smt=1
 fi
 
 tst_kvercmp 2 6 31; rc=$?
 if [ $rc -eq 1 -o $rc -eq 2 ] ; then
-	timer_migr_support_compatible=1
+        timer_migr_support_compatible=0
 else
-	timer_migr_support_compatible=0
+        timer_migr_support_compatible=1
 fi
 
 is_hyper_threaded; hyper_threaded=$?
@@ -90,7 +92,6 @@ is_multi_core; multi_core=$?
 is_dual_core; dual_core=$?
 
 #Checking sched_mc sysfs interface
-#check_config.sh config_sched_mc || RC=$?
 TST_COUNT=1
 if [ $multi_socket -eq $YES -a $multi_core -eq $YES ] ; then
 	if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
@@ -103,6 +104,25 @@ if [ $multi_socket -eq $YES -a $multi_co
 	else
     	tst_resm TCONF "Required kernel configuration for SCHED_MC NOT set"
 	fi
+
+	: $(( TST_COUNT+=1))
+	if [ -f /proc/sys/kernel/timer_migration ]; then
+    	if [ $timer_migr_support_compatible -eq $YES ]; then
+        	if test_timer_migration.sh; then
+            	tst_resm TPASS "Timer Migration interface test"
+        	else
+            	RC=$?
+            	tst_resm TFAIL "Timer migration interface test"
+        	fi
+    	fi
+	else
+    	if [ $supp -eq $YES ]; then
+        	RC=$?
+        	tst_resm TFAIL "Timer migration interface missing"
+		else
+        	tst_resm TCONF "Kernel version does not support Timer migration"
+		fi
+	fi
 else
 	if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
 		tst_resm TFAIL "sched_mc_power_savings interface in system which is not a multi socket &(/) multi core"
@@ -135,7 +155,6 @@ else
 fi
 
 # Checking cpufreq sysfs interface files
-#check_config.sh config_cpu_freq || RC=$?
 : $(( TST_COUNT += 1 ))
 if [ -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
     if check_cpufreq_sysfs_files.sh; then
@@ -187,12 +206,13 @@ else
 fi
 
 # sched_domain test
-if ! type python > /dev/null ; then
+which python > /dev/null
+if [ $? -ne 0 ] ; then
 	tst_resm TCONF "Python is not installed, CPU Consoldation\
 test cannot run"
 else
 	if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
-    		echo "max sched mc $max_sched_mc"
+		get_sched_values sched_mc; max_sched_mc=$?
 		for sched_mc in `seq 0 $max_sched_mc`; do
 			: $(( TST_COUNT+=1))
 			sched_domain.py -c $sched_mc; RC=$?
@@ -210,25 +230,6 @@ else
 	fi
 fi
 
-: $(( TST_COUNT+=1))
-if [ -f /proc/sys/kernel/timer_migration ]; then
-	if [ $timer_migr_support_compatible -eq $YES ]; then
-		if test_timer_migration.sh; then
-        	tst_resm TPASS "Timer Migration interface test"
-    	else
-        	RC=$?
-        	tst_resm TFAIL "Timer migration interface test"
-		fi
-	fi
-else
-	if [ $timer_migr_support_compatible -eq $YES ]; then
-		RC=$?
-		tst_resm TFAIL "Timer migration interface missing"
-	else
-		tst_resm TCONF "Kernel version does not support Timer migration"
-	fi
-fi
-
 if [ $# -gt 0 -a "$1" = "-exclusive" ]; then 
 	# Test CPU consolidation 
 	if [ $multi_socket -eq $YES -a $multi_core -eq $YES ]; then
@@ -266,7 +267,7 @@ if [ $# -gt 0 -a "$1" = "-exclusive" ]; 
 
 	fi
 
-	if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES -a $multi_core -eq $NO ]; then
+	if [ $hyper_threaded -eq $YES ]; then
 			#Testcase to validate consolidation at core level
 			for sched_smt in `seq 0 $max_sched_smt`; do
 				if [ $sched_smt -eq 2 ]; then
@@ -319,7 +320,7 @@ if [ $# -gt 0 -a "$1" = "-exclusive" ]; 
 	fi
 
     # Verify threads consolidation stops when sched_smt is disabled in HT systems
-	if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES ]; then
+	if [ $hyper_threaded -eq $YES ]; then
 		# Vary only sched_smt from 1 to 0 when workload is running and ensure that
 		# tasks do not consolidate to single core when sched_smt is set to 0
 		: $(( TST_COUNT += 1 ))

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs
  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
  2009-12-24 20:11   ` 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
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Poornima Nayak @ 2009-12-24 18:15 UTC (permalink / raw)
  To: ltp-list, arun, svaidy, ego

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [Patch 3/4]Python functions modified to run on Power platform
  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 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
@ 2009-12-24 18:15 ` 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:21 ` [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power Garrett Cooper
  3 siblings, 2 replies; 11+ messages in thread
From: Poornima Nayak @ 2009-12-24 18:15 UTC (permalink / raw)
  To: ltp-list, svaidy, ego, arun

Patch to learn topology information from sysfs. 
Incorporated Gautham's comments to improve maintainence of the code.

Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>

diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/power_management/lib/sched_mc.py ltp-intermediate-20091209.fixes/testcases/kernel/power_management/lib/sched_mc.py
--- ltp-intermediate-20091209.orig/testcases/kernel/power_management/lib/sched_mc.py	2009-12-09 13:18:25.000000000 +0530
+++ ltp-intermediate-20091209.fixes/testcases/kernel/power_management/lib/sched_mc.py	2009-12-24 23:14:23.712098662 +0530
@@ -24,6 +24,12 @@ cpu2_max_intr = 0
 intr_stat_timer_0 = []
 siblings_list = []
 
+# Define thresholds for CPU consolidation
+THRES_HT_KERNBENCH=40
+THRES_HT=40
+THRES_KERNBENCH=50
+THRES_EBIZZY=70
+
 def clear_dmesg():
     '''
        Clears dmesg
@@ -65,6 +71,42 @@ def count_num_sockets():
         print "INFO: Failed to get number of sockets in system", details
         sys.exit(1)
 
+def get_hyper_thread_count():
+    ''' Return number of threads in cpu0
+    '''
+    try:
+        file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/thread_siblings", 'r')
+        threads_count = 0
+        for line in file_cpuinfo:
+            core_grps = line.split(",")
+            for i in range(0, len(core_grps)):
+                cpumask=int(core_grps[i])
+                while cpumask > 0:
+                    threads_count = threads_count + 1
+                    cpumask = cpumask >> 1
+        return threads_count
+    except Exception, details:
+        print "INFO: Failed to get threaded siblings count", details
+        sys.exit(1)
+
+def get_core_sibling_count():
+    ''' Return number of threads in cpu0
+    '''
+    try:
+        file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/core_siblings", 'r')
+        cores_count = 0
+        for line in file_cpuinfo:
+            core_grps = line.split(",")
+            for i in range(0, len(core_grps)):
+                cpumask=int(core_grps[i])
+                while cpumask > 0:
+                    cores_count = cores_count + 1
+                    cpumask = cpumask >> 1
+        return cores_count
+    except Exception, details:
+        print "INFO: Failed to get core siblings count", details
+        sys.exit(1)
+
 def is_multi_socket():
     '''Return 1 if the system is multi socket else return 0
     '''
@@ -81,15 +123,8 @@ def is_hyper_threaded():
     '''Return 1 if the system is hyper threaded else return 0
     '''
     try:
-        file_cpuinfo = open("/proc/cpuinfo", 'r')
-        for line in file_cpuinfo:
-            if line.startswith('siblings'):
-                siblings = line.split(":")
-            if line.startswith('cpu cores'):
-                cpu_cores = line.split(":")
-                break
-        if int( siblings[1] ) / int( cpu_cores[1] )> 1:
-            file_cpuinfo.close()
+        threads_count = get_hyper_thread_count()
+        if threads_count > 1:
             return 1
         else:
             return 0
@@ -98,53 +133,33 @@ def is_hyper_threaded():
         sys.exit(1)
 
 def is_multi_core():
-    ''' Return true if system has sockets has multiple cores
+    ''' Return true if system has sockets with multiple cores
     '''
   
     try:
-        file_cpuinfo = open("/proc/cpuinfo", 'r')
-        for line in file_cpuinfo:
-            if line.startswith('siblings'):
-                siblings = line.split(":")
-            if line.startswith('cpu cores'):
-                cpu_cores = line.split(":")
-                break
-       
-        if int( siblings[1] ) == int( cpu_cores[1] ): 
-            if int( cpu_cores[1] ) > 1:
-                multi_core = 1
-            else:
-                multi_core = 0
+        cores_count = get_core_sibling_count()
+        if cores_count > 1:
+            return 1
         else:
-            num_of_cpus = int(siblings[1]) / int(cpu_cores[1])
-            if num_of_cpus > 1:
-                multi_core = 1
-            else:
-                multi_core = 0
-        file_cpuinfo.close()
-        return multi_core
+            return 0
     except Exception:
         print "Failed to check if system is multi core system"
         sys.exit(1)
 
-def get_hyper_thread_count():
-    ''' Return number of threads in CPU. For eg for x3950 this function
-        would return 2. In future if 4 threads are supported in CPU, this
-        routine would return 4
+def is_quad_core():
+    '''
+       Read sys topology info and check if system is Quad core
     '''
     try:
-        file_cpuinfo = open("/proc/cpuinfo", 'r')
-        for line in file_cpuinfo:
-            if line.startswith('siblings'):
-                siblings = line.split(":")
-            if line.startswith('cpu cores'):
-                cpu_cores = line.split(":")
-                break
-        return( int( siblings[1] ) / int( cpu_cores[1] ) )
-    except Exception:
-        print "Failed to check if system is hyper-threaded"
+        cpu_cores = get_core_sibling_count()
+        if cpu_cores == 4:
+            return(1)
+        else:
+            return(0)
+    except IOError, e:
+        print "Failed in function to check if system is quad core", e
         sys.exit(1)
-         
+
 def map_cpuid_pkgid():
     ''' Routine to map physical package id to cpu id
     '''
@@ -190,10 +205,21 @@ def generate_sibling_list():
     try:
         for i in range(0, cpu_count):
             siblings_file = '/sys/devices/system/cpu/cpu%s' % i
-            siblings_file += '/topology/thread_siblings_list'
-            threads_sibs = open(siblings_file).read().rstrip()
-            thread_ids = threads_sibs.split("-")
-    
+            siblings_file += '/topology/thread_siblings'
+            threads_sibs = open(siblings_file).read().split(",")
+            thread_ids = []
+            cpu_id=0
+            mask=1
+            
+            for j in range(len(threads_sibs)-1, 0, -1):
+                for k in range(0, 8):
+                    mask_bit_set=mask & int(threads_sibs[j],16)
+                    if mask_bit_set != 0:
+                        if not cpu_id in thread_ids:
+                            thread_ids.append(cpu_id)
+                    mask = mask << 1
+                    cpu_id += 1
+
             if not thread_ids in siblings_list:
                 siblings_list.append(thread_ids)
     except Exception, details:
@@ -211,7 +237,7 @@ def get_siblings(cpu_id):
                     for j in siblings_list[i]:
                         # Exclude cpu_id in the list of siblings
                         if j != cpu_id:
-                            cpus += j
+                            cpus += str(j)
                     return cpus
         return cpus
     except Exception, details:
@@ -276,17 +302,6 @@ def set_sched_smt_power(sched_smt_level)
         print "Could not set sched_smt_power_savings to", sched_smt_level, e
 	sys.exit(1)
 
-def set_timer_migration_interface(value):
-    ''' Set value of timer migration interface to a value
-        passed as argument
-    '''
-    try:
-        os.system('echo %s > \
-            /proc/sys/kernel/timer_migration 2>/dev/null' % value)
-    except OSError, e:
-        print "Could not set timer_migration to ", value, e
-        sys.exit(1)
-
 def get_job_count(stress, workload, sched_smt):
     ''' Returns number of jobs/threads to be triggered
     '''
@@ -585,25 +600,6 @@ def expand_range(range_val):
     except Exception, details:
         print "INFO: expand_pkg_grps failed ", details
 
-def is_quad_core():
-    '''
-       Read /proc/cpuinfo and check if system is Quad core
-    '''
-    try:
-        cpuinfo = open('/proc/cpuinfo', 'r')
-        for line in cpuinfo:
-            if line.startswith('cpu cores'):
-                cores = line.split("cpu cores")
-                num_cores = cores[1].split(":")
-                cpuinfo.close()
-                if int(num_cores[1]) == 4:
-                    return(1)
-                else:
-                    return(0)
-    except IOError, e:
-        print "Failed to get cpu core information", e
-        sys.exit(1)
-
 def validate_cpugrp_map(cpu_group, sched_mc_level, sched_smt_level):
     '''
        Verify if cpugrp belong to same package
@@ -612,7 +608,7 @@ def validate_cpugrp_map(cpu_group, sched
     try:
         if is_hyper_threaded():
             for pkg in sorted(cpu_map.keys()):
-                # if CPU utilized is across package this condition will be true
+            # if CPU utilized is across package this condition will be true
                 if len(modi_cpu_grp) != len(cpu_group):
                     break
                 for core in sorted(cpu_map[pkg].keys()):
@@ -724,21 +720,21 @@ def validate_cpu_consolidation(stress, w
                             utilization += int(get_cpu_utilization("cpu%s" %sib_list[i])) 
                     else:
                         utilization = stats_percentage[l][1]
-                    if utilization > 40:
+                    if utilization > THRES_HT_KERNBENCH:
                         cpus_utilized.append(int(cpu_id[1]))
                         if siblings != "":
                             for i in range(0, len(sib_list)):
                                 cpus_utilized.append(int(sib_list[i]))
                 else:
                     # This threshold wuld be modified based on results
-                    if stats_percentage[l][1] > 40:
+                    if stats_percentage[l][1] > THRES_HT:
                         cpus_utilized.append(int(cpu_id[1]))
             else:
                 if work_ld == "kernbench" :
-                    if stats_percentage[l][1] > 50:
+                    if stats_percentage[l][1] > THRES_KERNBENCH:
                         cpus_utilized.append(int(cpu_id[1]))
                 else:
-                    if stats_percentage[l][1] > 70:
+                    if stats_percentage[l][1] > THRES_EBIZZY:
                         cpus_utilized.append(int(cpu_id[1]))
             cpus_utilized.sort()
         print "INFO: CPU's utilized ", cpus_utilized

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [Patch 4/4]Readme modified based on review comments
  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 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
  2009-12-24 18:15 ` [LTP] [Patch 3/4]Python functions modified to run on Power platform Poornima Nayak
@ 2009-12-24 18:16 ` 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
  3 siblings, 1 reply; 11+ messages in thread
From: Poornima Nayak @ 2009-12-24 18:16 UTC (permalink / raw)
  To: ltp-list, arun, svaidy, ego

Patch to update readme with information on how to use Power management testcases
to test consolidation testcases.

Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>

diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/power_management/README ltp-intermediate-20091209.fixes/testcases/kernel/power_management/README
--- ltp-intermediate-20091209.orig/testcases/kernel/power_management/README	2009-12-09 13:18:25.000000000 +0530
+++ ltp-intermediate-20091209.fixes/testcases/kernel/power_management/README	2009-12-24 23:12:55.293026448 +0530
@@ -77,6 +77,8 @@ Power Management    1  FAIL  :  Required
 
 Then either configuration is not set or the system won't support.
 
+Command to test CPU consolidation & ILB testcases on any system syntax is 'runltp -f power_management_tests_exclusive'. CPU consolidation testcases has to be triggered on a system which is totally idle i.e do not execute exclusive testcases on KVM/xen test setup. 
+
 For CPU consolidation verification ebizzy is included in utils directory of LTP.
 To run cpu consolidation test user has to provide -w <workload> -l <sched_mc_level>.
 Refer to README in LTPROOT/utils/benchmark/ebizzy-0.2 directory for details of ebizzy.
@@ -84,4 +86,6 @@ Refer to README in LTPROOT/utils/benchma
 To test CPU consolidation for sched_mc 2 kernbench has to run. Kernbench needs linux kernel source as input in /root directory . For example download from http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.4.tar.bz2. If Linux kernel source not found kernbench wiil  not execute.
 CPU consolidation testcases will not execute if number of CPU's in package is less then 2. If system is hyper threaded but number of CPU is 1 only sched_smt testcases will be excuted. For better coverage of testcases select a system which is atleast quad core and then hyper threaded so that you will observe 8 CPU's in each package.
 
-Timer migration interface test will execute on kernel versions 2.6.31 and above. Timer migration functionality verification testcases will be executed only on suitable architecture like quad core or the number of CPU's in each package should be atleast 4 and above
+Timer migration interface test will execute on kernel versions 2.6.31 and above. 
+
+On Power platform sched_smt & cpu_idle testcases will be executed.

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 4/4]Readme modified based on review comments
  2009-12-24 18:16 ` [LTP] [Patch 4/4]Readme modified based on review comments Poornima Nayak
@ 2009-12-24 20:04   ` Garrett Cooper
  0 siblings, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2009-12-24 20:04 UTC (permalink / raw)
  To: Poornima Nayak
  Cc: ltp-list@lists.sourceforge.net, svaidy@linux.vnet.ibm.com,
	ego@in.ibm.com, arun@linux.vnet.ibm.com

On Dec 24, 2009, at 10:16 AM, Poornima Nayak  
<mpnayak@linux.vnet.ibm.com> wrote:

> Patch to update readme with information on how to use Power  
> management testcases
> to test consolidation testcases.
>
> Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>
>
> diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/ 
> power_management/README ltp-intermediate-20091209.fixes/testcases/ 
> kernel/power_management/README
> --- ltp-intermediate-20091209.orig/testcases/kernel/power_management/ 
> README    2009-12-09 13:18:25.000000000 +0530
> +++ ltp-intermediate-20091209.fixes/testcases/kernel/ 
> power_management/README    2009-12-24 23:12:55.293026448 +0530
> @@ -77,6 +77,8 @@ Power Management    1  FAIL  :  Required
>
> Then either configuration is not set or the system won't support.
>
> +Command to test CPU consolidation & ILB testcases on any system  
> syntax is 'runltp -f power_management_tests_exclusive'. CPU  
> consolidation testcases has to be triggered on a system which is  
> totally idle i.e do not execute exclusive testcases on KVM/xen test  
> setup.
> +
> For CPU consolidation verification ebizzy is included in utils  
> directory of LTP.
> To run cpu consolidation test user has to provide -w <workload> -l  
> <sched_mc_level>.
> Refer to README in LTPROOT/utils/benchmark/ebizzy-0.2 directory for  
> details of ebizzy.

This is 0.3 now.

> @@ -84,4 +86,6 @@ Refer to README in LTPROOT/utils/benchma
> To test CPU consolidation for sched_mc 2 kernbench has to run.  
> Kernbench needs linux kernel source as input in /root directory .  
> For example download from http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.4.tar.bz2 
> . If Linux kernel source not found kernbench wiil  not execute.
> CPU consolidation testcases will not execute if number of CPU's in  
> package is less then 2. If system is hyper threaded but number of  
> CPU is 1 only sched_smt testcases will be excuted. For better  
> coverage of testcases select a system which is atleast quad core and  
> then hyper threaded so that you will observe 8 CPU's in each package.
>
> -Timer migration interface test will execute on kernel versions  
> 2.6.31 and above. Timer migration functionality verification  
> testcases will be executed only on suitable architecture like quad  
> core or the number of CPU's in each package should be atleast 4 and  
> above
> +Timer migration interface test will execute on kernel versions  
> 2.6.31 and above.
> +
> +On Power platform sched_smt & cpu_idle testcases will be executed.
>
> --- 
> --- 
> --- 
> ---------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs
  2009-12-24 18:15 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
@ 2009-12-24 20:11   ` Garrett Cooper
  2010-01-11  4:25   ` Gautham R Shenoy
  1 sibling, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2009-12-24 20:11 UTC (permalink / raw)
  To: Poornima Nayak
  Cc: ltp-list@lists.sourceforge.net, svaidy@linux.vnet.ibm.com,
	ego@in.ibm.com, arun@linux.vnet.ibm.com

On Dec 24, 2009, at 10:15 AM, Poornima Nayak  
<mpnayak@linux.vnet.ibm.com> wrote:

> 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 }'`

Why have an intermediate variable labeled entries if all you do is  
echo the value back out and run it through awk unquoted? You could  
just as easily do this instead:

awk [options] [script-body] /sys/devices/system/cpu/cpu0/topology/ 
thread_siblings

> +    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() {

Thanks,
-Garrett

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power
  2009-12-24 18:15 [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power Poornima Nayak
                   ` (2 preceding siblings ...)
  2009-12-24 18:16 ` [LTP] [Patch 4/4]Readme modified based on review comments Poornima Nayak
@ 2009-12-24 20:21 ` Garrett Cooper
  2010-01-08  7:20   ` Poornima Nayak
  3 siblings, 1 reply; 11+ messages in thread
From: Garrett Cooper @ 2009-12-24 20:21 UTC (permalink / raw)
  To: Poornima Nayak
  Cc: ltp-list@lists.sourceforge.net, arun@linux.vnet.ibm.com,
	svaidy@linux.vnet.ibm.com, ego@in.ibm.com

On Dec 24, 2009, at 10:15 AM, Poornima Nayak  
<mpnayak@linux.vnet.ibm.com> wrote:

> Patch to enable Power management testcases in LTP to run on Power  
> platform
>
> Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>
>
> diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/ 
> power_management/runpwtests.sh ltp-intermediate-20091209.fixes/ 
> testcases/kernel/power_management/runpwtests.sh
> --- ltp-intermediate-20091209.orig/testcases/kernel/power_management/ 
> runpwtests.sh    2009-12-09 13:18:25.000000000 +0530
> +++ ltp-intermediate-20091209.fixes/testcases/kernel/ 
> power_management/runpwtests.sh    2009-12-24 23:16:39.859044825 +0530
> @@ -28,10 +28,21 @@
> # History:      26 Aug 2008 - Created this file
> # 03 Nov 2008 - Added CPUIDLE sysfs testcase
> #
> +# Function:     main
> +#
> +# Description:  - Execute all tests, exit with test status.
> +#
> +# Exit:         - zero on success
> +#               - non-zero on failure.
> +#
> +
> +#List of reusable functions defined in pm_include.sh
> +. ./pm_include.sh
> +
> +RC=0            #Return status
>
> # Exporting Required variables
> export TST_TOTAL=1
> -#LTPTMP=${TMP}
> export PATH=${PATH}:.
> export TCID="Power_Management"
> export TST_COUNT=0
> @@ -40,48 +51,39 @@ export analysis="/proctstat"
>
> YES=0
> NO=1
> -#List of reusable functions defined in pm_include.sh
> -. ./pm_include.sh
> -
> -# Function:     main
> -#
> -# Description:  - Execute all tests, exit with test status.
> -#
> -# Exit:         - zero on success
> -#               - non-zero on failure.
> -#
> -RC=0        #Return status
>
> # Checking required kernel version and architecture
> tst_kvercmp 2 6 21; rc=$?
> if [ $rc -ne 1 -a $rc -ne 2 ] ; then
> -    tst_resm TCONF "Kernel version not supported; not running  
> testcases"
> -    exit 0
> +        tst_resm TCONF "Kernel version not supported; not running  
> testcases"
> +        exit 0
> else
> -    case "$(uname -m)" in
> -    i[4-6]86|x86_64)
> +        case "$(uname -m)" in
> +        i[4-6]86|x86_64)
> +                ;;
> +        powerpc|ppc|powerpc64|ppc64)
>        ;;
> -    *)
> -        tst_resm TCONF "Arch not supported; not running testcases"
> -        exit 0
> -        ;;
> -    esac
> +        *)
> +                tst_resm TCONF "Arch not supported; not running  
> testcases"
> +                exit 0
> +                ;;
> +        esac
> fi
>
> tst_kvercmp 2 6 29; rc=$?
> if [ $rc -eq 2 ] ; then
> -    max_sched_mc=2
> -    max_sched_smt=2
> +        max_sched_mc=2
> +        max_sched_smt=2
> else
> -    max_sched_mc=1
> -    max_sched_smt=1
> +        max_sched_mc=1
> +        max_sched_smt=1
> fi
>
> tst_kvercmp 2 6 31; rc=$?
> if [ $rc -eq 1 -o $rc -eq 2 ] ; then
> -    timer_migr_support_compatible=1
> +        timer_migr_support_compatible=0
> else
> -    timer_migr_support_compatible=0
> +        timer_migr_support_compatible=1
> fi

Why did you invert the logic here? $? => 0 says the kernel version is  
less, 1 that it's equal, and 2 that it's greater than the version  
specified.

> is_hyper_threaded; hyper_threaded=$?
> @@ -90,7 +92,6 @@ is_multi_core; multi_core=$?
> is_dual_core; dual_core=$?
>
> #Checking sched_mc sysfs interface
> -#check_config.sh config_sched_mc || RC=$?
> TST_COUNT=1
> if [ $multi_socket -eq $YES -a $multi_core -eq $YES ] ; then
>    if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
> @@ -103,6 +104,25 @@ if [ $multi_socket -eq $YES -a $multi_co
>    else
>         tst_resm TCONF "Required kernel configuration for SCHED_MC  
> NOT set"
>    fi
> +
> +    : $(( TST_COUNT+=1))
> +    if [ -f /proc/sys/kernel/timer_migration ]; then
> +        if [ $timer_migr_support_compatible -eq $YES ]; then
> +            if test_timer_migration.sh; then
> +                tst_resm TPASS "Timer Migration interface test"
> +            else
> +                RC=$?
> +                tst_resm TFAIL "Timer migration interface test"
> +            fi
> +        fi
> +    else
> +        if [ $supp -eq $YES ]; then
> +            RC=$?
> +            tst_resm TFAIL "Timer migration interface missing"
> +        else
> +            tst_resm TCONF "Kernel version does not support Timer  
> migration"
> +        fi
> +    fi
> else
>    if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
>        tst_resm TFAIL "sched_mc_power_savings interface in system  
> which is not a multi socket &(/) multi core"
> @@ -135,7 +155,6 @@ else
> fi
>
> # Checking cpufreq sysfs interface files
> -#check_config.sh config_cpu_freq || RC=$?
> : $(( TST_COUNT += 1 ))
> if [ -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
>     if check_cpufreq_sysfs_files.sh; then
> @@ -187,12 +206,13 @@ else
> fi
>
> # sched_domain test
> -if ! type python > /dev/null ; then
> +which python > /dev/null
> +if [ $? -ne 0 ] ; then

type is a bourne shell builtin whereas which is a command.  
Furthermore, you  can inline shell true / false checks in branch  
conditionals. So why did you revert this?

>    tst_resm TCONF "Python is not installed, CPU Consoldation\
> test cannot run"
> else
>    if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
> -            echo "max sched mc $max_sched_mc"
> +        get_sched_values sched_mc; max_sched_mc=$?
>        for sched_mc in `seq 0 $max_sched_mc`; do
>            : $(( TST_COUNT+=1))
>            sched_domain.py -c $sched_mc; RC=$?
> @@ -210,25 +230,6 @@ else
>    fi
> fi
>
> -: $(( TST_COUNT+=1))
> -if [ -f /proc/sys/kernel/timer_migration ]; then
> -    if [ $timer_migr_support_compatible -eq $YES ]; then
> -        if test_timer_migration.sh; then
> -            tst_resm TPASS "Timer Migration interface test"
> -        else
> -            RC=$?
> -            tst_resm TFAIL "Timer migration interface test"
> -        fi
> -    fi
> -else
> -    if [ $timer_migr_support_compatible -eq $YES ]; then
> -        RC=$?
> -        tst_resm TFAIL "Timer migration interface missing"
> -    else
> -        tst_resm TCONF "Kernel version does not support Timer  
> migration"
> -    fi
> -fi
> -
> if [ $# -gt 0 -a "$1" = "-exclusive" ]; then

Sorry for not noticing this sooner. $1 and -exclusive should be  
prefixed by a character, e.g. x or this will be reported as a [(1)  
syntax error.

>
>    # Test CPU consolidation
>    if [ $multi_socket -eq $YES -a $multi_core -eq $YES ]; then
> @@ -266,7 +267,7 @@ if [ $# -gt 0 -a "$1" = "-exclusive" ];
>
>    fi
>
> -    if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES -a  
> $multi_core -eq $NO ]; then
> +    if [ $hyper_threaded -eq $YES ]; then
>            #Testcase to validate consolidation at core level
>            for sched_smt in `seq 0 $max_sched_smt`; do
>                if [ $sched_smt -eq 2 ]; then
> @@ -319,7 +320,7 @@ if [ $# -gt 0 -a "$1" = "-exclusive" ];
>    fi
>
>     # Verify threads consolidation stops when sched_smt is disabled  
> in HT systems
> -    if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES ]; then
> +    if [ $hyper_threaded -eq $YES ]; then
>        # Vary only sched_smt from 1 to 0 when workload is running  
> and ensure that
>        # tasks do not consolidate to single core when sched_smt is  
> set to 0
>        : $(( TST_COUNT += 1 ))

Thanks,
-Garrett

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 3/4]Python functions modified to run on Power platform
  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
  1 sibling, 0 replies; 11+ messages in thread
From: Garrett Cooper @ 2009-12-24 20:37 UTC (permalink / raw)
  To: Poornima Nayak
  Cc: ltp-list@lists.sourceforge.net, arun@linux.vnet.ibm.com,
	svaidy@linux.vnet.ibm.com, ego@in.ibm.com

On Dec 24, 2009, at 10:15 AM, Poornima Nayak  
<mpnayak@linux.vnet.ibm.com> wrote:

> Patch to learn topology information from sysfs.
> Incorporated Gautham's comments to improve maintainence of the code.
>
> Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>
>
> diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/ 
> power_management/lib/sched_mc.py ltp-intermediate-20091209.fixes/ 
> testcases/kernel/power_management/lib/sched_mc.py
> --- ltp-intermediate-20091209.orig/testcases/kernel/power_management/ 
> lib/sched_mc.py    2009-12-09 13:18:25.000000000 +0530
> +++ ltp-intermediate-20091209.fixes/testcases/kernel/ 
> power_management/lib/sched_mc.py    2009-12-24 23:14:23.712098662  
> +0530
> @@ -24,6 +24,12 @@ cpu2_max_intr = 0
> intr_stat_timer_0 = []
> siblings_list = []
>
> +# Define thresholds for CPU consolidation
> +THRES_HT_KERNBENCH=40
> +THRES_HT=40
> +THRES_KERNBENCH=50
> +THRES_EBIZZY=70
> +
> def clear_dmesg():
>     '''
>        Clears dmesg
> @@ -65,6 +71,42 @@ def count_num_sockets():
>         print "INFO: Failed to get number of sockets in system",  
> details
>         sys.exit(1)
>
> +def get_hyper_thread_count():
> +    ''' Return number of threads in cpu0
> +    '''
> +    try:
> +        file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/ 
> thread_siblings", 'r')
> +        threads_count = 0
> +        for line in file_cpuinfo:
> +            core_grps = line.split(",")
> +            for i in range(0, len(core_grps)):
> +                cpumask=int(core_grps[i])
> +                while cpumask > 0:
> +                    threads_count = threads_count + 1
> +                    cpumask = cpumask >> 1
> +        return threads_count
> +    except Exception, details:
> +        print "INFO: Failed to get threaded siblings count", details
> +        sys.exit(1)
> +
> +def get_core_sibling_count():
> +    ''' Return number of threads in cpu0
> +    '''
> +    try:
> +        file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/ 
> core_siblings", 'r')
> +        cores_count = 0
> +        for line in file_cpuinfo:
> +            core_grps = line.split(",")
> +            for i in range(0, len(core_grps)):
> +                cpumask=int(core_grps[i])
> +                while cpumask > 0:
> +                    cores_count = cores_count + 1
> +                    cpumask = cpumask >> 1
> +        return cores_count
> +    except Exception, details:
> +        print "INFO: Failed to get core siblings count", details
> +        sys.exit(1)
> +
> def is_multi_socket():
>     '''Return 1 if the system is multi socket else return 0
>     '''
> @@ -81,15 +123,8 @@ def is_hyper_threaded():
>     '''Return 1 if the system is hyper threaded else return 0
>     '''
>     try:
> -        file_cpuinfo = open("/proc/cpuinfo", 'r')
> -        for line in file_cpuinfo:
> -            if line.startswith('siblings'):
> -                siblings = line.split(":")
> -            if line.startswith('cpu cores'):
> -                cpu_cores = line.split(":")
> -                break
> -        if int( siblings[1] ) / int( cpu_cores[1] )> 1:
> -            file_cpuinfo.close()
> +        threads_count = get_hyper_thread_count()
> +        if threads_count > 1:
>             return 1
>         else:
>             return 0
> @@ -98,53 +133,33 @@ def is_hyper_threaded():
>         sys.exit(1)
>
> def is_multi_core():
> -    ''' Return true if system has sockets has multiple cores
> +    ''' Return true if system has sockets with multiple cores
>     '''
>
>     try:
> -        file_cpuinfo = open("/proc/cpuinfo", 'r')
> -        for line in file_cpuinfo:
> -            if line.startswith('siblings'):
> -                siblings = line.split(":")
> -            if line.startswith('cpu cores'):
> -                cpu_cores = line.split(":")
> -                break
> -
> -        if int( siblings[1] ) == int( cpu_cores[1] ):
> -            if int( cpu_cores[1] ) > 1:
> -                multi_core = 1
> -            else:
> -                multi_core = 0
> +        cores_count = get_core_sibling_count()
> +        if cores_count > 1:
> +            return 1
>         else:
> -            num_of_cpus = int(siblings[1]) / int(cpu_cores[1])
> -            if num_of_cpus > 1:
> -                multi_core = 1
> -            else:
> -                multi_core = 0
> -        file_cpuinfo.close()
> -        return multi_core
> +            return 0
>     except Exception:
>         print "Failed to check if system is multi core system"
>         sys.exit(1)
>
> -def get_hyper_thread_count():
> -    ''' Return number of threads in CPU. For eg for x3950 this  
> function
> -        would return 2. In future if 4 threads are supported in  
> CPU, this
> -        routine would return 4
> +def is_quad_core():
> +    '''
> +       Read sys topology info and check if system is Quad core
>     '''
>     try:
> -        file_cpuinfo = open("/proc/cpuinfo", 'r')
> -        for line in file_cpuinfo:
> -            if line.startswith('siblings'):
> -                siblings = line.split(":")
> -            if line.startswith('cpu cores'):
> -                cpu_cores = line.split(":")
> -                break
> -        return( int( siblings[1] ) / int( cpu_cores[1] ) )
> -    except Exception:
> -        print "Failed to check if system is hyper-threaded"
> +        cpu_cores = get_core_sibling_count()
> +        if cpu_cores == 4:
> +            return(1)
> +        else:
> +            return(0)
> +    except IOError, e:
> +        print "Failed in function to check if system is quad core", e
>         sys.exit(1)
> -
> +
> def map_cpuid_pkgid():
>     ''' Routine to map physical package id to cpu id
>     '''
> @@ -190,10 +205,21 @@ def generate_sibling_list():
>     try:
>         for i in range(0, cpu_count):
>             siblings_file = '/sys/devices/system/cpu/cpu%s' % i
> -            siblings_file += '/topology/thread_siblings_list'
> -            threads_sibs = open(siblings_file).read().rstrip()
> -            thread_ids = threads_sibs.split("-")
> -
> +            siblings_file += '/topology/thread_siblings'
> +            threads_sibs = open(siblings_file).read().split(",")

Leaked filehandle?

> +            thread_ids = []
> +            cpu_id=0
> +            mask=1
> +
> +            for j in range(len(threads_sibs)-1, 0, -1):
> +                for k in range(0, 8):
> +                    mask_bit_set=mask & int(threads_sibs[j],16)
> +                    if mask_bit_set != 0:
> +                        if not cpu_id in thread_ids:
> +                            thread_ids.append(cpu_id)
> +                    mask = mask << 1
> +                    cpu_id += 1
> +
>             if not thread_ids in siblings_list:
>                 siblings_list.append(thread_ids)
>     except Exception, details:
> @@ -211,7 +237,7 @@ def get_siblings(cpu_id):
>                     for j in siblings_list[i]:
>                         # Exclude cpu_id in the list of siblings
>                         if j != cpu_id:
> -                            cpus += j
> +                            cpus += str(j)
>                     return cpus
>         return cpus
>     except Exception, details:
> @@ -276,17 +302,6 @@ def set_sched_smt_power(sched_smt_level)
>         print "Could not set sched_smt_power_savings to",  
> sched_smt_level, e
>    sys.exit(1)
>
> -def set_timer_migration_interface(value):
> -    ''' Set value of timer migration interface to a value
> -        passed as argument
> -    '''
> -    try:
> -        os.system('echo %s > \
> -            /proc/sys/kernel/timer_migration 2>/dev/null' % value)
> -    except OSError, e:
> -        print "Could not set timer_migration to ", value, e
> -        sys.exit(1)
> -
> def get_job_count(stress, workload, sched_smt):
>     ''' Returns number of jobs/threads to be triggered
>     '''
> @@ -585,25 +600,6 @@ def expand_range(range_val):
>     except Exception, details:
>         print "INFO: expand_pkg_grps failed ", details
>
> -def is_quad_core():
> -    '''
> -       Read /proc/cpuinfo and check if system is Quad core
> -    '''
> -    try:
> -        cpuinfo = open('/proc/cpuinfo', 'r')
> -        for line in cpuinfo:
> -            if line.startswith('cpu cores'):
> -                cores = line.split("cpu cores")
> -                num_cores = cores[1].split(":")
> -                cpuinfo.close()
> -                if int(num_cores[1]) == 4:
> -                    return(1)
> -                else:
> -                    return(0)
> -    except IOError, e:
> -        print "Failed to get cpu core information", e
> -        sys.exit(1)
> -
> def validate_cpugrp_map(cpu_group, sched_mc_level, sched_smt_level):
>     '''
>        Verify if cpugrp belong to same package
> @@ -612,7 +608,7 @@ def validate_cpugrp_map(cpu_group, sched
>     try:
>         if is_hyper_threaded():
>             for pkg in sorted(cpu_map.keys()):
> -                # if CPU utilized is across package this condition  
> will be true
> +            # if CPU utilized is across package this condition will  
> be true
>                 if len(modi_cpu_grp) != len(cpu_group):
>                     break
>                 for core in sorted(cpu_map[pkg].keys()):
> @@ -724,21 +720,21 @@ def validate_cpu_consolidation(stress, w
>                             utilization += int(get_cpu_utilization 
> ("cpu%s" %sib_list[i]))
>                     else:
>                         utilization = stats_percentage[l][1]
> -                    if utilization > 40:
> +                    if utilization > THRES_HT_KERNBENCH:
>                         cpus_utilized.append(int(cpu_id[1]))
>                         if siblings != "":
>                             for i in range(0, len(sib_list)):
>                                 cpus_utilized.append(int(sib_list[i]))
>                 else:
>                     # This threshold wuld be modified based on results
> -                    if stats_percentage[l][1] > 40:
> +                    if stats_percentage[l][1] > THRES_HT:
>                         cpus_utilized.append(int(cpu_id[1]))
>             else:
>                 if work_ld == "kernbench" :
> -                    if stats_percentage[l][1] > 50:
> +                    if stats_percentage[l][1] > THRES_KERNBENCH:
>                         cpus_utilized.append(int(cpu_id[1]))
>                 else:
> -                    if stats_percentage[l][1] > 70:
> +                    if stats_percentage[l][1] > THRES_EBIZZY:
>                         cpus_utilized.append(int(cpu_id[1]))
>             cpus_utilized.sort()
>         print "INFO: CPU's utilized ", cpus_utilized

Two things:
1. You aren't cleaning up filehandles explicitly in this manner:

# open
try:
     # read / write operations
finally:
     # close

You can wrap sys.exit calls inside the try-finally block. Finally,  
while you can do the following with 2.5+, it's not compatible with <=  
2.4:

# open
try:
     # read / write operations
[except:
     # handle specific exceptions here.
]
finally:
     # close

2. sys.exit takes an optional string or an integer argument, where the  
former prints out the message and exits with $? => 1, iirc. help 
(sys.exit) will tell you all of the gory details...

HTH,
-Garrett

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 1/4]Master script modified to enable testcases to run on Power
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Poornima Nayak @ 2010-01-08  7:20 UTC (permalink / raw)
  To: Garrett Cooper
  Cc: arun@linux.vnet.ibm.com, ltp-list@lists.sourceforge.net,
	svaidy@linux.vnet.ibm.com, ego


[-- Attachment #1.1: Type: text/plain, Size: 8551 bytes --]

Garrett Cooper <yanegomi@gmail.com> 
12/25/2009 01:51 AM

To
Poornima Nayak <mpnayak@linux.vnet.ibm.com>
cc
"ltp-list@lists.sourceforge.net" <ltp-list@lists.sourceforge.net>, 
"arun@linux.vnet.ibm.com" <arun@linux.vnet.ibm.com>, 
"svaidy@linux.vnet.ibm.com" <svaidy@linux.vnet.ibm.com>, 
ego@linux.vnet.ibm.com
Subject
Re: [LTP] [Patch 1/4]Master script modified to enable testcases to run on 
Power






On Dec 24, 2009, at 10:15 AM, Poornima Nayak 
<mpnayak@linux.vnet.ibm.com> wrote:

> Patch to enable Power management testcases in LTP to run on Power 
> platform
>
> Signed-off-by: poornima nayak <mpnayak@linux.vnet.ibm.com>
>
> diff -uprN ltp-intermediate-20091209.orig/testcases/kernel/ 
> power_management/runpwtests.sh ltp-intermediate-20091209.fixes/ 
> testcases/kernel/power_management/runpwtests.sh
> --- ltp-intermediate-20091209.orig/testcases/kernel/power_management/ 
> runpwtests.sh    2009-12-09 13:18:25.000000000 +0530
> +++ ltp-intermediate-20091209.fixes/testcases/kernel/ 
> power_management/runpwtests.sh    2009-12-24 23:16:39.859044825 +0530
> @@ -28,10 +28,21 @@
> # History:      26 Aug 2008 - Created this file
> # 03 Nov 2008 - Added CPUIDLE sysfs testcase
> #
> +# Function:     main
> +#
> +# Description:  - Execute all tests, exit with test status.
> +#
> +# Exit:         - zero on success
> +#               - non-zero on failure.
> +#
> +
> +#List of reusable functions defined in pm_include.sh
> +. ./pm_include.sh
> +
> +RC=0            #Return status
>
> # Exporting Required variables
> export TST_TOTAL=1
> -#LTPTMP=${TMP}
> export PATH=${PATH}:.
> export TCID="Power_Management"
> export TST_COUNT=0
> @@ -40,48 +51,39 @@ export analysis="/proctstat"
>
> YES=0
> NO=1
> -#List of reusable functions defined in pm_include.sh
> -. ./pm_include.sh
> -
> -# Function:     main
> -#
> -# Description:  - Execute all tests, exit with test status.
> -#
> -# Exit:         - zero on success
> -#               - non-zero on failure.
> -#
> -RC=0        #Return status
>
> # Checking required kernel version and architecture
> tst_kvercmp 2 6 21; rc=$?
> if [ $rc -ne 1 -a $rc -ne 2 ] ; then
> -    tst_resm TCONF "Kernel version not supported; not running 
> testcases"
> -    exit 0
> +        tst_resm TCONF "Kernel version not supported; not running 
> testcases"
> +        exit 0
> else
> -    case "$(uname -m)" in
> -    i[4-6]86|x86_64)
> +        case "$(uname -m)" in
> +        i[4-6]86|x86_64)
> +                ;;
> +        powerpc|ppc|powerpc64|ppc64)
>        ;;
> -    *)
> -        tst_resm TCONF "Arch not supported; not running testcases"
> -        exit 0
> -        ;;
> -    esac
> +        *)
> +                tst_resm TCONF "Arch not supported; not running 
> testcases"
> +                exit 0
> +                ;;
> +        esac
> fi
>
> tst_kvercmp 2 6 29; rc=$?
> if [ $rc -eq 2 ] ; then
> -    max_sched_mc=2
> -    max_sched_smt=2
> +        max_sched_mc=2
> +        max_sched_smt=2
> else
> -    max_sched_mc=1
> -    max_sched_smt=1
> +        max_sched_mc=1
> +        max_sched_smt=1
> fi
>
> tst_kvercmp 2 6 31; rc=$?
> if [ $rc -eq 1 -o $rc -eq 2 ] ; then
> -    timer_migr_support_compatible=1
> +        timer_migr_support_compatible=0
> else
> -    timer_migr_support_compatible=0
> +        timer_migr_support_compatible=1
> fi

Why did you invert the logic here? $? => 0 says the kernel version is 
less, 1 that it's equal, and 2 that it's greater than the version 
specified.
If Kernel version is less then that particular kernel is not suitable for 
Timer Migration test.
Only if kernel version is 2.6.31 and above then Timer migration test has 
to be executed. In the script YES=0, NO=1

> is_hyper_threaded; hyper_threaded=$?
> @@ -90,7 +92,6 @@ is_multi_core; multi_core=$?
> is_dual_core; dual_core=$?
>
> #Checking sched_mc sysfs interface
> -#check_config.sh config_sched_mc || RC=$?
> TST_COUNT=1
> if [ $multi_socket -eq $YES -a $multi_core -eq $YES ] ; then
>    if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
> @@ -103,6 +104,25 @@ if [ $multi_socket -eq $YES -a $multi_co
>    else
>         tst_resm TCONF "Required kernel configuration for SCHED_MC 
> NOT set"
>    fi
> +
> +    : $(( TST_COUNT+=1))
> +    if [ -f /proc/sys/kernel/timer_migration ]; then
> +        if [ $timer_migr_support_compatible -eq $YES ]; then
> +            if test_timer_migration.sh; then
> +                tst_resm TPASS "Timer Migration interface test"
> +            else
> +                RC=$?
> +                tst_resm TFAIL "Timer migration interface test"
> +            fi
> +        fi
> +    else
> +        if [ $supp -eq $YES ]; then
> +            RC=$?
> +            tst_resm TFAIL "Timer migration interface missing"
> +        else
> +            tst_resm TCONF "Kernel version does not support Timer 
> migration"
> +        fi
> +    fi
> else
>    if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
>        tst_resm TFAIL "sched_mc_power_savings interface in system 
> which is not a multi socket &(/) multi core"
> @@ -135,7 +155,6 @@ else
> fi
>
> # Checking cpufreq sysfs interface files
> -#check_config.sh config_cpu_freq || RC=$?
> : $(( TST_COUNT += 1 ))
> if [ -d /sys/devices/system/cpu/cpu0/cpufreq ] ; then
>     if check_cpufreq_sysfs_files.sh; then
> @@ -187,12 +206,13 @@ else
> fi
>
> # sched_domain test
> -if ! type python > /dev/null ; then
> +which python > /dev/null
> +if [ $? -ne 0 ] ; then

type is a bourne shell builtin whereas which is a command. 
Furthermore, you  can inline shell true / false checks in branch 
conditionals. So why did you revert this?

Will modify the patch accordingly.
>    tst_resm TCONF "Python is not installed, CPU Consoldation\
> test cannot run"
> else
>    if [ -f /sys/devices/system/cpu/sched_mc_power_savings ] ; then
> -            echo "max sched mc $max_sched_mc"
> +        get_sched_values sched_mc; max_sched_mc=$?
>        for sched_mc in `seq 0 $max_sched_mc`; do
>            : $(( TST_COUNT+=1))
>            sched_domain.py -c $sched_mc; RC=$?
> @@ -210,25 +230,6 @@ else
>    fi
> fi
>
> -: $(( TST_COUNT+=1))
> -if [ -f /proc/sys/kernel/timer_migration ]; then
> -    if [ $timer_migr_support_compatible -eq $YES ]; then
> -        if test_timer_migration.sh; then
> -            tst_resm TPASS "Timer Migration interface test"
> -        else
> -            RC=$?
> -            tst_resm TFAIL "Timer migration interface test"
> -        fi
> -    fi
> -else
> -    if [ $timer_migr_support_compatible -eq $YES ]; then
> -        RC=$?
> -        tst_resm TFAIL "Timer migration interface missing"
> -    else
> -        tst_resm TCONF "Kernel version does not support Timer 
> migration"
> -    fi
> -fi
> -
> if [ $# -gt 0 -a "$1" = "-exclusive" ]; then

Sorry for not noticing this sooner. $1 and -exclusive should be 
prefixed by a character, e.g. x or this will be reported as a [(1) 
syntax error.
Based on your comments I am doing it, as such I have not observed syntax 
error while executing these testcases
>
>    # Test CPU consolidation
>    if [ $multi_socket -eq $YES -a $multi_core -eq $YES ]; then
> @@ -266,7 +267,7 @@ if [ $# -gt 0 -a "$1" = "-exclusive" ];
>
>    fi
>
> -    if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES -a 
> $multi_core -eq $NO ]; then
> +    if [ $hyper_threaded -eq $YES ]; then
>            #Testcase to validate consolidation at core level
>            for sched_smt in `seq 0 $max_sched_smt`; do
>                if [ $sched_smt -eq 2 ]; then
> @@ -319,7 +320,7 @@ if [ $# -gt 0 -a "$1" = "-exclusive" ];
>    fi
>
>     # Verify threads consolidation stops when sched_smt is disabled 
> in HT systems
> -    if [ $hyper_threaded -eq $YES -a $multi_socket -eq $YES ]; then
> +    if [ $hyper_threaded -eq $YES ]; then
>        # Vary only sched_smt from 1 to 0 when workload is running 
> and ensure that
>        # tasks do not consolidate to single core when sched_smt is 
> set to 0
>        : $(( TST_COUNT += 1 ))

Thanks,
-Garrett

------------------------------------------------------------------------------
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


[-- Attachment #1.2: Type: text/html, Size: 13698 bytes --]

[-- Attachment #2: Type: text/plain, Size: 390 bytes --]

------------------------------------------------------------------------------
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 

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs
  2009-12-24 18:15 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
  2009-12-24 20:11   ` Garrett Cooper
@ 2010-01-11  4:25   ` Gautham R Shenoy
  1 sibling, 0 replies; 11+ messages in thread
From: Gautham R Shenoy @ 2010-01-11  4:25 UTC (permalink / raw)
  To: Poornima Nayak; +Cc: ltp-list, svaidy, arun

On Thu, Dec 24, 2009 at 11:45:42PM +0530, Poornima Nayak wrote:
> 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
> +}

I find code duplication here.

Cant we have, 
get_entity_count() {
	ENTITY=$1
	entries=`cat /sys/devices/system/cpu/cpu0/topology/$ENTITY_SIBLINGS`
	.
	.
	.
	.
	.
	echo $cpucount
}

get_core_siblings_count() {
	get_entity_count "core"
}

get_thread_siblings_count() {
	get_entity_count "thread"
}

is_hyperthreaded() {
	nr_threads = get_thread_siblings_count()
	if [$nr_threads -gt 1 ]; then
		return 0
	else
		return 1
	fi
}

and so on ?

}
> +
>  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() {

-- 
Thanks and Regards
gautham

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [LTP] [Patch 3/4]Python functions modified to run on Power platform
  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
  1 sibling, 0 replies; 11+ messages in thread
From: Gautham R Shenoy @ 2010-01-11  4:50 UTC (permalink / raw)
  To: Poornima Nayak; +Cc: ltp-list, svaidy, arun

On Thu, Dec 24, 2009 at 11:45:51PM +0530, Poornima Nayak wrote:
> +def get_hyper_thread_count():
> +    ''' Return number of threads in cpu0
> +    '''
> +    try:
> +        file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/thread_siblings", 'r')
> +        threads_count = 0
> +        for line in file_cpuinfo:
> +            core_grps = line.split(",")
> +            for i in range(0, len(core_grps)):
> +                cpumask=int(core_grps[i])
> +                while cpumask > 0:
> +                    threads_count = threads_count + 1
> +                    cpumask = cpumask >> 1
> +        return threads_count
> +    except Exception, details:
> +        print "INFO: Failed to get threaded siblings count", details
> +        sys.exit(1)
> +
> +def get_core_sibling_count():
> +    ''' Return number of threads in cpu0
> +    '''
> +    try:
> +        file_cpuinfo = open("/sys/devices/system/cpu/cpu0/topology/core_siblings", 'r')
> +        cores_count = 0
> +        for line in file_cpuinfo:
> +            core_grps = line.split(",")
> +            for i in range(0, len(core_grps)):
> +                cpumask=int(core_grps[i])
> +                while cpumask > 0:
> +                    cores_count = cores_count + 1
> +                    cpumask = cpumask >> 1
> +        return cores_count
> +    except Exception, details:
> +        print "INFO: Failed to get core siblings count", details
> +        sys.exit(1)
> +

We could avoid the code repetition above.

def get_entity_count(entity):
	try:
		file_cpuinfo =
		open("/sys/devices/system/cpu/cpu0/topology/" + entity + "siblings", 'r)
		.
		.
		.
	except
		.
		.
		.

def get_hyper_thread_count():
	return get_entity_count("thread")

def get_core_sibling_count():
	return get_entity_count("core")



-- 
Thanks and Regards
gautham

------------------------------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-01-11  4:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [LTP] [Patch 2/4]Reusable functions modified to learn topology from sysfs Poornima Nayak
2009-12-24 20:11   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox