File: has_hugepage.py

package info (click to toggle)
dpdk 22.11.8-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 103,460 kB
  • sloc: ansic: 1,826,258; python: 4,473; sh: 4,351; makefile: 2,001; awk: 53
file content (26 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2021 Microsoft Corporation
"""This script checks if the system supports huge pages"""

import platform
import ctypes

os_name = platform.system()
if os_name == "Linux":
    try:
        with open("/proc/sys/vm/nr_hugepages") as file_o:
            content = file_o.read()
            print(content)
    except:
        print("0")

elif os_name == "FreeBSD":
    # Assume FreeBSD always has hugepages enabled
    print("1")
elif os_name == "Windows":
    if ctypes.windll.kernel32.GetLargePageMinimum() > 0:
        print("1")
    else:
        print("0")
else:
    print("0")