diff mbox series

usertools: show hugepages requested/set on failure

Message ID 20210308222521.822118-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series usertools: show hugepages requested/set on failure | expand

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/travis-robot success travis build: passed
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon March 8, 2021, 10:25 p.m. UTC
In case the number of requested hugepages cannot be set,
a more detailed error message is printed.
The new message does not mention "reserve" because setting
can be reserving or clearing.
The filename and numbers requested/set are printed to ease debugging.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 usertools/dpdk-hugepages.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Thomas Monjalon March 25, 2021, 5:08 p.m. UTC | #1
08/03/2021 23:25, Thomas Monjalon:
> In case the number of requested hugepages cannot be set,
> a more detailed error message is printed.
> The new message does not mention "reserve" because setting
> can be reserving or clearing.
> The filename and numbers requested/set are printed to ease debugging.
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Applied
diff mbox series

Patch

diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
index fb368b6933..5c409eb16c 100755
--- a/usertools/dpdk-hugepages.py
+++ b/usertools/dpdk-hugepages.py
@@ -57,19 +57,21 @@  def get_hugepages(path):
     return 0
 
 
-def set_hugepages(path, pages):
+def set_hugepages(path, reqpages):
     '''Write the number of reserved huge pages'''
     filename = path + '/nr_hugepages'
     try:
         with open(filename, 'w') as nr_hugepages:
-            nr_hugepages.write('{}\n'.format(pages))
+            nr_hugepages.write('{}\n'.format(reqpages))
     except PermissionError:
         sys.exit('Permission denied: need to be root!')
     except FileNotFoundError:
         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.')
+    gotpages = get_hugepages(path)
+    if gotpages != reqpages:
+        sys.exit('Unable to set pages ({} instead of {} in {}).'.format(
+                 gotpages, reqpages, filename))
 
 
 def show_numa_pages():