usertools: show an error message if unable to reserve requested hugepages

Message ID 20201130124533.23341-1-sarosh.arif@emumba.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series usertools: show an error message if unable to reserve requested hugepages |

Checks

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

Commit Message

Sarosh Arif Nov. 30, 2020, 12:45 p.m. UTC
  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>
---
 usertools/dpdk-hugepages.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Nov. 30, 2020, 4:43 p.m. UTC | #1
On Mon, 30 Nov 2020 17:45:33 +0500
Sarosh Arif <sarosh.arif@emumba.com> wrote:

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

This is ok, but this code was written to go through python lint
cleanly. This patch introduces new warnings:


usertools/dpdk-hugepages.py:239:4: W0601: Global variable 'args' undefined at the module level (global-variable-undefined)
usertools/dpdk-hugepages.py:239:4: C0103: Constant name "args" doesn't conform to UPPER_CASE naming style (invalid-name)
  

Patch

diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
index 1be100ca3..3f6e62c8f 100755
--- a/usertools/dpdk-hugepages.py
+++ b/usertools/dpdk-hugepages.py
@@ -62,7 +62,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:")
+        show_pages()
+        args.show = False

 def show_numa_pages():
     '''Show huge page reservations on Numa system'''
@@ -232,6 +235,8 @@  def main():
         '--setup',
         metavar='SIZE',
         help='setup huge pages by doing clear, unmount, reserve and mount')
+
+    global args
     args = parser.parse_args()
 
     if args.setup: