Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/intel/xe_vm: Validate host memory for overcommit tests
@ 2026-09-25  9:49 Sobin Thomas
  2026-09-25 10:39 ` ✓ Xe.CI.BAT: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sobin Thomas @ 2026-09-25  9:49 UTC (permalink / raw)
  To: igt-dev; +Cc: nishit.sharma, Sobin Thomas

The amount of VRAM available for the overcommit tests varies
across platforms. As a result the host RAM and swap required to
support the overcommit workload also varies.

Query the platform RAM and swap space and visible VRAM before
running overcommit tests.
Require a minimum swap capacity relative to the platform memory
config and limit the overcommit working set to 50% of the currently
available RAM and swap size.

Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
 tests/intel/xe_vm.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index a0a6616c3..4ee2ebbc0 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -2611,6 +2611,13 @@ test_vm_overcommit(int fd, struct drm_xe_engine_class_instance *eci,
 	overcommit_size = ALIGN((uint64_t)(base_size * c->overcommit_mult), 4096);
 
 	num_bos = (overcommit_size / nf_bo_size) + 1;
+	igt_debug("Overcommit sizing: case=%s use_vram=%d multiplier=%d "
+		  "system_size=%" PRIu64 " MiB vram_size=%" PRIu64 " MiB "
+		  "base_size=%" PRIu64 " MiB overcommit_size=%" PRIu64 " MiB "
+		  "bo_size=%" PRIu64 " MiB num_bos=%d\n",
+		  c->name, c->use_vram, c->overcommit_mult,
+		  system_size >> 20, vram_size >> 20, base_size >> 20,
+		  overcommit_size >> 20, nf_bo_size >> 20, num_bos);
 	bos = calloc(num_bos, sizeof(*bos));
 	igt_assert(bos);
 
@@ -2634,6 +2641,8 @@ test_vm_overcommit(int fd, struct drm_xe_engine_class_instance *eci,
 	/* Create and bind data BOs */
 	actual_stage = create_data_bos(fd, vm, bos, num_bos, nf_bo_size, c->use_vram, data_addr,
 				       c->bo_flags, eci->gt_id, &num_bound);
+	igt_debug("Overcommit BO creation: case=%s actual_stage=%d num_bound=%d/%d\n",
+		  c->name, actual_stage, num_bound, num_bos);
 	/*
 	 * On EXPECT_CREATE nothing was bound so bail out entirely.
 	 * On EXPECT_BIND with no BOs bound there is nothing to execute either.
@@ -3499,9 +3508,33 @@ int igt_main()
 		const char *mode = (c->vm_flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE) ?
 					"fault" : "nonfault";
 		igt_subtest_f("overcommit-%s-%s", mode, c->name) {
+			uint64_t ram_mb = igt_get_total_ram_mb();
+			uint64_t swap_mb = igt_get_total_swap_mb();
+			uint64_t vram_mb = xe_visible_vram_size(fd, 0) >> 20;
+			uint64_t avail_ram_mb = igt_get_avail_ram_mb();
+			uint64_t required_mb;
+			uint64_t budget_mb;
+
 			igt_require(xe_has_vram(fd));
-			igt_require(xe_visible_vram_size(fd, 0));
-			test_vm_overcommit(fd, hwe_non_copy, c, (igt_get_avail_ram_mb() << 20),
+			igt_require(vram_mb);
+			igt_debug("Overcommit host memory: case=%s mode=%s total_ram=%" PRIu64
+				  " MiB available_ram=%" PRIu64 " MiB vram=%" PRIu64
+				  " MiB swap=%" PRIu64 " MiB swap_ratio=%" PRIu64 "%%\n",
+				  c->name, mode, ram_mb, avail_ram_mb, vram_mb, swap_mb,
+				  (vram_mb + ram_mb) ? swap_mb * 100 / (vram_mb + ram_mb) : 0);
+			igt_require_f(swap_mb * 100 >= (vram_mb + ram_mb) * 35,
+				      "Swap (%" PRIu64 " MiB) must be at least 35%% of "
+				      "VRAM + system RAM (%" PRIu64 " MiB)\n",
+				      swap_mb, vram_mb + ram_mb);
+			required_mb = ((c->use_vram ? vram_mb : avail_ram_mb) *
+				       c->overcommit_mult);
+			required_mb = ALIGN(required_mb, 64) + 64;
+			budget_mb = avail_ram_mb + swap_mb;
+			igt_require_f(required_mb <= budget_mb * 50 / 100,
+				      "Overcommit working set (%" PRIu64 " MiB) exceeds "
+				      "50%% of available RAM + swap (%" PRIu64 " MiB)\n",
+				       required_mb, budget_mb);
+			test_vm_overcommit(fd, hwe_non_copy, c, (avail_ram_mb << 20),
 					   xe_visible_vram_size(fd, 0));
 		}
 	}
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-05 16:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25  9:49 [PATCH i-g-t] tests/intel/xe_vm: Validate host memory for overcommit tests Sobin Thomas
2026-09-25 10:39 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-09-25 10:50 ` ✓ i915.CI.BAT: " Patchwork
2026-09-25 19:08 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-26  4:36 ` ✗ i915.CI.Full: " Patchwork
2026-10-05 16:28 ` [PATCH i-g-t] " Sharma, Nishit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox