-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhugepages.py
64 lines (52 loc) · 1.44 KB
/
hugepages.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Author(s): Kamil Vojanec <[email protected]>
Copyright: (C) 2024 CESNET, z.s.p.o.
Hugepage configuration module.
"""
from pathlib import Path
from typing import Union
from lbr_testsuite import executable
def configure_hugepages(
huge_alloc: str = "8G",
huge_pagesize: str = "1G",
huge_dir: Union[str, Path] = Path("/mnt/huge"),
):
"""Configure hugepages using dpdk-hugepages tool.
Parameters
----------
huge_alloc : str
Hugepages to allocate. String contains a numeric value with
K, M or G suffix.
huge_pagesize : str
Size of a single hugepage. String contains a numeric value
with K, M or G suffix.
huge_dir : str or Path.
Path to the hugepage mountpoint directory.
"""
executable.Tool(
[
"dpdk-hugepages",
"--setup",
huge_alloc,
"--pagesize",
huge_pagesize,
"--directory",
str(huge_dir),
]
).run()
def clear_hugepages(huge_dir: Union[str, Path] = Path("/mnt/huge")):
"""Unmount and clear previously allocated hugepages.
Parameters
----------
huge_dir : str or Path
Path to the directory where hugepages are mounted.
"""
executable.Tool(
[
"dpdk-hugepages",
"--unmount",
"--directory",
str(huge_dir),
],
).run()
executable.Tool(["dpdk-hugepages", "--clear"]).run()