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 9885EA0C4C; Tue, 23 Nov 2021 23:15:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 216A8410F6; Tue, 23 Nov 2021 23:15:36 +0100 (CET) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by mails.dpdk.org (Postfix) with ESMTP id 3209740040 for ; Tue, 23 Nov 2021 23:15:35 +0100 (CET) Received: by mail-lf1-f54.google.com with SMTP id bi37so1737712lfb.5 for ; Tue, 23 Nov 2021 14:15:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=juqxhbLhtMnSWxsbgAgJzjySqdjI/fs4mi3FxmehqBI=; b=S9a4ZERx3j9A3hnOgoX9yn5WMyKPlkSds0IHBnctkVgD7V3Nj5HtbugUcYo9EeJ96q 1D3iulUqxEWzlawQe2xUd7+dHI4qSXp/1iq6WNpigYHinBjFulsXLDn+TZG9yOfSXsQN Q0QYvQdCwDqJMEoRRYBGP9G9+YkDyRmwhgx2MN+wyKRjvQ0K3muqK32wTvbz8LUSrgwd QNRgTblIF1nSaJEynaPNyIUwWTqw6XwEBbkFCzjDpd19gk6Hp6jjVD0OxrtEtAKFi0xh xE9arEZ6XZD6WVptURJu3uXn+fvPmUSB8jr2iWV5e4aSHG+Lml5SB+avdGB7DDra0EMX YcSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=juqxhbLhtMnSWxsbgAgJzjySqdjI/fs4mi3FxmehqBI=; b=gE8o7C6HIphTMdxmLOY2Zn5cyEFGi7PfaaADrtJ8mjP9aeXAImWPVmCRvrQQKvDMmG PaxH63DGYEyZRAFeo+GqrEo8Ax5RQL/fDYNsZQeq8dUvotSvMhu67idgJigdPdo/rgul MicrModZocxTB6Bi7Ve68bZQZfIIvyJKJtKsUDT5lG0DTbUx97l/lqAeigIYO6es+TDN ssXhjPh/iMofKMWE5BhNOyzhAzGCqKB/iykhTG/E1nMme2Ix+cCem2BWaa7rNTcsipw3 iXqvsZxYAQ+nHTYfmYvEEUqycYv7zCTlCxls8yK/cHqn3nfgt0pmPnX3+H0XWMs2cgH1 MXkA== X-Gm-Message-State: AOAM531dMMg+KJ/hcH1CCxhVJAgHPf6im0mb2M80l/f05JIwiM0O+NsB MDEtu0RO9MHDpn/iwbBaUbo= X-Google-Smtp-Source: ABdhPJwD6criMhi0QkE5EmLNjBaMYsx3Po7QUhRCFOitNplrawlylwZPjjBmpZm8wHn2ec/TYk4+EA== X-Received: by 2002:a05:6512:22c7:: with SMTP id g7mr8760021lfu.668.1637705734567; Tue, 23 Nov 2021 14:15:34 -0800 (PST) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id h10sm1416562lfv.56.2021.11.23.14.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Nov 2021 14:15:34 -0800 (PST) Date: Wed, 24 Nov 2021 01:15:33 +0300 From: Dmitry Kozlyuk To: Jie Zhou 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: <20211124011533.7623c5ae@sovereign> In-Reply-To: <1635216361-23641-11-git-send-email-jizh@linux.microsoft.com> 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> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 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") [...]