-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tool to check supported hugepagesize
- Loading branch information
1 parent
6efdb9b
commit c09990a
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
import re | ||
from typing import Any, Set | ||
|
||
from lisa.executable import Tool | ||
from lisa.util import LisaException | ||
|
||
PATTERN_HUGEPAGE = re.compile( | ||
r"^hugepages-(?P<hugepage_size_in_kb>\d+)kB", | ||
) | ||
|
||
class Hugepages(Tool): | ||
@property | ||
def command(self) -> str: | ||
return "ls /sys/devices/system/node/node*/hugepages" | ||
|
||
@property | ||
def can_install(self) -> bool: | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return False | ||
|
||
def _initialize(self, *args: Any, **kwargs: Any) -> None: | ||
self._command = "ls /sys/devices/system/node/node*/hugepages" | ||
self._hugepage_sizes = set() | ||
|
||
def get_hugepage_sizes_in_kB(self): | ||
hugepage_size_dir_names = self.run("", shell=True) | ||
# e.g. hugepages-16777216kB hugepages-2048kB hugepages-524288kB | ||
for hugepage_size_dir_name in hugepage_size_dir_names.stdout.split(): | ||
matched_hugepage = PATTERN_HUGEPAGE.match(hugepage_size_dir_name) | ||
self._hugepage_sizes.add(matched_hugepage.group("hugepage_size_in_kb")) | ||
return self._hugepage_sizes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
Lscpu, | ||
Lsmod, | ||
Lspci, | ||
Hugepages, | ||
Modprobe, | ||
Mount, | ||
Ntttcp, | ||
|
@@ -99,6 +100,12 @@ def __init__(self, _node: Node, _testpmd: DpdkTestpmd) -> None: | |
def init_hugepages(node: Node, enable_gibibyte_hugepages: bool = False) -> None: | ||
mount = node.tools[Mount] | ||
if enable_gibibyte_hugepages: | ||
hugepages = node.tools[Hugepages] | ||
hugepage_sizes_in_kB = hugepages.get_hugepage_sizes_in_kB() | ||
if "1048576" not in hugepage_sizes_in_kB: | ||
This comment has been minimized.
Sorry, something went wrong.
squirrelsc
Member
|
||
raise SkippedException( | ||
f"Supported hugepage sizes in kB: {hugepage_sizes_in_kB}. 1048576 kB is not available" | ||
) | ||
mount.mount( | ||
name="nodev", | ||
point="/mnt/huge-1G", | ||
|
1 comment
on commit c09990a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the init procedure for hugepages into the tool too, we want to abstract both checks and usage into the tool so people don't need to deal with sysfs paths or mount commands. The advantage is we're giving them an API so we can improve or change the underlying implementation later, if needed.
I would comment the tool a little more thoroughly. Explaining the limitations: since we rely on sysfs this only supports Linux and not BSD, not Windows.
I'm a little iffy on relying on sysfs to check the available hugepage sizes, maybe we could link to the Linux docs on hugepages or some Linux source 🤔