Skip to content

Commit

Permalink
Tool to check supported hugepagesize
Browse files Browse the repository at this point in the history
  • Loading branch information
kanchansenlaskar committed Jun 9, 2024
1 parent 6efdb9b commit 1b4444e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lisa/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .git import Git
from .hibernation_setup import HibernationSetup
from .hostname import Hostname
from .meminfo import Meminfo
from .hwclock import Hwclock
from .hyperv import HyperV
from .interrupt_inspector import InterruptInspector
Expand Down Expand Up @@ -158,6 +159,7 @@
"Iperf3",
"HibernationSetup",
"Hostname",
"Meminfo",
"Hwclock",
"HyperV",
"InterruptInspector",
Expand Down
55 changes: 55 additions & 0 deletions lisa/tools/meminfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import re
from pathlib import PurePath
from typing import (List,Any)
from lisa.executable import Tool
from lisa.operating_system import Posix
from lisa.util import LisaException, constants, find_patterns_in_lines, get_matched_str

PATTERN_MEM_INFO = re.compile(
r"^(?P<mem_info_key>[^\s]+)\:\s+(?P<mem_info_key_value>.+)",
)
class Meminfo(Tool):

@property
def command(self) -> str:
return "cat /proc/meminfo"

@property
def can_install(self) -> bool:
return False

def _initialize(self, *args: Any, **kwargs: Any) -> None:
self._command = "cat /proc/meminfo"
self._mem_info_dict = {}

def _get_memoryinfo(self):
memoryinfo = self.run("", shell=True)
for memory_info_entry in memoryinfo.stdout.splitlines():
mem_info_content = MeminfoContent(memory_info_entry)
self._mem_info_dict[mem_info_content.mem_info_key]=mem_info_content.mem_info_key_value
return self._mem_info_dict

def get_hugepagesize(self):
if not "hugepagesize" in self._mem_info_dict:
self._get_memoryinfo()
return self._mem_info_dict.get("Hugepagesize", None)

class MeminfoContent:
def __init__(self, memory_info_entry_raw: str) -> None:
self.parse(memory_info_entry_raw)

def __str__(self) -> str:
return (
f"MeminfoKey: {self.mem_info_key} "
f"MeminfoKeyValue {self.mem_info_key_value} "
)

def parse(self, raw_str: str) -> None:
matched_mem_info = PATTERN_MEM_INFO.match(raw_str)
if matched_mem_info:
self.mem_info_key = matched_mem_info.group("mem_info_key")
self.mem_info_key_value = matched_mem_info.group("mem_info_key_value")
else:
raise LisaException("cannot find any matched memory info content")
8 changes: 8 additions & 0 deletions microsoft/testsuites/dpdk/dpdkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Lscpu,
Lsmod,
Lspci,
Meminfo,
Modprobe,
Mount,
Ntttcp,
Expand Down Expand Up @@ -99,6 +100,13 @@ 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:
meminfo = node.tools[Meminfo]
hugepagesize = meminfo.get_hugepagesize()

if hugepagesize != "1048576 KB":
raise SkippedException(
f"Expected 1048576 KB hugepages, found {hugepagesize} hugepages."
)
mount.mount(
name="nodev",
point="/mnt/huge-1G",
Expand Down

0 comments on commit 1b4444e

Please sign in to comment.