[dts] [PATCH 2/9] framework: platform independent cpu info parsing
Gowrishankar
gowrishankar.m at linux.vnet.ibm.com
Fri Feb 26 11:17:07 CET 2016
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 <gowrishankar.m at linux.vnet.ibm.com>
---
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
More information about the dts
mailing list