From patchwork Fri Feb 10 07:41:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenzhuo Lu X-Patchwork-Id: 123663 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04F7241C5D; Fri, 10 Feb 2023 09:17:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E6DC7410D3; Fri, 10 Feb 2023 09:17:54 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 694A540EE6 for ; Fri, 10 Feb 2023 09:17:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676017073; x=1707553073; h=from:to:cc:subject:date:message-id; bh=6e9RKbvhnbWkduEEaGTyp1GeDYg8EhPE8WKVh0BJjT8=; b=LytOwJah1NBzmdW9TYDU6pgqKu1jPbNdPKrxoOjafgrizG990k2G+mlT +YLQkg4kuHB2m0HB8j6qL7k0lVkMBKbR0B3RdULN0kVoECm1gBydbHdUo 4uofXNwmXZZNVaTrNNgRViJTAqnlaKHDJuqNZ6pV31uUp/yVW2QPpqVXl +LaFL3PYR6KdaNzbZjOl+Iikjoz16kTrszUoiKw1/g3sx2EEKg3HKA/qA Zb0dR4hr0UUHcAhDpEpYEpxhppPYb6Axmt6CKLif9oXSodrjbbB1O7VkC NLUbZ+rUoY+NSU1jOsrj8VWliwCJqopVp50mAYfRInJD8vPDdkeTddmpM Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="310731660" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="310731660" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2023 00:17:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10616"; a="736651831" X-IronPort-AV: E=Sophos;i="5.97,286,1669104000"; d="scan'208";a="736651831" Received: from dpdk-wenzhuo-cascadelake.sh.intel.com ([10.67.110.255]) by fmsmga004.fm.intel.com with ESMTP; 10 Feb 2023 00:17:50 -0800 From: Wenzhuo Lu To: dev@dpdk.org Cc: Wenzhuo Lu Subject: [RFC] usertools: enhance CPU layout Date: Fri, 10 Feb 2023 15:41:34 +0800 Message-Id: <1676014894-83654-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 CPU is becoming more and more complex. Some CPUs are made up of several dies. The cores in different dies may be different. The user tool can be updated to show more about CPU components. 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'. The known limitation/issue. 1, To tell a core is P-core or E-core is based on if this core shares L2 cache with others. Not sure if there's any better criteria. 2, OS shows there's only 1 die in a CPU although there're actually several. Hope the accurate information can be proved by the coming OSs. There's also other information, like accelerators and even memory are embedded into CPU. In the future the user tool may be updated to show more. Signed-off-by: Wenzhuo Lu --- usertools/cpu_layout.py | 57 +++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 891b9238fa..9812df0503 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -1,11 +1,15 @@ #!/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 = [] core_map = {} +core_p_e = {} +title_len = 47 +die_len = 6 base_path = "/sys/devices/system/cpu" fd = open("{}/kernel_max".format(base_path)) max_cpus = int(fd.read()) @@ -20,19 +24,38 @@ 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' + else: + p_e = '-E' 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) +print("dies = ", dies) print("sockets = ", sockets) print("") @@ -43,22 +66,28 @@ + 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: + 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)