usertools: show an error message if unable to reserve requested hugepages
Checks
Commit Message
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
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)
@@ -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: