From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by dpdk.org (Postfix) with ESMTP id 4366B2C6A for ; Fri, 26 Feb 2016 11:18:24 +0100 (CET) Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Feb 2016 20:18:23 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 26 Feb 2016 20:18:21 +1000 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: gowrishankar.m@linux.vnet.ibm.com X-IBM-RcptTo: dts@dpdk.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 44890357803F for ; Fri, 26 Feb 2016 21:18:21 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1QAIB2H12058914 for ; Fri, 26 Feb 2016 21:18:21 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1QAHlQD000664 for ; Fri, 26 Feb 2016 21:17:47 +1100 Received: from chozha.in.ibm.com ([9.79.215.216]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u1QAHhux032599 for ; Fri, 26 Feb 2016 21:17:46 +1100 From: Gowrishankar To: dts Date: Fri, 26 Feb 2016 15:47:07 +0530 Message-Id: <1456481834-10027-3-git-send-email-gowrishankar.m@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1456481834-10027-1-git-send-email-gowrishankar.m@linux.vnet.ibm.com> References: <1456481834-10027-1-git-send-email-gowrishankar.m@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16022610-1618-0000-0000-0000271B7E21 Subject: [dts] [PATCH 2/9] framework: platform independent cpu info parsing X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2016 10:18:26 -0000 To collect thread/core/socket, /proc/cpuinfo would not help in case of powerpc. Instead, lscpu seems to be a better alternative and platform neutral approach. Signed-off-by: Gowrishankar --- framework/crb.py | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/framework/crb.py b/framework/crb.py index c6fd9fb..1711f37 100644 --- a/framework/crb.py +++ b/framework/crb.py @@ -495,41 +495,25 @@ class Crb(object): cpuinfo = \ self.send_expect( - "grep --color=never \"processor\\|physical id\\|core id\\|^$\" /proc/cpuinfo", + "lscpu -p|grep -v \#", "#", alt_session=True) - if "processor" not in cpuinfo: - # yocto not support --color=never, but ubuntu must need --color=never, - # so check cpuinfo, before parsing cpuinfo, if cpuifo get error, delete --color=never - # and get cpuinfo again - cpuinfo = \ - self.send_expect( - r'grep "processor\|physical id\|core id\|^$" /proc/cpuinfo', - "#", alt_session=True) - - cpuinfo = cpuinfo.split('\r\n\r\n') + cpuinfo = cpuinfo.split() # haswell cpu on cottonwood core id not correct # need addtional coremap for haswell cpu core_id = 0 coremap = {} for line in cpuinfo: - m = re.search("processor\t: (\d+)\r\n" + - "physical id\t: (\d+)\r\n" + - "core id\t\t: (\d+)", line) - - if m: - thread = m.group(1) - socket = m.group(2) - core = m.group(3) - - if core not in coremap.keys(): - coremap[core] = core_id - core_id += 1 - - if self.crb['bypass core0'] and core == '0' and socket == '0': - self.logger.info("Core0 bypassed") - continue - self.cores.append( + (thread, core, socket) = line.split(',')[0:3] + + if core not in coremap.keys(): + coremap[core] = core_id + core_id += 1 + + if self.crb['bypass core0'] and core == '0' and socket == '0': + self.logger.info("Core0 bypassed") + continue + self.cores.append( {'thread': thread, 'socket': socket, 'core': coremap[core]}) self.number_of_cores = len(self.cores) -- 1.7.10.4