From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C450A04B5; Tue, 27 Oct 2020 17:05:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 713C0BBBA; Tue, 27 Oct 2020 17:05:35 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 25E565AB7 for ; Tue, 27 Oct 2020 17:05:31 +0100 (CET) IronPort-SDR: SHNAlOYkF/bBf/jk0O2LD6KXmCTPTFbEh9hoyMVP3pgXser9gevBEF2tlOiG6HY7uYQ7uDPE22 36IkZEcWjtpw== X-IronPort-AV: E=McAfee;i="6000,8403,9787"; a="147965229" X-IronPort-AV: E=Sophos;i="5.77,424,1596524400"; d="scan'208";a="147965229" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 09:05:07 -0700 IronPort-SDR: s9E/MTMsTQRhfSdEyIB7m0+EnkoeXBMZ2pwIJNamLBvIPJo4Mv/g/1LZBRSgErEjqNEDOGohGA zXV2GJXiEdTg== X-IronPort-AV: E=Sophos;i="5.77,424,1596524400"; d="scan'208";a="535847908" Received: from bricha3-mobl.ger.corp.intel.com ([10.214.252.158]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 27 Oct 2020 09:05:03 -0700 Date: Tue, 27 Oct 2020 16:04:58 +0000 From: Bruce Richardson To: Juraj =?utf-8?Q?Linke=C5=A1?= Cc: "Ruifeng.Wang@arm.com" , "Honnappa.Nagarahalli@arm.com" , "Phil.Yang@arm.com" , "vcchunga@amazon.com" , "Dharmik.Thakkar@arm.com" , "jerinjacobk@gmail.com" , "hemant.agrawal@nxp.com" , "dev@dpdk.org" Message-ID: <20201027160458.GC956@bricha3-MOBL.ger.corp.intel.com> References: <1603280261-20206-1-git-send-email-juraj.linkes@pantheon.tech> <1603464488-25493-1-git-send-email-juraj.linkes@pantheon.tech> <1603464488-25493-4-git-send-email-juraj.linkes@pantheon.tech> <20201027112041.GD936@bricha3-MOBL.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Subject: Re: [dpdk-dev] [PATCH v4 3/6] build: optional NUMA and cpu counts detection 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Oct 27, 2020 at 03:50:46PM +0000, Juraj Linkeš wrote: > > > > -----Original Message----- > > From: Bruce Richardson > > Sent: Tuesday, October 27, 2020 12:21 PM > > To: Juraj Linkeš > > Cc: Ruifeng.Wang@arm.com; Honnappa.Nagarahalli@arm.com; > > Phil.Yang@arm.com; vcchunga@amazon.com; Dharmik.Thakkar@arm.com; > > jerinjacobk@gmail.com; hemant.agrawal@nxp.com; dev@dpdk.org > > Subject: Re: [PATCH v4 3/6] build: optional NUMA and cpu counts detection > > > > On Fri, Oct 23, 2020 at 04:48:05PM +0200, Juraj Linkeš wrote: > > > Add an option to automatically discover the host's numa and cpu counts > > > and use those values for a non cross-build. > > > Give users the option to override the per-arch default values or > > > values from cross files by specifying them on the command line with > > > -Dmax_lcores and -Dmax_numa_nodes. > > > > > > Signed-off-by: Juraj Linkeš > > > --- > > > buildtools/get_cpu_count.py | 7 ++++++ > > > buildtools/get_numa_count.py | 22 +++++++++++++++++ > > > buildtools/meson.build | 2 ++ > > > config/meson.build | 48 ++++++++++++++++++++++++++++++++++-- > > > meson_options.txt | 8 +++--- > > > 5 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 > > > buildtools/get_cpu_count.py create mode 100644 > > > buildtools/get_numa_count.py > > > > > > diff --git a/buildtools/get_cpu_count.py b/buildtools/get_cpu_count.py > > > new file mode 100644 index 000000000..386f85f8b > > > --- /dev/null > > > +++ b/buildtools/get_cpu_count.py > > > @@ -0,0 +1,7 @@ > > > +#!/usr/bin/python3 > > > +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2020 > > > +PANTHEON.tech s.r.o. > > > + > > > +import os > > > + > > > +print(os.cpu_count()) > > > diff --git a/buildtools/get_numa_count.py > > > b/buildtools/get_numa_count.py new file mode 100644 index > > > 000000000..f0c49973a > > > --- /dev/null > > > +++ b/buildtools/get_numa_count.py > > > @@ -0,0 +1,22 @@ > > > +#!/usr/bin/python3 > > > +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2020 > > > +PANTHEON.tech s.r.o. > > > + > > > +import ctypes > > > +import glob > > > +import os > > > +import subprocess > > > + > > > +if os.name == 'posix': > > > + if os.path.isdir('/sys/devices/system/node'): > > > + print(len(glob.glob('/sys/devices/system/node/node*'))) > > > + else: > > > + print(subprocess.run(['sysctl', 'vm.ndomains'], > > > +capture_output=True).stdout) > > > > I think you can shorten this, by just calling subprocess.run and not capturing > > anything, in which case the stdout will be printed as normal. > > > > subprocess.run(['sysctl', 'vm.ndomains']) > > > > This will also print out the resulting object (e.g. CompletedProcess(args=['ls', '-ls', '/sys/devices/system/node'], returncode=0)), but an assignment will take care of that. I'll make the change. > Not unless you are running interactively in the python3 REPL. For example: $ cat test_meminfo.py #! /usr/bin/env python3 from subprocess import run run(['cat', '/proc/meminfo']) $ python3 test_meminfo.py | tail -n 5 Hugepagesize: 2048 kB Hugetlb: 17825792 kB DirectMap4k: 1056788 kB DirectMap2M: 9758720 kB DirectMap1G: 88080384 kB $