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 E10A9A054A; Thu, 11 Feb 2021 09:20:48 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A81D1CC55C; Thu, 11 Feb 2021 09:20:48 +0100 (CET) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by mails.dpdk.org (Postfix) with ESMTP id 6D57D1CC505 for ; Thu, 11 Feb 2021 09:20:47 +0100 (CET) Received: by mail-ej1-f41.google.com with SMTP id f14so8679671ejc.8 for ; Thu, 11 Feb 2021 00:20:47 -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=0o2tlPI1enwsqsxdtDYGe8eMfuCXBaQEqqcndYirMlc=; b=Tmipi+TGis9Ff2SXMcsvfNAjB5kprNpld4Z7MmuDS6RVrhavSTkCuAOsdCEef1lYOx s/EZxwhQXAs4yzS8qHHKxMXsSpYFh3B4hv+MaIlwRXMaLCcFQ+muBAKSPFyUG/kGxNsR eWuX6vp1s+HAYSfRtnycWnNw5EOzAUpm9h83kmLAfSNgNeb9cH2ozL6dUqtGustr/vVI 9tK7ZfU5UZkzqCFOP3gRQgj5ZdJLWVFRSGkjTOTpHQyQHJt2tufrxOdwqfmK+oDzuUKc 64Aiw0FlOjp3NnnYkgUVhPKXzkRMvbXysvm5K9gO2PUHGMt48YxpCf0RtiUyhDnKbEtX yxnA== 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=0o2tlPI1enwsqsxdtDYGe8eMfuCXBaQEqqcndYirMlc=; b=oo6Uyo/CKeXmvyPrNN1Kl2ywHuVF9qVbsVwRk+szkK9iJVfsR/sPyqDhKYG6ar/e2v tsHgqBYHhJH9UmOC4EOSX4dWTLVGxNcQLYF1xvQbyuCNPtBzJUnnP2QSt5u+sWoGQ0lc XjnwstIKQ5WAd7k2nyuq/5GTZ9sRpqWkg8sCrrsG811yYtXz4zpkQaE/F0y9OwLWuR7O qZ6p0ZTLhS8TE3bpbo5qqLAlxeJKPq+1ifEOo+q1p0By+nQgOPUax/V3Xh2kbdh9AOeX KHcLLQuCCANeOectmwf9FcQqAOICKuHYj6syJf2fegPJdSkGy4KM5BEawMRopPoMzFX7 9BNg== X-Gm-Message-State: AOAM530nHSflV/8cp2Sn1kQRnhSnGntgXpr0X/D/y/18xff1sSvfQkvv 0wjcNcTn045G3It8dV3OXG5e7g== X-Google-Smtp-Source: ABdhPJx/qjTzcMnf1UBSplfdbXDwJVg12vgp6RUAW4WgtwqO+bfn33rWqnF9rDXLYjK5Ocwg0pRdWg== X-Received: by 2002:a17:906:3850:: with SMTP id w16mr7454182ejc.286.1613031647124; Thu, 11 Feb 2021 00:20:47 -0800 (PST) Received: from localhost.localdomain ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id p10sm3179242edj.2.2021.02.11.00.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 00:20:46 -0800 (PST) From: Sarosh Arif To: sthemmin@microsoft.com Cc: dev@dpdk.org, Sarosh Arif Date: Thu, 11 Feb 2021 13:20:04 +0500 Message-Id: <20210211082004.23626-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210061605.30648-1-sarosh.arif@emumba.com> References: <20210210061605.30648-1-sarosh.arif@emumba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" 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() v4: fix indentation --- 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..e68bae5a4 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))) if get_hugepages(path) != pages: sys.exit('Unable to reserve required pages.') -- 2.25.1