From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by dpdk.org (Postfix) with ESMTP id 5ADFC1E34 for ; Fri, 28 Apr 2017 12:35:30 +0200 (CEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3SAYUJC058331 for ; Fri, 28 Apr 2017 06:35:30 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a3hf61dd5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 28 Apr 2017 06:35:29 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Apr 2017 20:35:27 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 28 Apr 2017 20:35:25 +1000 Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3SAZG8C2228606 for ; Fri, 28 Apr 2017 20:35:24 +1000 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3SAYqIW011405 for ; Fri, 28 Apr 2017 20:34:52 +1000 Received: from chozha.in.ibm.com ([9.193.77.198]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3SAYptf011049; Fri, 28 Apr 2017 20:34:52 +1000 From: Gowrishankar To: Thomas Monjalon Cc: dev@dpdk.org, Gowrishankar Muthukrishnan Date: Fri, 28 Apr 2017 16:04:35 +0530 X-Mailer: git-send-email 1.9.1 X-TM-AS-MML: disable x-cbid: 17042810-0044-0000-0000-0000024ABEAE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042810-0045-0000-0000-000006D2C6AF Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-28_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704280157 Subject: [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Apr 2017 10:35:31 -0000 From: Gowrishankar Muthukrishnan 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 --- usertools/cpu_layout.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 5735891..99152a2 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -46,6 +46,8 @@ 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()) @@ -70,7 +72,10 @@ 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 ')) @@ -87,5 +92,8 @@ 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) print(output) -- 1.9.1