DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] usertools: show valid hugepage sizes if user requests an invalid hugepage size
@ 2020-11-30 12:47 Sarosh Arif
  2020-11-30 16:46 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Sarosh Arif @ 2020-11-30 12:47 UTC (permalink / raw)
  To: sthemmin; +Cc: dev, 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 <sarosh.arif@emumba.com>
---
 usertools/dpdk-hugepages.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
index 1be100ca3..f503ad377 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 show_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
+    print("valid page sizes: {}".format(valid_page_sizes))
 
 def set_hugepages(path, pages):
     '''Write the number of reserved huge pages'''
@@ -61,8 +69,9 @@ def set_hugepages(path, pages):
     except FileNotFoundError:
         filename = os.path.basename(path)
         size = filename[10:]
-        sys.exit('{} is not a valid system huge page size'.format(size))
-
+        print('{} is not a valid system huge page size'.format(size))
+        show_valid_page_sizes(path)
+        sys.exit()
 
 def show_numa_pages():
     '''Show huge page reservations on Numa system'''
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-02-11 23:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30 12:47 [dpdk-dev] [PATCH] usertools: show valid hugepage sizes if user requests an invalid hugepage size Sarosh Arif
2020-11-30 16:46 ` Stephen Hemminger
2020-11-30 16:47 ` Stephen Hemminger
2020-12-02 11:06 ` [dpdk-dev] [v2 PATCH] " Sarosh Arif
2021-02-05 18:17   ` Thomas Monjalon
2021-02-08 22:12     ` Stephen Hemminger
2021-02-09 11:34   ` Burakov, Anatoly
2021-02-10  6:16   ` [dpdk-dev] [v3 " Sarosh Arif
2021-02-10 17:41     ` Burakov, Anatoly
2021-02-11  8:20     ` [dpdk-dev] [v4 " Sarosh Arif
2021-02-11 16:26       ` Stephen Hemminger
2021-02-11 21:44       ` Thomas Monjalon
2021-02-11 23:16         ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).