Skip to content

Commit

Permalink
Handle CPU count on AMD VMs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsrivastavv authored and LiliDeng committed Feb 4, 2023
1 parent 22a6276 commit 856f3db
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lisa/tools/lscpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,11 @@ def get_cpu_type(self, force_run: bool = False) -> CpuType:
f"Unknow cpu type. The output of lscpu is {result.stdout}"
)

def get_cpu_model_name(self, force_run: bool = False) -> str:
def get_cpu_model_name(self, force_run: bool = False) -> Optional[str]:
result = self.run(force_run=force_run)
matched = self.__cpu_model_name.findall(result.stdout)
assert_that(
len(matched),
f"model name should have exact one line, but got {matched}",
).is_equal_to(1)
if len(matched) == 0:
return None

return str(matched[0])

Expand Down
33 changes: 32 additions & 1 deletion microsoft/testsuites/core/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
hyperv_interrupt_substr = ["hyperv", "Hypervisor", "Hyper-V"]


EPYC_ROME_NUMA_NODE_SIZE = 4
EPYC_MILAN_NUMA_NODE_SIZE = 8


@TestSuiteMetadata(
area="core",
category="functional",
Expand Down Expand Up @@ -68,7 +72,23 @@ def l3_cache_check(self, node: Node, log: Logger) -> None:
"No support for NUMA setting. https://t.ly/x8k3"
)

cpu_info = node.tools[Lscpu].get_cpu_info()
lscpu = node.tools[Lscpu]
threads_per_core = lscpu.get_thread_per_core_count()
processor_name = lscpu.get_cpu_model_name()

if processor_name:
if "7452" in processor_name:
# This is AMD EPYC Rome processor series
effective_numa_node_size = EPYC_ROME_NUMA_NODE_SIZE * threads_per_core
self._verify_node_mapping(node, effective_numa_node_size)
return
elif "7763" in processor_name:
# This is AMD EPYC Milan processor series
effective_numa_node_size = EPYC_MILAN_NUMA_NODE_SIZE * threads_per_core
self._verify_node_mapping(node, effective_numa_node_size)
return

cpu_info = lscpu.get_cpu_info()
for cpu in cpu_info:
assert_that(
cpu.l3_cache,
Expand Down Expand Up @@ -204,3 +224,14 @@ def _create_stimer_interrupts(self, node: Node, cpu_count: int) -> None:
process = node.tools[TaskSet].run_on_specific_cpu(i)
time.sleep(1)
process.kill()

def _verify_node_mapping(self, node: Node, numa_node_size: int) -> None:
cpu_info = node.tools[Lscpu].get_cpu_info()
cpu_info.sort(key=lambda cpu: cpu.cpu)
for i, cpu in enumerate(cpu_info):
numa_node_id = i // numa_node_size
assert_that(
cpu.l3_cache,
"L3 cache of each core must be mapped to the NUMA node "
"associated with the core.",
).is_equal_to(numa_node_id)

0 comments on commit 856f3db

Please sign in to comment.