From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by dpdk.org (Postfix) with ESMTP id 5A04A234 for ; Mon, 1 May 2017 08:29:59 +0200 (CEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v416Sr4J116823 for ; Mon, 1 May 2017 02:29:58 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a5xm19w24-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 01 May 2017 02:29:58 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 1 May 2017 16:29:55 +1000 Received: from d23relay09.au.ibm.com (202.81.31.228) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 1 May 2017 16:29:53 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v416TiEP983446 for ; Mon, 1 May 2017 16:29:52 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v416TFbI000948 for ; Mon, 1 May 2017 16:29:15 +1000 Received: from [9.124.211.203] ([9.124.211.203]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v416TCsr000820; Mon, 1 May 2017 16:29:13 +1000 To: Thomas Monjalon , Andriy Berestovskyy References: <20170430141140.7865-1-thomas@monjalon.net> Cc: dev@dpdk.org From: gowrishankar muthukrishnan Date: Mon, 1 May 2017 11:59:01 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170430141140.7865-1-thomas@monjalon.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17050106-0040-0000-0000-0000031126F4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050106-0041-0000-0000-00000C89350B Message-Id: <1234535c-4633-8556-47ba-f4b8219c7f55@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-01_03:, , 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-1705010042 Subject: Re: [dpdk-dev] [PATCH] usertools: fix CPU layout with python 3 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: Mon, 01 May 2017 06:29:59 -0000 On Sunday 30 April 2017 07:41 PM, Thomas Monjalon wrote: > 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 Thanks Thomas. Please include minor correction in your patch as below. > Fixes: deb87e6777c0 ("usertools: use sysfs for CPU layout") > Fixes: 63985c5f104e ("usertools: fix CPU layout for more than 2 threads") > > Signed-off-by: Thomas Monjalon > --- > usertools/cpu_layout.py | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py > index 99152a2ec..74da928df 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("") > > max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1)) > -max_thread_count = len(core_map.values()[0]) > +max_thread_count = len(core_map) We need to retain thread count calculated from any of core_map values (index 0 as in patch), hence keeping ljust() in output same as w/o this change. So, max_thread_count = len(list(core_map.values())[0]) Above list() ensures return values are in list always irrespective of python 2x / 3x. Regards, Gowrishankar > max_core_map_len = (max_processor_len * max_thread_count) \ > + len(", ") * (max_thread_count - 1) \ > + len('[]') + len('Socket ') > @@ -92,7 +96,7 @@ > 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)