|
14 | 14 |
|
15 | 15 | from framework.guest_stats import MeminfoGuest |
16 | 16 | from framework.microvm import HugePagesConfig |
| 17 | +from framework.properties import global_props |
17 | 18 | from framework.utils import get_kernel_version, get_resident_memory |
18 | 19 |
|
19 | 20 | MEMHP_BOOTARGS = "console=ttyS0 reboot=k panic=1 memhp_default_state=online_movable" |
@@ -290,3 +291,76 @@ def test_snapshot_restore_persistence(uvm_plain_6_1, microvm_factory): |
290 | 291 | assert checksum_before == checksum_after, "Checksums didn't match" |
291 | 292 |
|
292 | 293 | validate_metrics(restored_vm) |
| 294 | + |
| 295 | + |
| 296 | +def timed_memory_hotplug(uvm, size, metrics, metric_prefix, fc_metric_name): |
| 297 | + """Wait for all memory hotplug events to be processed""" |
| 298 | + |
| 299 | + uvm.flush_metrics() |
| 300 | + |
| 301 | + api_time, total_time = uvm.hotplug_memory(size) |
| 302 | + |
| 303 | + fc_metrics = uvm.flush_metrics() |
| 304 | + |
| 305 | + metrics.put_metric( |
| 306 | + f"{metric_prefix}_api_time", |
| 307 | + api_time, |
| 308 | + unit="Seconds", |
| 309 | + ) |
| 310 | + metrics.put_metric( |
| 311 | + f"{metric_prefix}_total_time", |
| 312 | + total_time, |
| 313 | + unit="Seconds", |
| 314 | + ) |
| 315 | + metrics.put_metric( |
| 316 | + f"{metric_prefix}_fc_time", |
| 317 | + fc_metrics["memory_hotplug"][fc_metric_name]["sum_us"], |
| 318 | + unit="Microseconds", |
| 319 | + ) |
| 320 | + |
| 321 | + |
| 322 | +@pytest.mark.nonci |
| 323 | +@pytest.mark.parametrize( |
| 324 | + "hotplug_size", |
| 325 | + [ |
| 326 | + 1024, |
| 327 | + 2048, |
| 328 | + 4096, |
| 329 | + 8192, |
| 330 | + 16384, |
| 331 | + ], |
| 332 | +) |
| 333 | +@pytest.mark.parametrize( |
| 334 | + "huge_pages", |
| 335 | + [HugePagesConfig.NONE, HugePagesConfig.HUGETLBFS_2MB], |
| 336 | +) |
| 337 | +def test_memory_hotplug_latency( |
| 338 | + microvm_factory, guest_kernel_linux_6_1, rootfs, hotplug_size, huge_pages, metrics |
| 339 | +): |
| 340 | + """Test the latency of hotplugging memory""" |
| 341 | + |
| 342 | + for i in range(20): |
| 343 | + config = { |
| 344 | + "total_size_mib": hotplug_size, |
| 345 | + "slot_size_mib": 128, |
| 346 | + "block_size_mib": 2, |
| 347 | + } |
| 348 | + uvm_plain_6_1 = microvm_factory.build(guest_kernel_linux_6_1, rootfs, pci=True) |
| 349 | + uvm = uvm_booted_memhp(uvm_plain_6_1, None, None, False, config, None, None) |
| 350 | + |
| 351 | + if i == 0: |
| 352 | + metrics.set_dimensions( |
| 353 | + { |
| 354 | + "instance": global_props.instance, |
| 355 | + "cpu_model": global_props.cpu_model, |
| 356 | + "host_kernel": f"linux-{global_props.host_linux_version}", |
| 357 | + "performance_test": "test_memory_hotplug_latency", |
| 358 | + "hotplug_size": str(hotplug_size), |
| 359 | + "huge_pages": huge_pages, |
| 360 | + **uvm.dimensions, |
| 361 | + } |
| 362 | + ) |
| 363 | + |
| 364 | + timed_memory_hotplug(uvm, hotplug_size, metrics, "hotplug", "plug_agg") |
| 365 | + timed_memory_hotplug(uvm, 0, metrics, "hotunplug", "unplug_agg") |
| 366 | + timed_memory_hotplug(uvm, hotplug_size, metrics, "hotplug_2nd", "plug_agg") |
0 commit comments