From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 69AA91E34 for ; Fri, 28 Apr 2017 13:58:17 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 17EB320BCE; Fri, 28 Apr 2017 07:58:17 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 28 Apr 2017 07:58:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=9vY4DTnshuNgzky gt1nujzcG1tBtUYoHMPD80O1UbOg=; b=HN2nzTA0IZoHVsD6FtUpIACBs5+38MN rk22XGz681yZOsJACCZE//IdTzL56XhZAY+qsdrqiTvxfkbB4IDNWPpca8OOfl3K 8riQJm37lMxR1TtC1DQAKl9VlekqGa/4co4/GeuxpVNZmxHKRvtJ4DGwdxQVD1lQ jugUcteNPErg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=9vY4DTnshuNgzkygt1nujzcG1tBtUYoHMPD80O1UbOg=; b=nPC1T79f kPP/PC/Z7H/52E3XedV1axUc90xXQ0OK9XzCXf8g4Wv4h4xWI52tRaYhuagzjeqr GqAWzoEIA7KsJJo575zkUgCt7FISFcGI4BmZXgRiPq+cxX0CGPJ3Y/j93YclR7an dG3Ij850FoqWr8iaWeo7kJ71mtZbnEdhypyxECZ3s6Arqaaw+zrKqVWrjEYsTGpQ z5JOMl/R3fU6gueUagZ0E5GQCpYqGGRt7w9EP32435kAvp+ELn0wEYS6V5nwIKca p6IIHJMwGwPeW8HBAYnmd1ZWKRQuk3NcyeEIV/mJXZmbBkc1d6UEcgIJJ5sx+d54 /oIkEf/NShACjQ== X-ME-Sender: X-Sasl-enc: Ri4wE9sluX80xGWgBjGc3Ot8O29Hzik64Qrzx7EXlXWT 1493380696 Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id C7C5F24457; Fri, 28 Apr 2017 07:58:16 -0400 (EDT) From: Thomas Monjalon To: Andriy Berestovskyy Cc: dev@dpdk.org, Gowrishankar Date: Fri, 28 Apr 2017 13:58:16 +0200 Message-ID: <1874376.tUCind7prS@xps> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [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 11:58:17 -0000 Andriy, please would you like to review this patch? 28/04/2017 12:34, Gowrishankar: > 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) >