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 2CEE9A0550; Wed, 10 Feb 2021 18:41:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F202540693; Wed, 10 Feb 2021 18:41:25 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 2D9D940142 for ; Wed, 10 Feb 2021 18:41:24 +0100 (CET) IronPort-SDR: Vq7SfkZ3jxWEwD0KlAg1KEJWyTppaZMxzFnPZFzYP4lAmE9ENuxrMkSfmCgLBS682pKw7ejBQm BT5cAzg7Nq+Q== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="169794957" X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="169794957" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2021 09:41:24 -0800 IronPort-SDR: 96C3Oa3rzy+p9qFI3HnjdB1nfajVKnu+McKZYuL+Joz5Co3YHqJcYypPNJwKZJ8A7uy3hWD3LP 930mfK8vSyPg== X-IronPort-AV: E=Sophos;i="5.81,168,1610438400"; d="scan'208";a="396791409" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.247.83]) ([10.213.247.83]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2021 09:41:22 -0800 To: Sarosh Arif , sthemmin@microsoft.com Cc: dev@dpdk.org, thomas@monjalon.net References: <20201202110654.20923-1-sarosh.arif@emumba.com> <20210210061605.30648-1-sarosh.arif@emumba.com> From: "Burakov, Anatoly" Message-ID: Date: Wed, 10 Feb 2021 17:41:21 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20210210061605.30648-1-sarosh.arif@emumba.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [v3 PATCH] usertools: show valid hugepage sizes if user requests an invalid hugepage size 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" On 10-Feb-21 6:16 AM, Sarosh Arif wrote: > If user requests a hugepage size which is not supported by the system, > currently user gets an error message saying that the requested size > is not a valid system huge page size. In addition to this if we display > the valid hugepage sizes it will be convenient for the user to request > the right size next time. > > Signed-off-by: Sarosh Arif > --- > v2: > pass string in sys.exit() to remove pylint warning > v3: > modify get_valid_page_sizes() > --- > > usertools/dpdk-hugepages.py | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py > index 70432f9cd..57ae9f391 100755 > --- a/usertools/dpdk-hugepages.py > +++ b/usertools/dpdk-hugepages.py > @@ -43,6 +43,12 @@ def is_numa(): > return os.path.exists('/sys/devices/system/node') > > > +def get_valid_page_sizes(path): > + '''Extract valid hugepage sizes''' > + dir = os.path.dirname(path) > + pg_sizes = (d.split("-")[1] for d in os.listdir(dir)) > + return " ".join(pg_sizes) > + > def get_hugepages(path): > '''Read number of reserved pages''' > with open(path + '/nr_hugepages') as nr_hugepages: > @@ -59,9 +65,8 @@ def set_hugepages(path, pages): > except PermissionError: > sys.exit('Permission denied: need to be root!') > except FileNotFoundError: > - filename = os.path.basename(path) > - size = filename[10:] > - sys.exit('{} is not a valid system huge page size'.format(size)) > + sys.exit("Invalid page size. Valid page sizes: {}".format( > + get_valid_page_sizes(path))) Nitpicking, but i think this indentation wouldn't be OK with a PEP-8 style checker. This should be better: sys.exit("Invalid page size. Valid page sizes: {}" .format(get_validpage_sizes(path)) (note the alignment of .format with the quote) Otherwise, LGTM Acked-by: Anatoly Burakov > if get_hugepages(path) != pages: > sys.exit('Unable to reserve required pages.') > > -- Thanks, Anatoly