From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D093A04DB; Wed, 2 Dec 2020 12:08:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 91DA2C956; Wed, 2 Dec 2020 12:08:26 +0100 (CET) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by dpdk.org (Postfix) with ESMTP id 3B5AEC910 for ; Wed, 2 Dec 2020 12:08:25 +0100 (CET) Received: by mail-wm1-f42.google.com with SMTP id e25so6804031wme.0 for ; Wed, 02 Dec 2020 03:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CotttyPoA9dCLmWU29CqF6aGL2GuO1BQIRtGxU7niXQ=; b=kXLYjm5DItBRtIJOVJKemzPX1UPlxkmjhz5d++8/QDEuN0rpDZHS/9VLT9Yxr7sBEF 6UOH6KFA24uaX96EXeb5dX5RJtNK3ikHH8g83Y4yBU2WuzMUXWcieT8AwrA1mJq6SUNB nxQ8UBNZbxtwIXXHH5NqPW+v6D03qqW+7UZLAz2Dg0D6AGA649mT77htNcUtQcT0Fi2y QIPb7UKulnpzwggLRpBkIJUwi4Xg/3vfCcs59BNuvGPqqVyDyTHr6XKKnVOPrX6sVt8x 1VfXE+vwMsQPtBIqNVZ891SLbYMZEzTfg01wY8BR9yquVrr/0zT2xubEWxMh0oLK5mzZ lyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CotttyPoA9dCLmWU29CqF6aGL2GuO1BQIRtGxU7niXQ=; b=bWd7xkd6Bq3YU8mB+jRvJ9maYpldTD8RyVzaFAwc4KzJEiclqVU0RsvswjOuEHPKDj kpxcGFseMjxfQ4X/hKLuVpqULil2JcapzNLsZLw6HrPhAtQVcpxMAXfeHTltehAGLvFR Y8YeniGksyIS5YxLylVuwGmnvIG4yOTfgvPv0IS76QK+3y+lsYTMqG3WVk/ND/d7MuKj FaR8Ot23H7H9yd109DTkhyZVvLEtYksiHt4LqFSiOzj3g/wJ7HEUshjRc+kUSM+j3pVy TOxg8k9agzQlZvr+7bJ03zsoigq3dCcV8p9zDdrsdl7ZaD9QH4K9VSK9ZZIjfAaETMAI hSrQ== X-Gm-Message-State: AOAM532c+C6xIfM1px+rFb0+N1PQjXVbobmbWoKmB8wgx9oJkeuWb0Rb lWEjpocxYVjIQl2o8+Dvc1AkzA== X-Google-Smtp-Source: ABdhPJwg+37gnV169REzsaWFh02iUmWm5sv1e/Ydjjt/8FOId/x9YlgcNFgHcsm87bFMS0SVoAt2TA== X-Received: by 2002:a1c:bc41:: with SMTP id m62mr2604628wmf.46.1606907303775; Wed, 02 Dec 2020 03:08:23 -0800 (PST) Received: from localhost.localdomain ([101.50.93.221]) by smtp.gmail.com with ESMTPSA id w15sm1647828wrp.52.2020.12.02.03.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:08:23 -0800 (PST) From: Sarosh Arif To: sthemmin@microsoft.com Cc: dev@dpdk.org, Sarosh Arif Date: Wed, 2 Dec 2020 16:06:54 +0500 Message-Id: <20201202110654.20923-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130124719.23434-1-sarosh.arif@emumba.com> References: <20201130124719.23434-1-sarosh.arif@emumba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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.15 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" 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 --- usertools/dpdk-hugepages.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py index 1be100ca3..09d35bf55 100755 --- a/usertools/dpdk-hugepages.py +++ b/usertools/dpdk-hugepages.py @@ -49,6 +49,14 @@ def get_hugepages(path): return int(nr_hugepages.read()) return 0 +def get_valid_page_sizes(path): + valid_page_sizes = "" + hugepage_dir_path = os.path.split(path)[0] + 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 + 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))) def show_numa_pages(): '''Show huge page reservations on Numa system''' -- 2.25.1