Current usertools/cpu_layout.py is broken to handle multithreads
of count more than 2 as in IBM powerpc P8 servers.
Below patch addressed this issue.
Also, added minor exception catch on failing to open unavailable
sys file in case of multithread=off configuration in server.
Patch has been verified not to break existing topology configurations
and also not changing anything in current output.
Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
Reviewed-by: Andriy Berestovskyy <andriy.berestovskyy@caviumnetworks.com>
for cpu in xrange(max_cpus + 1):
try:
fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu))
for cpu in xrange(max_cpus + 1):
try:
fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu))
+ except IOError:
+ continue
except:
break
core = int(fd.read())
except:
break
core = int(fd.read())
print("")
max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1))
print("")
max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1))
-max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ')
+max_thread_count = len(core_map.values()[0])
+max_core_map_len = (max_processor_len * max_thread_count) \
+ + len(", ") * (max_thread_count - 1) \
+ + len('[]') + len('Socket ')
max_core_id_len = len(str(max(cores)))
output = " ".ljust(max_core_id_len + len('Core '))
max_core_id_len = len(str(max(cores)))
output = " ".ljust(max_core_id_len + len('Core '))
for c in cores:
output = "Core %s" % str(c).ljust(max_core_id_len)
for s in sockets:
for c in cores:
output = "Core %s" % str(c).ljust(max_core_id_len)
for s in sockets:
- output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
+ if core_map.has_key((s,c)):
+ output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
+ else:
+ output += " " * (max_core_map_len + 1)