summaryrefslogtreecommitdiffstats
path: root/extras/vpp_config/vpplib/CpuUtils.py
diff options
context:
space:
mode:
Diffstat (limited to 'extras/vpp_config/vpplib/CpuUtils.py')
-rw-r--r--extras/vpp_config/vpplib/CpuUtils.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/extras/vpp_config/vpplib/CpuUtils.py b/extras/vpp_config/vpplib/CpuUtils.py
index f5c23bc141a..23f418d33be 100644
--- a/extras/vpp_config/vpplib/CpuUtils.py
+++ b/extras/vpp_config/vpplib/CpuUtils.py
@@ -12,7 +12,7 @@
# limitations under the License.
"""CPU utilities library."""
-
+from __future__ import absolute_import, division
import re
from vpplib.VPPUtil import VPPUtil
@@ -43,8 +43,8 @@ class CpuUtils(object):
@staticmethod
def is_smt_enabled(cpu_info):
"""Uses CPU mapping to find out if SMT is enabled or not. If SMT is
- enabled, the L1d,L1i,L2,L3 setting is the same for two processors. These
- two processors are two threads of one core.
+ enabled, the L1d,L1i,L2,L3 setting is the same for two processors.
+ These two processors are two threads of one core.
:param cpu_info: CPU info, the output of "lscpu -p".
:type cpu_info: list
@@ -53,7 +53,7 @@ class CpuUtils(object):
"""
cpu_mems = [item[-4:] for item in cpu_info]
- cpu_mems_len = len(cpu_mems) / CpuUtils.NR_OF_THREADS
+ cpu_mems_len = len(cpu_mems) // CpuUtils.NR_OF_THREADS
count = 0
for cpu_mem in cpu_mems[:cpu_mems_len]:
if cpu_mem in cpu_mems[cpu_mems_len:]:
@@ -137,7 +137,7 @@ class CpuUtils(object):
if smt_enabled and not smt_used:
cpu_list_len = len(cpu_list)
- cpu_list = cpu_list[:cpu_list_len / CpuUtils.NR_OF_THREADS]
+ cpu_list = cpu_list[:cpu_list_len // CpuUtils.NR_OF_THREADS]
return cpu_list
@@ -171,8 +171,8 @@ class CpuUtils(object):
cpu_cnt = cpu_list_len - skip_cnt
if smt_used:
- cpu_list_0 = cpu_list[:cpu_list_len / CpuUtils.NR_OF_THREADS]
- cpu_list_1 = cpu_list[cpu_list_len / CpuUtils.NR_OF_THREADS:]
+ cpu_list_0 = cpu_list[:cpu_list_len // CpuUtils.NR_OF_THREADS]
+ cpu_list_1 = cpu_list[cpu_list_len // CpuUtils.NR_OF_THREADS:]
cpu_list = [cpu for cpu in cpu_list_0[skip_cnt:skip_cnt + cpu_cnt]]
cpu_list_ex = [cpu for cpu in
cpu_list_1[skip_cnt:skip_cnt + cpu_cnt]]
@@ -236,8 +236,8 @@ class CpuUtils(object):
smt_used=smt_used)
if smt_used:
cpu_list_len = len(cpu_list)
- cpu_list_0 = cpu_list[:cpu_list_len / CpuUtils.NR_OF_THREADS]
- cpu_list_1 = cpu_list[cpu_list_len / CpuUtils.NR_OF_THREADS:]
+ cpu_list_0 = cpu_list[:cpu_list_len // CpuUtils.NR_OF_THREADS]
+ cpu_list_1 = cpu_list[cpu_list_len // CpuUtils.NR_OF_THREADS:]
cpu_range = "{}{}{},{}{}{}".format(cpu_list_0[0], sep,
cpu_list_0[-1],
cpu_list_1[0], sep,