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 B8833A0547; Thu, 11 Feb 2021 22:44:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35B0222A24F; Thu, 11 Feb 2021 22:44:11 +0100 (CET) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 4EEC840147 for ; Thu, 11 Feb 2021 22:44:09 +0100 (CET) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id EB643A3C; Thu, 11 Feb 2021 16:44:06 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 11 Feb 2021 16:44:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm3; bh= ONwAfWD5soVdonen0dklMUNWQQT7SzQT/CANzcwAAl0=; b=Nqg7faZF9d3sewus a2wWgmgfAnkmAjGPiOEABQY13lunmgIxdnfy41MK1uaDBiaZ4h2fo+zEzId9+kCM RWUP0P7A4Yfj/x+0fB4FJhW7ozd2oHCrfyepvOHCJde/fu7T1cxuehOPKGGqbGJz 66OqTwE5KR6mDlAcEJm36Vki4+FBPQSk0CQRoJoNWobUXk6WgglJG8vqBGO4RutP lZkZHX1mPZIpa3rczrpEYO65GcuOlaUiIITmrRD3w5HsWLjsJJ7W7jb5ZifYb+Wt ytMdc6xwfwRvv0FLK3J6V8uv+O6YLQk5MjM8mfjs2z5RDXJmjDpXbH2phfT7X6ut ceMfNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=ONwAfWD5soVdonen0dklMUNWQQT7SzQT/CANzcwAA l0=; b=Y8gqoTcNSD8teW4wFhzS201+bXNI96XUFRvSRUEBnu+FDRsP5a58PkV86 2zFK596CPf1esn87QLGP5gC2OhPA4V0P1LrLzPVdEuMia/fhuVFianpufR7VK9Jp CpqN5ozblkohc/6Z9hLqG7vO1mK2owLUKEUoJXReUOchpBfZBDrGgt2hjaGQEKyc 2KHXaKBglwRjEknc9v3mJSQbVtgixgEIna8rihCVS7DIB9vUsTZajhLbXJpDgDr+ pvF5ONhTRWmnjcLmqi5yxwvjc9rvBTbLMZCFiMkHeG2etSIKxx8mtyI7cyMbgWjV tYqdjKyuSw6qnRBvkQZPhr1VAIdQg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrheelgdduheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id B9324240064; Thu, 11 Feb 2021 16:44:05 -0500 (EST) From: Thomas Monjalon To: Sarosh Arif Cc: sthemmin@microsoft.com, dev@dpdk.org Date: Thu, 11 Feb 2021 22:44:03 +0100 Message-ID: <7682463.TU6WbEMXMz@thomas> In-Reply-To: <20210211082004.23626-1-sarosh.arif@emumba.com> References: <20210210061605.30648-1-sarosh.arif@emumba.com> <20210211082004.23626-1-sarosh.arif@emumba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [v4 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" 11/02/2021 09:20, Sarosh Arif: > 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 > --- > --- 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) > + A second blank line is required here. > 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))) Alignment needs a small fixup. After these small changes, flake8 is OK. Applied, thanks.