From patchwork Wed Feb 10 06:16:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarosh Arif X-Patchwork-Id: 87840 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C9732A054F; Wed, 10 Feb 2021 07:17:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4AC1F40693; Wed, 10 Feb 2021 07:17:05 +0100 (CET) Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by mails.dpdk.org (Postfix) with ESMTP id 90D1740147 for ; Wed, 10 Feb 2021 07:17:04 +0100 (CET) Received: by mail-ej1-f46.google.com with SMTP id a9so1941254ejr.2 for ; Tue, 09 Feb 2021 22:17:04 -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=FLIqHt98J/juPBPpTng4N2O/da7KstksTEmvlpy0rjs=; b=P4IyxCDnNSNqBCEAM+f+OyVVqtG3WkSBw++Mxph43UC7yPmfuW8s+aOtTY7Mc4DVQ/ zyum9A687fc8DFHMrCXtTTOkRXnujn05S9jfH1DZ2W6EeqiD23VRSib1miMrCz9mXULb 8KTFuWDR6Ee/nCVFSEw2fuRUW/fUbZpZWlMH1MvaFtKETOkRWW51KJ0a4eNgrggzqkib JOudmLDRjBHxlfbq2xGP2B/B2OXub/gNlhNj36oDnXF3yxCH5ssNLFBQ7XJGMWqr2ZuB UTIULPGinc8rsVOB1Wv6U9J1BKRDUn7q6MbkZHzipRHrlF6a+MWeBUDQ/NWwo/xv3JtB Zg+g== 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=FLIqHt98J/juPBPpTng4N2O/da7KstksTEmvlpy0rjs=; b=XuH8cR4X+Kktjpo8ra1rAwu0d1IQcFc2iCV+7X2KaRu4BmLwVI6PVabaNT4wNFL4Kb 18idqkH6KXheAA4d9TOexNfHD6EMwH54oOQS23/ynxUXKo7MYM2cEym3q4gTMQTbPed6 +EfNYVWYtO8kjKRzpKAwfcNLoST52GnT6Q+UBAIHoiwXgfqGcVbRthqQRTq3DK6zyxXt QqaSflrAuZLKaD36dUz3MJTUydmFCC2Dfz9UoFse0bihLLcJs2bBx1CRftTq0Cig2aax cSylquG0jM79gAerf40CZjUTAU99MJDPGF2wHaW7DRWs2hqKQ5I6K4ab0nNNEiydRvIC peAQ== X-Gm-Message-State: AOAM5310JGALAq1/xVzsn6P3Gx+9rzgX7wUCOKjP6HpGTj+Dq6jB60SD krKzFyz79hWeZgXcdbYh3Ch72g== X-Google-Smtp-Source: ABdhPJxrKgWNJyfg3UYK0TctR38F/CwSL8HzQnZ+9wXic7uRvG1Gzi8edT4nFi/C/1aRvrRNZjqjdw== X-Received: by 2002:a17:907:767c:: with SMTP id kk28mr1401791ejc.98.1612937824191; Tue, 09 Feb 2021 22:17:04 -0800 (PST) Received: from localhost.localdomain ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id hc40sm470170ejc.50.2021.02.09.22.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 22:17:03 -0800 (PST) From: Sarosh Arif To: sthemmin@microsoft.com Cc: dev@dpdk.org, anatoly.burakov@intel.com, thomas@monjalon.net, Sarosh Arif Date: Wed, 10 Feb 2021 11:16:05 +0500 Message-Id: <20210210061605.30648-1-sarosh.arif@emumba.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201202110654.20923-1-sarosh.arif@emumba.com> References: <20201202110654.20923-1-sarosh.arif@emumba.com> MIME-Version: 1.0 Subject: [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" 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 Acked-by: Anatoly Burakov --- 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))) if get_hugepages(path) != pages: sys.exit('Unable to reserve required pages.')