From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02D85A034C; Sat, 26 Mar 2022 08:32:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4F14410F3; Sat, 26 Mar 2022 08:32:27 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2051.outbound.protection.outlook.com [40.107.94.51]) by mails.dpdk.org (Postfix) with ESMTP id 3B9AB4014F for ; Sat, 26 Mar 2022 08:32:26 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NQkg6IXCVV+7ynI7z2PI49I+dzzRvdyRASNNps/agLY1eyMVDDFtvNNl7k+LXjTpcXm4HdrtfPZ/BHMZgeY0rdbqGHcdTUdtpC/G2QHBcTXQ7xRLTUSnNl2yKpBJniCMmX2thjsYhxFN7VA1EmUMTjavsdOw+ZzLkVh+GDnmjqkQYP1dbQLckyFBYPWdstidVGCv3skHPFiu0LNlHpxDkoru9IOvOwFAiCr+mNaXCLUqydT0g2Oh5hWjp/ScLx1cHZn/pfUuHZlre3nUHOqCo9mRHE5h8UpBAdyM/6TdR5QNB3OSkZlR9VQxq1E1bSQCdL2Md+DfpZU6uPdY3tMNCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NBWE4YJHEyokqgFOKfSOqsrGs5XSXXf1CoQD8jsualQ=; b=RyksDsg414BtjwS5NW9FPwfyp+F9yINCOcLBopf6uIkR/zGUQYvW2nMX4Hakvx57gNNfN2NDnlw548xvf6gkLVLn1PK/jjabMrvuFiXyWUmXYbOlCYp+njmv13hlNkNWLKdchPC02jDEN/ci1r9YRt4U7iYYXBCRbtsl/L72UQi2/CCoZZDHomyXjo/Fi/x8PABiunJbJNU2lb9At2kpNY0hhryat9x+hpLWYPPGDf/ePfEee5jP4ogGaY0axbjrqY4sW78hnGrQpXl7zXmnOqehPDbx+2KJtV4fb9i6MoYhXY8rk3vzizIfzLhboYmXqcDsjsU5IKKPtb7j05kG4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=monjalon.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NBWE4YJHEyokqgFOKfSOqsrGs5XSXXf1CoQD8jsualQ=; b=G7C5t7gYQOxeKoAsRP9pizdX6k2m5KEhVa5Zy8Kr3JvOxL+8jE1GaJo28VCkialhUT6zRzuzcYgllnRYGFSZW9DnlQbI4dvK50Yus6qB/kWHxIsjWHbsO34j3eCWB/G21x4u27wsWe5N08JWuc6V+buQ+1bdAtG0SX3WH+BuLHU= Received: from BN8PR16CA0026.namprd16.prod.outlook.com (2603:10b6:408:4c::39) by BN7PR12MB2739.namprd12.prod.outlook.com (2603:10b6:408:31::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Sat, 26 Mar 2022 07:32:22 +0000 Received: from BN8NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::33) by BN8PR16CA0026.outlook.office365.com (2603:10b6:408:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17 via Frontend Transport; Sat, 26 Mar 2022 07:32:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT038.mail.protection.outlook.com (10.13.176.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5102.17 via Frontend Transport; Sat, 26 Mar 2022 07:32:21 +0000 Received: from telco2.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 26 Mar 2022 02:32:20 -0500 From: Vipin Varghese To: , CC: , , Subject: [PATCH] usertools: enhance logic to display NUMA Date: Sat, 26 Mar 2022 00:32:07 -0700 Message-ID: <20220326073207.489694-1-vipin.varghese@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c2987ca-a576-4688-d044-08da0efac3db X-MS-TrafficTypeDiagnostic: BN7PR12MB2739:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zd5Is7A4b32CZ32dx0Wh+LLAlGqHrZZC727eVWltCsyUrQhUwiZdkBSIfhGEr6VEKXhz6skXD8zr5Fdx53k+aghn3dYB0toKcYC8QQhveH/5aVka4z9CkcuvuLU5XnWq1PxkiaHcr4Ulx7phjdBXMtznJqrMZx1HzJBf5JyRL2WTT6kdFolDHQBLxIiIR8R4IZps2bA2W8i2Z6bJTzB+HmCPGnisJVGaDsqWhPmszdc7gLNP2Th45L81dRzRSHjiBDCOxZVFK/+0BZT2gnJikSgRYqKoFBJNKy1Cohhei2e9x2Zwf1Pu4s60aQzSM5+1/p5G0MYeBKUsAbd9WZZOdPBDLUEcUyXUce+W3mwJl5UPx4NAwFa2pRnKcyuVieu2Da7/LBF2XzNa1gLFrRZ5NNGZUdRZuOAIrsQtxFjd/ln6mxkZ9zwPawBy94b0v/7uNXnT6J7I5vHiG0xSNnq+tai6RsVldM8+LcFt6ywdLvNbrFXL67+PRCXSx50ncUMkWnsB/TyPLl7pD2+IlmvuNauQlyd1Ifto6D9jtBJEHcyK0vItE1UdAPo2ZuSp+bKi/s3/7TtpkqD2Dfiswp3HV8FWj2+YAcjW8PZNyxuj2MVs1KyoBoxeLu4a1z1bmQUik2Ad7EPx3/ATEG+DW2Yh3EPiaFi8HJV4QlMsQX+h+z2n1RU5mXRsGkQ3I/bghm8B7xCytRfFywqcBIqwfKj+gA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(44832011)(2906002)(1076003)(5660300002)(86362001)(83380400001)(7696005)(186003)(26005)(426003)(16526019)(82310400004)(336012)(8936002)(2616005)(508600001)(40460700003)(54906003)(110136005)(356005)(6666004)(316002)(36756003)(81166007)(70586007)(70206006)(8676002)(4326008)(36860700001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2022 07:32:21.6140 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c2987ca-a576-4688-d044-08da0efac3db X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2739 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org enhance python logic to accomadate NUMA information. Current logic considers physical socket with CPU threads to core map. With new AMD SKU vairant NUMA is no longer same as SOCKET. Single physical socket can be partitioned to variant of 1,2 and 4. The changes address the new mapping with Socket-NUMA to CPU cores. Signed-off-by: Vipin Varghese --- usertools/cpu_layout.py | 76 +++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 891b9238fa..295f2c0e9b 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -3,13 +3,27 @@ # Copyright(c) 2010-2014 Intel Corporation # Copyright(c) 2017 Cavium, Inc. All rights reserved. +import glob +import os + sockets = [] cores = [] +numaNodes = [] core_map = {} +numa_map = {} +node_path = "/sys/devices/system/node" base_path = "/sys/devices/system/cpu" -fd = open("{}/kernel_max".format(base_path)) -max_cpus = int(fd.read()) -fd.close() +max_cpus = 0 + +if os.path.isdir(base_path): + temp_maxCpu = glob.glob(base_path + '/cpu[0-9]*') + max_cpus = len(temp_maxCpu) + +if os.path.isdir(node_path): + temp_numaNodes = glob.glob(node_path + '/node*') + for numaId in range(0, int(os.path.basename(temp_numaNodes[-1])[4:]) + 1): + numaNodes.append(numaId) + for cpu in range(max_cpus + 1): try: fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu)) @@ -17,48 +31,52 @@ continue core = int(fd.read()) fd.close() + + tempGet_cpuNuma = glob.glob("{}/cpu{}/node*".format(base_path, cpu)) + temp_cpuNuma = tempGet_cpuNuma[-1].split("{}/cpu{}/".format(base_path, cpu))[-1] + numa = temp_cpuNuma.split("node")[-1] + fd = open("{}/cpu{}/topology/physical_package_id".format(base_path, cpu)) socket = int(fd.read()) fd.close() + if core not in cores: cores.append(core) + if socket not in sockets: sockets.append(socket) + key = (socket, core) if key not in core_map: core_map[key] = [] core_map[key].append(cpu) + key = (socket, numa) + if key not in numa_map: + numa_map[key] = [] + + if (core_map[(socket, core)] not in numa_map[key]): + numa_map[key].append(core_map[(socket, core)]) + print(format("=" * (47 + len(base_path)))) print("Core and Socket Information (as reported by '{}')".format(base_path)) print("{}\n".format("=" * (47 + len(base_path)))) print("cores = ", cores) +print("numa nodes per socket = ", numaNodes) print("sockets = ", sockets) print("") -max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1)) -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 ') -max_core_id_len = len(str(max(cores))) - -output = " ".ljust(max_core_id_len + len('Core ')) -for s in sockets: - output += " Socket %s" % str(s).ljust(max_core_map_len - len('Socket ')) -print(output) - -output = " ".ljust(max_core_id_len + len('Core ')) -for s in sockets: - output += " --------".ljust(max_core_map_len) - output += " " -print(output) - -for c in cores: - output = "Core %s" % str(c).ljust(max_core_id_len) - for s in sockets: - if (s, c) in core_map: - output += " " + str(core_map[(s, c)]).ljust(max_core_map_len) - else: - output += " " * (max_core_map_len + 1) - print(output) +for keys in numa_map: + print ("") + socket,numa = keys + + output = " Socket " + str(socket).ljust(3, ' ') + " Numa " + str(numa).zfill(1) + " " + #output = " Socket " + str(socket).zfill(1) + " Numa " + str(numa).zfill(1) + " " + print(output) + print(format("-" * len(output))) + + for index,coreSibling in enumerate(numa_map[keys]): + print ("Core " + str(index).ljust(3, ' ') + " " + str(coreSibling)) + #print ("Core " + str(index).zfill(3) + " " + str(coreSibling)) +print("") + -- 2.25.1