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 E5D39A0C55; Wed, 1 Dec 2021 01:29:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 737E14068C; Wed, 1 Dec 2021 01:29:51 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B655A4067B for ; Wed, 1 Dec 2021 01:29:49 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1061) id CEB5D20E0BF5; Tue, 30 Nov 2021 16:29:48 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CEB5D20E0BF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1638318588; bh=vK6Mf/6W3t7uHeDPD3OWZWJPMh5BhRfGj1wWtVwlzow=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FquCnkeu9BKrdBIddoNFYYhQL26BOjOjfLLyqq/yRsdJWCHXV9h8ixq6D6SRiwG6E nAUBnfeRwHMtLwGUO4Gbv+LiS+atU4EpqxuEe989UIA4CcKz0y5N1y2rNujIblgipP btmQScIetaqDkEvBpUqNloVHQmY8cxt+dJJwA1kc= Date: Tue, 30 Nov 2021 16:29:48 -0800 From: Jie Zhou To: Dmitry Kozlyuk Cc: dev@dpdk.org, roretzla@microsoft.com, navasile@linux.microsoft.com, dmitrym@microsoft.com, pallavi.kadam@intel.com, talshn@nvidia.com, thomas@monjalon.net, aconole@redhat.com Subject: Re: [PATCH v8 10/11] app/test: replace .sh scripts with .py scripts Message-ID: <20211201002948.GA14219@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1635215204-20604-1-git-send-email-jizh@linux.microsoft.com> <1635216361-23641-1-git-send-email-jizh@linux.microsoft.com> <1635216361-23641-11-git-send-email-jizh@linux.microsoft.com> <20211124011533.7623c5ae@sovereign> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211124011533.7623c5ae@sovereign> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Wed, Nov 24, 2021 at 01:15:33AM +0300, Dmitry Kozlyuk wrote: > 2021-10-25 19:46 (UTC-0700), Jie Zhou: > > - Add python script to check if system supports hugepages > > - Remove corresponding .sh scripts > > - Replace calling of .sh with corresponding .py in meson.build > > > > Signed-off-by: Jie Zhou > > --- > > app/test/has-hugepage.sh | 11 ----------- > > app/test/has_hugepage.py | 25 +++++++++++++++++++++++++ > > app/test/meson.build | 2 +- > > 3 files changed, 26 insertions(+), 12 deletions(-) > > delete mode 100755 app/test/has-hugepage.sh > > create mode 100644 app/test/has_hugepage.py > > > > 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() > > Please follow Python's preferred naming style, "os_name". > > > +if osName == "Linux": > > + with open("/proc/sys/vm/nr_hugepages") as file_o: > > + content = file_o.read() > > + print(content) > > Compared to shell version, lost is the logic to print 0 in case of a failure. > > > +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. > > I honestly don't see what this comment adds to the code below :) > > > + if ctypes.windll.kernel32.GetLargePageMinimum() > 0: > > + print("1") > > + else: > > + print("0") > > +else: > > + print("0") > [...] Thanks Dmitry. Addressed all in V9.