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