From 5865ad48986c1bb34525ecc9396b2977feabbf44 Mon Sep 17 00:00:00 2001 From: Balamuruhan S Date: Mon, 13 May 2019 17:57:53 +0530 Subject: [PATCH] utils/memory: add method to get all supported hugepage sizes add `get_supported_huge_pages_size()` to get multiple hugepage sizes supported by the host. Suggested-by: Amador Pahim Signed-off-by: Balamuruhan S --- avocado/utils/memory.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/avocado/utils/memory.py b/avocado/utils/memory.py index 37436266..02e5f7d9 100644 --- a/avocado/utils/memory.py +++ b/avocado/utils/memory.py @@ -250,6 +250,18 @@ def get_page_size(): return int(output) +def get_supported_huge_pages_size(): + """ + Get all supported huge page sizes for this system. + + :return: list of Huge pages size (kB). + """ + output = os.listdir('/sys/kernel/mm/hugepages/') + # Given the items in this directory are in the format hugepages-kB, + # the will always start from index 10. + return [int(each[10:].rstrip('kB')) for each in output] + + def get_huge_page_size(): """ Get size of the huge pages for this system. -- GitLab