DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sarosh Arif <sarosh.arif@emumba.com>
To: sthemmin@microsoft.com
Cc: dev@dpdk.org, Sarosh Arif <sarosh.arif@emumba.com>
Subject: [dpdk-dev] [v2 PATCH] usertools: show an error message if unable to reserve requested hugepages
Date: Thu, 17 Dec 2020 16:16:16 +0500	[thread overview]
Message-ID: <20201217111616.24057-1-sarosh.arif@emumba.com> (raw)
In-Reply-To: <20201130124533.23341-1-sarosh.arif@emumba.com>

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@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


  parent reply	other threads:[~2020-12-17 11:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 12:45 [dpdk-dev] [PATCH] " Sarosh Arif
2020-11-30 16:43 ` Stephen Hemminger
2020-12-17 11:16 ` Sarosh Arif [this message]
2020-12-17 18:15   ` [dpdk-dev] [v2 PATCH] " Stephen Hemminger
2021-01-07  8:06     ` Sarosh Arif
2021-01-07 15:37       ` Stephen Hemminger
2021-01-08  9:06 ` [dpdk-dev] [v3 " Sarosh Arif
2021-02-05 18:24   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201217111616.24057-1-sarosh.arif@emumba.com \
    --to=sarosh.arif@emumba.com \
    --cc=dev@dpdk.org \
    --cc=sthemmin@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).