[dpdk-dev] [v2 PATCH] usertools: show an error message if unable to reserve requested hugepages

Sarosh Arif sarosh.arif at emumba.com
Thu Dec 17 12:16:16 CET 2020


Sometimes the system is unable to reserve the requested hugepages because
enough space is not available in the RAM. In that case, currently the
script displays no error message hence the user can be under the delusion
that the hugepages he requested are all successfully reserved. This patch
displays an error message if the pages reserved are different from the
requested pages and shows the actual pages reserved.


Signed-off-by: Sarosh Arif <sarosh.arif at emumba.com>
---
v2:
use a global variable SHOW_HUGEPAGES to remove linter warnings
---
 usertools/dpdk-hugepages.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
index 1be100ca3..83332c096 100755
--- a/usertools/dpdk-hugepages.py
+++ b/usertools/dpdk-hugepages.py
@@ -16,6 +16,8 @@
 # systemd mount point for huge pages
 HUGE_MOUNT = "/dev/hugepages"
 
+# show hugepages flag
+SHOW_HUGEPAGES = False
 
 def fmt_memsize(kb):
     '''Format memory size in kB into conventional format'''
@@ -62,6 +64,10 @@ def set_hugepages(path, pages):
         filename = os.path.basename(path)
         size = filename[10:]
         sys.exit('{} is not a valid system huge page size'.format(size))
+    if get_hugepages(path) != pages:
+        print("Unable to reserve required pages. The pages reserved are:")
+        global SHOW_HUGEPAGES
+        SHOW_HUGEPAGES = True
 
 
 def show_numa_pages():
@@ -233,6 +239,9 @@ def main():
         metavar='SIZE',
         help='setup huge pages by doing clear, unmount, reserve and mount')
     args = parser.parse_args()
+
+    global SHOW_HUGEPAGES
+    SHOW_HUGEPAGES = args.show
 
     if args.setup:
         args.clear = True
@@ -260,7 +269,7 @@ def main():
             int(reserve_kb / pagesize_kb), pagesize_kb, node=args.node)
     if args.mount:
         mount_huge(pagesize_kb, HUGE_MOUNT)
-    if args.show:
+    if SHOW_HUGEPAGES:
         show_pages()
         print()
         show_mount()
-- 
2.25.1



More information about the dev mailing list