From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0045.outbound.protection.outlook.com [104.47.33.45]) by dpdk.org (Postfix) with ESMTP id 1A70FFE5 for ; Fri, 31 Mar 2017 14:21:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gAknRShz9ne4PaKAULRqmUbepRR0XvKyAzgrBTtCHVI=; b=QadswU4SH5+vSfer4r+I/hwMQp7z4GB1LilSN7WPCszTQjh5G2pDxGCmyIRWHvVR19cY/e8td+3PyvIOBJG89zBSRetinh0/5GEXM2H8R+xfE5dUxNWdhDPLGwp7qJ2gefQZ+ITmLMTqNnVDNerzV8oBscvfOKO3NWOyzYDphqI= Authentication-Results: 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from b.semihalf.local (31.172.191.173) by SN2PR0701MB1040.namprd07.prod.outlook.com (10.160.58.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10; Fri, 31 Mar 2017 12:21:18 +0000 From: Andriy Berestovskyy To: Thomas Monjalon Cc: dev@dpdk.org Date: Fri, 31 Mar 2017 14:21:00 +0200 Message-Id: <1490962860-11567-1-git-send-email-Andriy.Berestovskyy@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [31.172.191.173] X-ClientProxiedBy: HE1PR02CA0111.eurprd02.prod.outlook.com (10.170.249.40) To SN2PR0701MB1040.namprd07.prod.outlook.com (10.160.58.147) X-MS-Office365-Filtering-Correlation-Id: 283efc93-a43d-45f0-0fd3-08d478306f57 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:SN2PR0701MB1040; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0701MB1040; 3:yvZtDQvZurbf8aMBuwlOx+yLbF0bTzzarhfqP9XGvi6KgV6g+ys0kHHxC/YKEvGvPDOObFsXLVXELWNaADFBD3xvc+hbzcsm8tBGdjTPxA137Q01LACS0kqAfXGKSs/BSF6MgnCKkPgfJejNBBdfQ8whIhcdo34GmhZUcmAoaRCPtAllT16yaTEcLlkzypaliB6MTbOTWNbzrD9BoQOvHit8cBR6HPaKl1s74ZqZg96sC+F81eo5WInemzovLT3IbMPjPmXCQKQ3tenRpL7XE/k+FiXD/f0hfRg6ROxZXGEYif0sMDGMhetSq2Y6T/y+dNDlhjT6jzV8HmMECzO+Qw==; 25:RHN0Efvxvp+KmxzAVHsTP/ud/kqRElOJMGHw+xqD4FOlpUlYSbPLeBOjFzKJbs0nWZuJ0VoGuHzPPkTlwOn3RswQWQsxUPRCe4aY5hAAHX1MNye9Xe79btcZ9c5Kzdikrk+h0xhtUcRtwHYT6LuFm7xJcvv614dlAk7GaILHN0tk3ucGxQjFRyMzfIhDx/6QCdudlRKRPiSI7kBJAvQZRKLQefSgHe25mCrbFc2UQlzXN0OoYptkATSoaW3EZF2uL5Yp0n/HSl3zyYdPfTqRL99n3ytq2OpenSlhzfTc49NIV0Nvs4tno+kDegZbNPWq2gT/BOsQmrDoCl+fjy377OCDjdMHwHwcwPOHi/3XAnNUzHBzhywjmmfsRk9OLkbKAG7/wGjLvX+DRaxh3V0p6K6nhC3u5ZH7kiXvfMykSMy535em7gxaqRVEg5fbgQ6/QTe++eJB/nhxABj9vSmCFw== X-Microsoft-Exchange-Diagnostics: 1; SN2PR0701MB1040; 31:i/nfjignzJozfTufoOvCbgjcUdrA8uB7Md8f6wqW93MnHedpUgrt2N4z6R9J2Mzu7xsegzHrPUOawgBdn/MyQcaHSx3iW+nWq8D/c8utqRkWKLt8z6OnAFo3Twi6VCJcfhGBasVd/saUvweVuFoLsM5yro8rTNU5+KtMCJ/NhWlf7oeK796zTf2UPJZFQ8tJDbOX3sUUWyKVTcALla0KTzr9QSCsMHmAAMS1dvzi76L4qaO5Sp0kYHGGXOeVdQ41QYpM8z0SvblgRXKW4E0REiIFoJ5inN1o9WUBQf3T0jI=; 20:NTzm/MkT49ytXQ65M4LxQn7jgK3J2I4w6R8r25W9gJGCm1PGlywyENG9xboAf53RWJqc+uUB0O4zH+Bd9kWPo8wwBLLBxI3+Ia6xLMQ5lUNYYMvGRvl8z3nvIZ1xW2KeJ/aCCAv9DSgFmdFtvExedcm1wYO+bEMKk2cjSRK3Kms0ZmtZKmP7Olg7acFGBDm0s1Cf4AYrp5tGeEnPQANIKTLjC+WYfwBPOLADJYFKi2TBJkCkRAWskJUHlrW7TitZgyvccyYcdA/sZ+DpQNkiVjDOnmGLaVSJ3CaYWGrgtnOVaxZLV8Ti4okdIYhoWGP93KBBOK9Ik9LrWw51ctpmL3iN11mN7Rwmi3SkyvgVaaz3ckIXzWwrv/LFPvDO+KyoUK731vUCSZHJB8W/vVa70Ouz+MflD8/CQazKCgv+vf5DomEAk2YK+EGK1CQeU1YnAb+C14GhHbVSUjJPJUoxuhwPOaY2JovULqA0DWPYGFl8GEBrwROsYa6hZIj2oW90Vi9/qH+8ZtHihreYLl0f9knjQJUN8YZBB51B0yAk8khjUSOibW6Zeuxt8Qiu+yK5uiPDnqV461euzFHeWD/FzHqpvTIiY9ElUruYEv+Hj3o= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(6041248)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123555025)(6072148); SRVR:SN2PR0701MB1040; BCL:0; PCL:0; RULEID:; SRVR:SN2PR0701MB1040; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0701MB1040; 4:NLtH00PAS7TxpkJi19rDeZf5g50pxLkS4aaJSj6oD5r+ZHycY6jeAN093EHWPkBjsPlQEBujEKSmhvfVPhhhiR5MuOOVDT52ouQCGFy8NfO5ssCfyasFiafD26HJm0jbT5PRDGZVZZyBK6GU57MP9o5IPlGfooqpY3LZJXpVrjNBA7ABBQtUwgECD03UNmeSquVHW90iMrFjCjBPjGbrVYz1OHmJnGxaUNZQCXvEg5HtsgjRo2BfcwzFRWoIvhyUsiqCvoN+1idT2AeQ7ctbkNTlEEJCalRCctOnHGGAmrofyPPecUvOxyOUy1NMuhQtRTa9OWMgTmeQhWO/d2XZPIh5jAYlDOaD5BBX06LeNVUca3OEiAhwAjwluC3tO+fKCWMxz0t71aEU+p2amWT+xcDGTMYUlPBAIhSmNcriu0lJv52TO3ylyF3BW7IlNUkh3rLJ0zhsZsyt6mf3rvYb9U2kyk123A5wxzGcO62VZLLsu0HldpN4CtnAgTxkwF8OeZO8Sxvy58kB0Y1a5oj0tR3PmGMzOSlAJ5OVnVjPC1n2ZxIDrLSZOvyx1gNfPPzWQezrggQ5VG37VMW7axvD8kbf2pQi+X/GVItTi7MQp2yTAy+uN89Lvai99etpphaCZYH2z8vxwdL5/0xVnO+El9XqG1Woxp6Bj04bc5XHCqjtpXiOeGvuacr0/dRt5+09 X-Forefront-PRVS: 02638D901B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39850400002)(39840400002)(39410400002)(39400400002)(39450400003)(42186005)(6512007)(66066001)(48376002)(47776003)(189998001)(6486002)(50986999)(6506006)(5003940100001)(53936002)(5660300001)(305945005)(6666003)(6916009)(42882006)(50226002)(7736002)(8676002)(25786009)(4326008)(81166006)(2906002)(36756003)(6116002)(38730400002)(110136004)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR0701MB1040; H:b.semihalf.local; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0701MB1040; 23:n213dVcb0EKgOgVoHaAmCHq7U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ZFNYflDLDM47/u2h9zwXIQls/WBul97b4oNpiW2wfDbGO+RqwzXwu4w3ytM/FK6DEnOXGgaRCbsZWTUfhVqMWvPrHjE8O2I3veKRTcPS+ePqp7ZcHT2ZouRAk9Nb5COD66pK9C0Nz9mKAmwGnTFp5NtyrWFS8jLbwAn+p5Vie43Iy7IPR7oVAJfKn8XEHfpamuJbWEfh1/0m2jBieptk3u2PFKrTzwYQGe5s+chuKtdpBO/pagelJ9zN9cOel4fWmdaNnVoA4vSS1Q==; 5:/bJykpWTeN+OcaAEXLunT5g1h4YnP6XfZSBwfNOUE123HOYDcK2FZs0c0NFOTxngqB0M4LYykvUJXUgFf9ifzVyTeP/1voPzMqGl5JYS521UfBRb0e0PIyzit/a6yCIWMjj+qPgtQFKZ3NgfFOQ1LA==; 24:VQDJCHrNwfxmy/7eF8qXFQtZKkf6AxrRNRhgPlm7TGlGyGyMxxIXE3fBQM3gSxcACpS+TFiskHN2ubEFg4/0U/NRkUlpznqUgGVLLR+ZNpw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR0701MB1040; 7:y17cUxH9ttei+dVXXszVxrDEnH0QBO36K7FAMxPhbCx3+gMf2y/BWoH+jAV9R97CPCagxK0qmTQUhO4oqoLZxJyVp1dVxD/JH5XTEFAsEINORaA27mQtAeCCqKJK6hdSXqJxo8TFOnAkX/BlOIElmNT5wJPOwD5wzcQdO8enHth7odlbRLokTJkWkf5+9Fs9qV8gki5W2lch/2Zp1rNEjNhttTbWp5JR9W09SkqHt0svQD2Fw25mo0NqRPzmc/lKUqtxdG701S7rR6y7qtXEjTI44PPjh7ypdEcrPkukOBtEMxNZLkVFp/HxtIvTC2dM6hkHVWYoG8Fot2X3IUgnug== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2017 12:21:18.0322 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0701MB1040 Subject: [dpdk-dev] [PATCH] usertools: use /sys/devices/system/cpu for CPU layout script 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, 31 Mar 2017 12:21:21 -0000 Some platforms do not have core/socket info in /proc/cpuinfo. Signed-off-by: Andriy Berestovskyy --- usertools/cpu_layout.py | 53 +++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py index 0e049a6..5735891 100755 --- a/usertools/cpu_layout.py +++ b/usertools/cpu_layout.py @@ -4,6 +4,7 @@ # BSD LICENSE # # Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright(c) 2017 Cavium Networks Ltd. All rights reserved. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -38,40 +39,32 @@ sockets = [] cores = [] core_map = {} - -fd = open("/proc/cpuinfo") -lines = fd.readlines() +base_path = "/sys/devices/system/cpu" +fd = open("{}/kernel_max".format(base_path)) +max_cpus = int(fd.read()) fd.close() - -core_details = [] -core_lines = {} -for line in lines: - if len(line.strip()) != 0: - name, value = line.split(":", 1) - core_lines[name.strip()] = value.strip() - else: - core_details.append(core_lines) - core_lines = {} - -for core in core_details: - for field in ["processor", "core id", "physical id"]: - if field not in core: - print("Error getting '%s' value from /proc/cpuinfo" % field) - sys.exit(1) - core[field] = int(core[field]) - - if core["core id"] not in cores: - cores.append(core["core id"]) - if core["physical id"] not in sockets: - sockets.append(core["physical id"]) - key = (core["physical id"], core["core id"]) +for cpu in xrange(max_cpus + 1): + try: + fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu)) + except: + break + core = int(fd.read()) + fd.close() + 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(core["processor"]) + core_map[key].append(cpu) -print("============================================================") -print("Core and Socket Information (as reported by '/proc/cpuinfo')") -print("============================================================\n") +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("sockets = ", sockets) print("") -- 2.7.4