From patchwork Thu Oct 14 03:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Zhou X-Patchwork-Id: 101534 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 88C21A0C4B; Thu, 14 Oct 2021 05:31:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C1B61411D2; Thu, 14 Oct 2021 05:30:34 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5459440E50 for ; Thu, 14 Oct 2021 05:30:21 +0200 (CEST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 5BA9120B9D14; Wed, 13 Oct 2021 20:30:20 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5BA9120B9D14 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1634182220; bh=gi2/6VZPgeudBvovS6dxBH4A0VwkpNotD9d0mVL/MgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=inFFMo5LBg3iEemb/bFXzfrYU1Q1AXSMGamekIjCoHWObN2hGQwV2nsc+lGn7BEDZ 5dtNqzejwhUzwr0P5GxfC1rMhho6r8E5Ec9O6YMCyAxM14AHDNQhAUaATpzsvCNa8b zUI4aC0loDWi5YY7dBB+PJ45nZznz8jlSfIEoCVc= From: Jie Zhou To: dev@dpdk.org Cc: dmitry.kozliuk@gmail.com, roretzla@microsoft.com, navasile@linux.microsoft.com, dmitrym@microsoft.com, pallavi.kadam@intel.com, talshn@nvidia.com, thomas@monjalon.net, aconole@redhat.com Date: Wed, 13 Oct 2021 20:30:13 -0700 Message-Id: <1634182214-24540-12-git-send-email-jizh@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1634182214-24540-1-git-send-email-jizh@linux.microsoft.com> References: <1630729155-24584-1-git-send-email-jizh@linux.microsoft.com> <1634182214-24540-1-git-send-email-jizh@linux.microsoft.com> Subject: [dpdk-dev] [PATCH v4 11/12] app/test: replace .sh scripts with .py scripts 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 Sender: "dev" - Add python script to get coremask - Add python script to check if system supports hugepages - Remove two corresponding .sh scripts - Replace calling of .sh with corresponding .py in meson.build Signed-off-by: Jie Zhou --- app/test/get-coremask.sh | 13 ------------- app/test/get_coremask.py | 12 ++++++++++++ app/test/has-hugepage.sh | 11 ----------- app/test/has_hugepage.py | 25 +++++++++++++++++++++++++ app/test/meson.build | 7 ++++--- 5 files changed, 41 insertions(+), 27 deletions(-) delete mode 100755 app/test/get-coremask.sh create mode 100644 app/test/get_coremask.py delete mode 100755 app/test/has-hugepage.sh create mode 100644 app/test/has_hugepage.py diff --git a/app/test/get-coremask.sh b/app/test/get-coremask.sh deleted file mode 100755 index bb8cf404d2..0000000000 --- a/app/test/get-coremask.sh +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2019 Intel Corporation - -if [ "$(uname)" = "Linux" ] ; then - cat /sys/devices/system/cpu/present -elif [ "$(uname)" = "FreeBSD" ] ; then - ncpus=$(/sbin/sysctl -n hw.ncpu) - echo 0-$(expr $ncpus - 1) -else -# fallback - echo 0-3 -fi diff --git a/app/test/get_coremask.py b/app/test/get_coremask.py new file mode 100644 index 0000000000..13939bcf78 --- /dev/null +++ b/app/test/get_coremask.py @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2021 Microsoft Corporation +"""This script returns the system cpu range""" + +import multiprocessing + +cpucount = multiprocessing.cpu_count() +if cpucount is None: + # use fallback cpu count + print("0-3") +else: + print("0-" + str(cpucount - 1)) diff --git a/app/test/has-hugepage.sh b/app/test/has-hugepage.sh deleted file mode 100755 index d600fad319..0000000000 --- a/app/test/has-hugepage.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2020 Mellanox Technologies, Ltd - -if [ "$(uname)" = "Linux" ] ; then - cat /proc/sys/vm/nr_hugepages || echo 0 -elif [ "$(uname)" = "FreeBSD" ] ; then - echo 1 # assume FreeBSD always has hugepages -else - echo 0 -fi diff --git a/app/test/has_hugepage.py b/app/test/has_hugepage.py new file mode 100644 index 0000000000..70107c61fd --- /dev/null +++ b/app/test/has_hugepage.py @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2021 Microsoft Corporation +"""This script checks if the system supports huge pages""" + +import platform +import ctypes + +osName = platform.system() +if osName == "Linux": + with open("/proc/sys/vm/nr_hugepages") as file_o: + content = file_o.read() + print(content) +elif osName == "FreeBSD": + # Assume FreeBSD always has hugepages enabled + print("1") +elif osName == "Windows": + # On Windows, determine if large page is supported based on the + # value returned by GetLargePageMinimum. If the return value is zero, + # the processor does not support large pages. + if ctypes.windll.kernel32.GetLargePageMinimum() > 0: + print("1") + else: + print("0") +else: + print("0") diff --git a/app/test/meson.build b/app/test/meson.build index f144d8b8ed..e1d003eff4 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -451,7 +451,7 @@ dpdk_test = executable('dpdk-test', driver_install_path), install: true) -has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0' +has_hugepage = run_command(py3, 'has_hugepage.py').stdout().strip() != '0' message('hugepage availability: @0@'.format(has_hugepage)) # some perf tests (eg: memcpy perf autotest)take very long @@ -459,8 +459,9 @@ message('hugepage availability: @0@'.format(has_hugepage)) timeout_seconds = 600 timeout_seconds_fast = 10 -get_coremask = find_program('get-coremask.sh') -num_cores_arg = '-l ' + run_command(get_coremask).stdout().strip() +list_of_cores = run_command(py3, 'get_coremask.py').stdout().strip() +message('list of cores: @0@'.format(list_of_cores)) +num_cores_arg = '-l ' + list_of_cores default_test_args = [num_cores_arg]