public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: thomas.hellstrom@intel.com, nishit.sharma@intel.com,
	Sobin Thomas <sobin.thomas@intel.com>
Subject: [PATCH i-g-t 2/2] test/intel/xe_vm: Test to check no overcommit flag in fault mode
Date: Thu, 12 Feb 2026 19:03:03 +0000	[thread overview]
Message-ID: <20260212190305.804221-3-sobin.thomas@intel.com> (raw)
In-Reply-To: <20260212190305.804221-1-sobin.thomas@intel.com>

In existing tests there is no support to check no overcommit flag
(DRM_XE_VM_CREATE_NO_VM_OVERCOMMIT) which will disallow overcommit
during bind

- test_vm_fault_mode_no_overcommit(): Tests that fault-mode VMs with
  DRM_XE_VM_CREATE_NO_VM_OVERCOMMIT enabled properly prevent eviction
  and validate OOM error handling.

These tests ensure deterministic VM behavior and prevent unpredictable
eviction-related performance degradation in memory-constrained scenarios.

Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
 include/drm-uapi/xe_drm.h |   1 +
 tests/intel/xe_vm.c       | 131 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 128 insertions(+), 4 deletions(-)

diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h
index 077e66a68..2efe27ad5 100644
--- a/include/drm-uapi/xe_drm.h
+++ b/include/drm-uapi/xe_drm.h
@@ -983,6 +983,7 @@ struct drm_xe_vm_create {
 #define DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE	(1 << 0)
 #define DRM_XE_VM_CREATE_FLAG_LR_MODE	        (1 << 1)
 #define DRM_XE_VM_CREATE_FLAG_FAULT_MODE	(1 << 2)
+#define DRM_XE_VM_CREATE_FLAG_NO_VM_OVERCOMMIT  (1 << 3)
 	/** @flags: Flags */
 	__u32 flags;
 
diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
index cf45d1051..d908f6005 100644
--- a/tests/intel/xe_vm.c
+++ b/tests/intel/xe_vm.c
@@ -21,7 +21,9 @@
 #include "xe/xe_spin.h"
 #include <string.h>
 
-
+#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
+#define BO_SIZE xe_bb_size(fd, SZ_512M)
+#define MAX_BUFS ((int)(xe_visible_vram_size(fd, 0) / BO_SIZE))
 
 static uint32_t
 addr_low(uint64_t addr)
@@ -2387,9 +2389,6 @@ static void invalid_vm_id(int fd)
  */
 static void test_oom(int fd)
 {
-#define USER_FENCE_VALUE 0xdeadbeefdeadbeefull
-#define BO_SIZE xe_bb_size(fd, SZ_512M)
-#define MAX_BUFS ((int)(xe_visible_vram_size(fd, 0) / BO_SIZE))
 	uint64_t addr = 0x1a0000;
 	uint64_t vm_sync;
 	uint32_t bo[MAX_BUFS + 1];
@@ -2934,6 +2933,125 @@ gpu_done:
 	xe_vm_destroy(fd, vm);
 }
 
+/**
+ * SUBTEST: evict-vm-fault-no-overcommit
+ * Description: Test if vm fault mode with NO_VM_OVERCOMMIT flag prevents overcommit
+ * Functionality: NO_VM_OVERCOMMIT flag prevents per-VM overcommit in fault mode
+ * Test category: functionality test
+ */
+static void test_vm_fault_no_overcommit(int fd, struct drm_xe_engine_class_instance *eci,
+					uint64_t system_size, uint64_t vram_size,
+					uint64_t overcommit_multiplier)
+{
+	uint64_t overcommit_size;
+	uint32_t vm;
+	uint32_t *bos;
+	int num_bos;
+	size_t nf_bo_size = 64 * 1024 * 1024;  // 64MB per BO
+	int i;
+	int create_ret;
+	int bind_err;
+	bool overcommit_detected = false;
+	uint32_t bind_exec_queue;
+	uint64_t data_addr = 0x300000000;
+
+	struct drm_xe_sync bind_sync[1] = {
+		{
+		.type = DRM_XE_SYNC_TYPE_USER_FENCE,
+		.flags = DRM_XE_SYNC_FLAG_SIGNAL,
+		.timeline_value = USER_FENCE_VALUE
+		},
+	};
+
+	igt_debug("Starting fault-mode NO_VM_OVERCOMMIT test");
+
+	overcommit_size = ALIGN(vram_size * overcommit_multiplier, 4096);
+
+	if (overcommit_size > system_size) {
+		igt_debug("Limiting overcommit size from %llu MB to %llu MB",
+			  (unsigned long long)(overcommit_size >> 20),
+			  (unsigned long long)(system_size >> 20));
+		overcommit_size = ALIGN(system_size, 4096);
+	}
+
+	num_bos = (overcommit_size / nf_bo_size) + 1;
+	bos = calloc(num_bos, sizeof(*bos));
+	igt_assert(bos);
+
+	igt_debug("Fault mode NO_OVERCOMMIT: allocating %d BOs of %llu MB each, "
+		  "target overcommit=%llu MB, vram=%llu MB",
+		  num_bos, (unsigned long long)(nf_bo_size >> 20),
+		  (unsigned long long)(overcommit_size >> 20),
+		  (unsigned long long)(vram_size >> 20));
+
+	/* Create fault-mode VM with NO_VM_OVERCOMMIT flag */
+	vm = xe_vm_create(fd, DRM_XE_VM_CREATE_FLAG_LR_MODE |
+		       DRM_XE_VM_CREATE_FLAG_FAULT_MODE |
+		       DRM_XE_VM_CREATE_FLAG_NO_VM_OVERCOMMIT, 0);
+	igt_assert(vm);
+
+	bind_exec_queue = xe_bind_exec_queue_create(fd, vm, 0);
+
+	/* Try to create and bind BOs - should eventually fail or limit overcommit */
+	for (i = 0; i < num_bos; i++) {
+		struct {
+			uint64_t vm_sync;
+		} *data;
+
+		/* CREATE BO */
+		create_ret = __xe_bo_create(fd, 0, nf_bo_size,
+					    vram_if_possible(fd, eci->gt_id),
+					    DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM,
+					    NULL, &bos[i]);
+		if (create_ret) {
+			igt_debug("BO create failed with error %d (%s)",
+				  -create_ret, strerror(-create_ret));
+			overcommit_detected = true;
+			num_bos = i;
+			break;
+		}
+
+		igt_debug("BO created successfully - %llu MB",
+			  (unsigned long long)(nf_bo_size >> 20));
+
+		/* MAP BO */
+		data = xe_bo_map(fd, bos[i], 4096);
+		memset(data, 0, 4096);
+		bind_sync[0].addr = to_user_pointer(&data->vm_sync);
+
+		/* Try to bind with IMMEDIATE flag - subject to no overcommit check */
+		bind_err = __xe_vm_bind(fd, vm, bind_exec_queue, bos[i], 0,
+					data_addr + (i * nf_bo_size), nf_bo_size,
+					DRM_XE_VM_BIND_OP_MAP, DRM_XE_VM_BIND_FLAG_IMMEDIATE,
+					bind_sync, 1, 0, 0, 0);
+		if (bind_err) {
+			igt_debug("Bind failed at %d/%d with error %d (%s)",
+				  i, num_bos, -bind_err, strerror(-bind_err));
+			igt_assert_f(bind_err == -ENOMEM || bind_err == -ENOSPC,
+				     "Unexpected bind error %d (%s)", -bind_err,
+				     strerror(-bind_err));
+			overcommit_detected = true;
+			num_bos = i;
+			break;
+		}
+
+		munmap(data, 4096);
+	}
+
+	igt_debug("NO_VM_OVERCOMMIT test: overcommit %s (created %d BOs)",
+		  overcommit_detected ? "limited" : "completed",
+		  num_bos);
+
+	/* Cleanup */
+	xe_exec_queue_destroy(fd, bind_exec_queue);
+	for (i = 0; i < num_bos; i++) {
+		if (bos[i])
+			gem_close(fd, bos[i]);
+	}
+	free(bos);
+	xe_vm_destroy(fd, vm);
+}
+
 int igt_main()
 {
 	struct drm_xe_engine_class_instance *hwe, *hwe_non_copy = NULL;
@@ -3350,6 +3468,11 @@ int igt_main()
 		igt_assert(xe_visible_vram_size(fd, 0));
 		test_oom(fd);
 	}
+	igt_subtest("evict-vm-fault-no-overcommit") {
+		igt_require(xe_has_vram(fd));
+		igt_assert(xe_visible_vram_size(fd, 0));
+		test_vm_fault_no_overcommit(fd, hwe, system_size, vram_size, 2);
+	}
 
 	igt_fixture()
 		drm_close_driver(fd);
-- 
2.52.0


  parent reply	other threads:[~2026-02-12 19:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-12 19:03 [PATCH i-g-t 0/2] test/intel/xe_vm: Add overcommit and no‑overcommit handling tests Sobin Thomas
2026-02-12 19:03 ` [PATCH i-g-t 1/2] tests/intel/xe_vm: overcommit tests for fault-mode and non-fault-mode VMs Sobin Thomas
2026-02-12 19:03 ` Sobin Thomas [this message]
2026-02-24 19:41   ` [PATCH i-g-t 2/2] test/intel/xe_vm: Test to check no overcommit flag in fault mode Kamil Konieczny
2026-02-12 21:19 ` ✗ Xe.CI.BAT: failure for test/intel/xe_vm: Add overcommit and no‑overcommit handling tests Patchwork
2026-02-12 21:37 ` ✓ i915.CI.BAT: success " Patchwork
2026-02-13  0:58 ` ✗ i915.CI.Full: failure " Patchwork
2026-02-13 23:52 ` ✗ Xe.CI.FULL: " Patchwork
2026-02-17 13:57 ` [PATCH i-g-t 0/2] " Hellstrom, Thomas
2026-02-17 14:06   ` Hellstrom, Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260212190305.804221-3-sobin.thomas@intel.com \
    --to=sobin.thomas@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=nishit.sharma@intel.com \
    --cc=thomas.hellstrom@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox