xref: /dpdk/buildtools/has-hugepages.py (revision 0aeaf75df8795573768b2d924a146dcb384e8fce)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright (c) 2021 Microsoft Corporation
3"""This script checks if the system supports huge pages"""
4
5import platform
6import ctypes
7
8os_name = platform.system()
9if os_name == "Linux":
10    try:
11        with open("/proc/sys/vm/nr_hugepages") as file_o:
12            content = file_o.read()
13            print(content)
14    except:
15        print("0")
16
17elif os_name == "FreeBSD":
18    # Assume FreeBSD always has hugepages enabled
19    print("1")
20elif os_name == "Windows":
21    if ctypes.windll.kernel32.GetLargePageMinimum() > 0:
22        print("1")
23    else:
24        print("0")
25else:
26    print("0")
27