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 AB28542977; Tue, 18 Apr 2023 07:57:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81045410EA; Tue, 18 Apr 2023 07:57:41 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 4A68540EDF for ; Tue, 18 Apr 2023 07:57:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681797459; x=1713333459; h=from:to:cc:subject:date:message-id; bh=x4qwmFVPl/We58c6q/w3fJ85qkxLVKPY+MZB8XE9ndQ=; b=mdqTQzaBHiRfqz7jOq/qShyPxwNIu4S9UzJURFR9G0TXxEUWAon6daI1 j2McNWNPr9VGi8M+rwvnniof4J2c6gRYD+3ggHZHhM/eZZ0hBp6w5plME tC0V8tUxGOqsdKAzV8iTW4DGpK3dO8N8CQuw3f377DdYH5Zuq5ldKfxdF +UtTyJH1O5kE/+4pi+pMSgX0phzHrHrKt6oqgx3tlN8OuuxwHy21Ef5V/ nqsOLKTa4rxPBr/8IOerX9IVBYY7XGLhR19B4oRwvyDclXA4xgCGRqRjS cCjegTdRxYRaNtMeP/tJTlENgIc3ApkuhaPGd578b31fKzG2MQqvJxSwx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="345081264" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="345081264" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2023 22:57:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="641235485" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="641235485" Received: from dpdk-wenzhuo-cascadelake.sh.intel.com ([10.67.110.255]) by orsmga003.jf.intel.com with ESMTP; 17 Apr 2023 22:57:36 -0700 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Subject: [PATCH] usertools: enhance CPU layout Date: Tue, 18 Apr 2023 13:25:41 +0800 Message-Id: <1681795541-68384-1-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.8.3.1 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 The cores in a single CPU may be not all the same. The user tool is updated to show the difference of the cores. This patch addes below informantion, 1, Group the cores based on the die. 2, A core is either a performance core or an efficency core. A performance core is shown as 'Core-P'. An efficency core is shown as 'Core-E'. 3, All the E-cores which share the same L2-cache are grouped to one module. The known limitation. 1, To tell a core is P-core or E-core is based on if this core shares L2 cache with others. Signed-off-by: Wenzhuo Lu --- usertools/cpu_layout.py | 77 +++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 891b9238fa..d78758cf2c 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -1,11 +1,17 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2014 Intel Corporation +# Copyright(c) 2010-2023 Intel Corporation # Copyright(c) 2017 Cavium, Inc. All rights reserved. sockets = [] +dies = [] cores = [] +module_id = [] core_map = {} +core_p_e = {} +title_len = 47 +die_len = 8 +module_no = 0 base_path = "/sys/devices/system/cpu" fd = open("{}/kernel_max".format(base_path)) max_cpus = int(fd.read()) @@ -20,19 +26,54 @@ fd = open("{}/cpu{}/topology/physical_package_id".format(base_path, cpu)) socket = int(fd.read()) fd.close() + fd = open("{}/cpu{}/topology/die_id".format(base_path, cpu)) + die = int(fd.read()) + fd.close() + fd = open("{}/cpu{}/topology/thread_siblings_list".format(base_path, cpu)) + threads_share = str(fd.read()) + fd.close() + fd = open("{}/cpu{}/cache/index2/shared_cpu_list".format(base_path, cpu)) + l2_cache_share = str(fd.read()) + fd.close() + if (threads_share == l2_cache_share): + p_e = '-P' + module_id.append(-1) + else: + module_tmp = [] + p_e = '-E' + for i in l2_cache_share: + if not i.isdigit(): + break + module_tmp.append(i) + if (cpu == int("".join(module_tmp))): + module_id.append(module_no) + module_no += 1 + else: + module_id.append(-1) if core not in cores: cores.append(core) + if die not in dies: + dies.append(die) if socket not in sockets: sockets.append(socket) - key = (socket, core) + key = (socket, die, core) + key_p_e = (die, core) if key not in core_map: core_map[key] = [] + if key_p_e not in core_p_e: + core_p_e[key_p_e] = p_e core_map[key].append(cpu) -print(format("=" * (47 + len(base_path)))) +print(format("=" * (title_len + len(base_path)))) print("Core and Socket Information (as reported by '{}')".format(base_path)) -print("{}\n".format("=" * (47 + len(base_path)))) +print("{}\n".format("=" * (title_len + len(base_path)))) print("cores = ", cores) +meaningful_module = [] +for i in module_id: + if (i != -1): + meaningful_module.append(i) +print("modules = ", meaningful_module) +print("dies = ", dies) print("sockets = ", sockets) print("") @@ -43,22 +84,30 @@ + len('[]') + len('Socket ') max_core_id_len = len(str(max(cores))) -output = " ".ljust(max_core_id_len + len('Core ')) +socket_space_len = max_core_id_len + len('Core ') + die_len + len('-P') +output = " ".ljust(socket_space_len) 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 ')) +output = " ".ljust(socket_space_len) 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 d in dies: + print("Die", die) + for c in cores: + if (module_id[core_map[(sockets[0], d, c)][0]] != -1): + print(" Module", module_id[core_map[(sockets[0], d, c)][0]]) + output = " ".ljust(die_len) + output += "Core" + output += core_p_e[(d, c)] + output += " %s" % str(c).ljust(max_core_id_len) + for s in sockets: + if (s, d, c) in core_map: + output += " " + str(core_map[(s, d, c)]).ljust(max_core_map_len) + else: + output += " " * (max_core_map_len + 1) + print(output) -- 2.25.1