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 5CA6AA0524; Fri, 5 Feb 2021 19:17:59 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D8AB640682; Fri, 5 Feb 2021 19:17:58 +0100 (CET) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id C80A44067B for ; Fri, 5 Feb 2021 19:17:56 +0100 (CET) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 9E32B5C005F; Fri, 5 Feb 2021 13:17:55 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 05 Feb 2021 13:17:55 -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= YdR0VZtuXnf8SSPOqj9masRLpfaY08+auHBHirxryKg=; b=hu4OJBqJ2ksJ5xla 5I+zjA/w1AnnYLCV88y/uAgX8OHdo5VnPLQfUhIeKS2BYDHiH94TCpWlgN6Zly15 d27pmrRIq8/tjMhUwrA55BYy1fYxhTDpQ3ZA/UHI4Yck4Y/abKQIJMAoAzYp+FTr dGHYRzsufj7fsv5iv0x2zODpPNCI3i8wDpxp7bcALuavnowtx4drO8aKtbdmqeU5 Zptvp4+U985B3gqA9qJZEQaXB/ASiL0S8ZDaFWBMh9XdkAOULmhSa6O4Jnc4DP6A Cqh1FojnijPCCY51jrEAhChEAyhjOyvTEKllhzIXH6mIftEO0l0+qQMcHzR70alA 3Uy/0w== 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=YdR0VZtuXnf8SSPOqj9masRLpfaY08+auHBHirxry Kg=; b=I3OYaf6sLhcjvWeC6OILstp9NDGlnIKaSSgZEIrbF1rKiBbjlUK45kDfr S1Mz0ni2K4Ohmug9KWQUrW/5BKWGYiL1Vpn5G1E9mRPaHzIwT3UCFMcI1NHOiT8A JjP/ntDiGlC3KH4vz+MYC7f7vxBpQaXDBy2oMU4NESRKqtS1Lcw/xpZzwsopk/dg ulkh3lZN6gJe4U4cxl4Ha+DS2vf3IqYaSLTTnvpsAVhJvGm/0BCyc2BOkkjU+Fpe Mioc8FB7JPD99EjsMH/gGhcm0GThdS+UHlR7eg+BT+7W+TCcFv6agPUGzpgEE8ag IJhmQ9JWQ55NjuKretHZ6pHaqTDfQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrgeeigdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdejueei iedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 83D1A1080069; Fri, 5 Feb 2021 13:17:54 -0500 (EST) From: Thomas Monjalon To: Sarosh Arif Cc: sthemmin@microsoft.com, dev@dpdk.org, stephen@networkplumber.org Date: Fri, 05 Feb 2021 19:17:52 +0100 Message-ID: <2159847.9U2c7sIdO1@thomas> In-Reply-To: <20201202110654.20923-1-sarosh.arif@emumba.com> References: <20201130124719.23434-1-sarosh.arif@emumba.com> <20201202110654.20923-1-sarosh.arif@emumba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [v2 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" 02/12/2020 12:06, 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 > --- > v2: > pass string in sys.exit() to remove pylint warning Stephen, is this version OK? > +def get_valid_page_sizes(path): > + valid_page_sizes = "" > + hugepage_dir_path = os.path.split(path)[0] Sorry for not following. Why this split? Maybe add a comment? > + hugepage_dirs = os.listdir(hugepage_dir_path) > + for each_dir in hugepage_dirs: > + hugepage_size = each_dir.split("-")[1] > + valid_page_sizes = valid_page_sizes + " " + hugepage_size Why not using += here? > + return valid_page_sizes > > def set_hugepages(path, pages): > '''Write the number of reserved huge pages''' > @@ -59,10 +67,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)))