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 EB320457E4; Fri, 16 Aug 2024 14:17:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A694D42DD3; Fri, 16 Aug 2024 14:17:06 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id 0D85642DBB for ; Fri, 16 Aug 2024 14:17:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723810625; x=1755346625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uRF0gaDMgIO617G8A5S69JKY6U7neMUAYedXnBVbZcs=; b=S+nx2Tzq4wHie2588bXpNiIPu/5+F/oK2TpwIK8q4tK8dIkZkFCu9GQV rHNo6WqB2sJYl7qmrRQMaQfBjwHtl1ROknXtgbeAAjfI3kCFXTwrrpP/1 PdT168/Onbm4WkE9gm6HaJrVnLEmQFX2o/aAz+USwZ274xDeC3CooNrXK DIu0A9TX49DypAZELBUrCWnQq2WRi46gHZ2Rdr8GhpI+Q8I6Di5EqFp4N FA4Jvu/HTOc4TuezhO9KWgLP8G+/sGN0F5kcRPk6rgscSvuRnzr5d7Pju mI6+HXPPKgnHlAmNZ7H/vLLPFo2G1DRtogLmSHLIiRn5sBzxjXni2LuEF w==; X-CSE-ConnectionGUID: +M2oenISTKehlhJ4Xqe2kw== X-CSE-MsgGUID: XJzIjAxASqyyN0WVBBVWLg== X-IronPort-AV: E=McAfee;i="6700,10204,11166"; a="22276057" X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="22276057" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2024 05:17:04 -0700 X-CSE-ConnectionGUID: yyHr2jrsTb23FX0sJLtK9A== X-CSE-MsgGUID: jfftRW8/QYqdDZZmfRWIng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,151,1719903600"; d="scan'208";a="59819885" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa010.fm.intel.com with ESMTP; 16 Aug 2024 05:17:03 -0700 From: Anatoly Burakov To: dev@dpdk.org, Robin Jarry Cc: bruce.richardson@intel.com Subject: [PATCH v2 3/4] usertools/dpdk-hugepages.py: sort by NUMA node Date: Fri, 16 Aug 2024 13:16:57 +0100 Message-ID: <8f79ca252aac7d47106e6660fb88ad122cd25fcc.1723810613.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <4844fc3a4604ffef789702752ff04699ab5118db.1723810613.git.anatoly.burakov@intel.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Currently, the list of per-NUMA node hugepages is displayed in glob order, which can be arbitrary. Fix it to sort the glob order. Signed-off-by: Anatoly Burakov --- usertools/dpdk-hugepages.py | 40 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py index bf2575ba36..54232ddf22 100755 --- a/usertools/dpdk-hugepages.py +++ b/usertools/dpdk-hugepages.py @@ -74,21 +74,37 @@ def set_hugepages(path, reqpages): gotpages, reqpages, filename)) +def get_numa_pages_node(node): + '''Read list of hugepage reservations on specific NUMA node''' + hp_path = f'/sys/devices/system/node/node{node}/hugepages' + if not os.path.exists(hp_path): + return + res = [] + for pg_sz_dir in os.listdir(hp_path): + pg_sz = int(pg_sz_dir[10:-2]) + nr_pages = get_hugepages(f'{hp_path}/{pg_sz_dir}') + if nr_pages > 0: + pg_sz_str = fmt_memsize(pg_sz) + total_sz_str = fmt_memsize(nr_pages * pg_sz) + res += [(nr_pages, pg_sz_str, total_sz_str)] + else: + res += [(0, None, None)] + return res + + def show_numa_pages(): '''Show huge page reservations on Numa system''' + # get list of NUMA nodes and sort them by integer order print('Node Pages Size Total') - for numa_path in glob.glob('/sys/devices/system/node/node*'): - node = numa_path[29:] # slice after /sys/devices/system/node/node - path = numa_path + '/hugepages' - if not os.path.exists(path): - continue - for hdir in os.listdir(path): - pages = get_hugepages(path + '/' + hdir) - if pages > 0: - kb = int(hdir[10:-2]) # slice out of hugepages-NNNkB - print('{:<4} {:<5} {:<6} {}'.format(node, pages, - fmt_memsize(kb), - fmt_memsize(pages * kb))) + nodes = sorted(int(node[29:]) + for node in glob.glob('/sys/devices/system/node/node*')) + for node in nodes: + pg_sz_data = get_numa_pages_node(node) + for nr_pages, pg_sz, total_sz in pg_sz_data: + if not nr_pages: + continue + print('{:<4} {:<5} {:<6} {}' + .format(node, nr_pages, pg_sz, total_sz)) def show_non_numa_pages(): -- 2.43.5