summaryrefslogtreecommitdiff
path: root/usertools
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2017-04-30 16:11:40 +0200
committerThomas Monjalon <thomas@monjalon.net>2017-05-02 00:17:40 +0200
commitc9208f1dc96701c8d373681d93853b4631b03a2e (patch)
tree6a8dd541d26467b4bac0b6d90c77a8cbdd250b3c /usertools
parentdf86b009dd7099d2a373f3eddbe5ca997dacace3 (diff)
downloaddpdk-c9208f1dc96701c8d373681d93853b4631b03a2e.zip
dpdk-c9208f1dc96701c8d373681d93853b4631b03a2e.tar.gz
dpdk-c9208f1dc96701c8d373681d93853b4631b03a2e.tar.xz
usertools: fix CPU layout with python 3
These differences in Python 3 were causing errors: - xrange is replaced by range - dict values are a view (instead of list) - has_key is removed Fixes: deb87e6777c0 ("usertools: use sysfs for CPU layout") Fixes: 63985c5f104e ("usertools: fix CPU layout for more than 2 threads") Signed-off-by: Thomas Monjalon <thomas@monjalon.net> Reviewed-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
Diffstat (limited to 'usertools')
-rwxr-xr-xusertools/cpu_layout.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py
index 99152a2..9394944 100755
--- a/usertools/cpu_layout.py
+++ b/usertools/cpu_layout.py
@@ -35,6 +35,10 @@
#
from __future__ import print_function
import sys
+try:
+ xrange # Python 2
+except NameError:
+ xrange = range # Python 3
sockets = []
cores = []
@@ -72,7 +76,7 @@ print("sockets = ", sockets)
print("")
max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1))
-max_thread_count = len(core_map.values()[0])
+max_thread_count = len(list(core_map.values())[0])
max_core_map_len = (max_processor_len * max_thread_count) \
+ len(", ") * (max_thread_count - 1) \
+ len('[]') + len('Socket ')
@@ -92,7 +96,7 @@ print(output)
for c in cores:
output = "Core %s" % str(c).ljust(max_core_id_len)
for s in sockets:
- if core_map.has_key((s,c)):
+ if (s,c) in core_map:
output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
else:
output += " " * (max_core_map_len + 1)