git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
log: close in cleanup stage
[dpdk.git]
/
usertools
/
dpdk-hugepages.py
diff --git
a/usertools/dpdk-hugepages.py
b/usertools/dpdk-hugepages.py
index
fb368b6
..
4fdb199
100755
(executable)
--- a/
usertools/dpdk-hugepages.py
+++ b/
usertools/dpdk-hugepages.py
@@
-29,7
+29,7
@@
def get_memsize(arg):
'''Convert memory size with suffix to kB'''
match = re.match(r'(\d+)([' + BINARY_PREFIX + r']?)$', arg.upper())
if match is None:
'''Convert memory size with suffix to kB'''
match = re.match(r'(\d+)([' + BINARY_PREFIX + r']?)$', arg.upper())
if match is None:
- sys.exit('{} is not a valid
page
size'.format(arg))
+ sys.exit('{} is not a valid size'.format(arg))
num = float(match.group(1))
suffix = match.group(2)
if suffix == "":
num = float(match.group(1))
suffix = match.group(2)
if suffix == "":
@@
-57,19
+57,21
@@
def get_hugepages(path):
return 0
return 0
-def set_hugepages(path, pages):
+def set_hugepages(path,
req
pages):
'''Write the number of reserved huge pages'''
filename = path + '/nr_hugepages'
try:
with open(filename, 'w') as nr_hugepages:
'''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(
req
pages))
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)))
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():
def show_numa_pages():
@@
-254,6
+256,8
@@
To a complete setup of with 2 Gigabyte of 1G huge pages:
pagesize_kb = get_memsize(args.pagesize)
else:
pagesize_kb = default_pagesize()
pagesize_kb = get_memsize(args.pagesize)
else:
pagesize_kb = default_pagesize()
+ if not pagesize_kb:
+ sys.exit("Invalid page size: {}kB".format(pagesize_kb))
if args.clear:
clear_pages()
if args.clear:
clear_pages()