Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Dugast <francois.dugast@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Francois Dugast" <francois.dugast@intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [PATCH i-g-t] tests/intel/xe_exec_system_allocator: Test madvise(MADV_DONTNEED)
Date: Fri, 24 Apr 2026 10:16:47 +0200	[thread overview]
Message-ID: <20260424081647.516473-1-francois.dugast@intel.com> (raw)

Extend the compute test to make use of madvise(MADV_DONTNEED) on the input
array before reading from it after computation, so that its effects can be
checked by looking at GT stats or tracing for example with:

    sudo bpftrace -e 'kprobe:xe_migrate_from_vram { printf("%llu,%d,VRAM->SYSTEM\n", nsecs, tid); }'

Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Francois Dugast <francois.dugast@intel.com>
---
 tests/intel/xe_exec_system_allocator.c | 32 +++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/tests/intel/xe_exec_system_allocator.c b/tests/intel/xe_exec_system_allocator.c
index 5580099f7..5a6334b73 100644
--- a/tests/intel/xe_exec_system_allocator.c
+++ b/tests/intel/xe_exec_system_allocator.c
@@ -2267,6 +2267,7 @@ static void read_gt_stats_snapshot(int fd,
 /* compute flags */
 #define TOUCH_ONCE		(0x1 << 0)
 #define ACCESS_DEVICE_HOST	(0x1 << 1)
+#define USE_MADV_DONTNEED	(0x1 << 2)
 
 /**
  * SUBTEST: compute
@@ -2285,6 +2286,18 @@ static void read_gt_stats_snapshot(int fd,
  * Description: Run a simple compute kernel %arg[1] on a 2MB malloc'ed buffer
  * Test category: performance test
  *
+ * SUBTEST: eu-fault-4k-range-device-host-madvise-dontneed
+ * Description: Run a simple compute kernel %arg[1] on a 4KB malloc'ed buffer for which madvise(MADV_DONTNEED) is used
+ * Test category: performance test
+ *
+ * SUBTEST: eu-fault-64k-range-device-host-madvise-dontneed
+ * Description: Run a simple compute kernel %arg[1] on a 64KB malloc'ed buffer for which madvise(MADV_DONTNEED) is used
+ * Test category: performance test
+ *
+ * SUBTEST: eu-fault-2m-range-device-host-madvise-dontneed
+ * Description: Run a simple compute kernel %arg[1] on a 2MB malloc'ed buffer for which madvise(MADV_DONTNEED) is used
+ * Test category: performance test
+ *
  * arg[1]:
  *
  * @once-device:				touch the buffer only once, from the device
@@ -2321,7 +2334,7 @@ test_compute(int fd, struct drm_xe_engine_class_instance *eci, size_t size,
 	xe_wait_ufence(fd, &bo_sync->sync, USER_FENCE_VALUE, 0, FIVE_SEC);
 
 	env.loop_count = (flags & TOUCH_ONCE) ? 1 : env.array_size;
-	env.skip_results_check = !(flags & ACCESS_DEVICE_HOST);
+	env.skip_results_check = true;
 	env.vm = vm;
 
 	read_gt_stats_snapshot(fd, eci, &stats_before);
@@ -2343,6 +2356,22 @@ test_compute(int fd, struct drm_xe_engine_class_instance *eci, size_t size,
 
 		xe_run_intel_compute_kernel_on_engine(fd, eci, &env, EXECENV_PREF_SYSTEM);
 
+		if (flags & ACCESS_DEVICE_HOST) {
+			float total = 0;
+
+			if (flags & USE_MADV_DONTNEED)
+				madvise(compute_input, size, MADV_DONTNEED);
+
+			/*
+			 * No functional purpose, just force a read on host
+			 */
+			for (int j = 0; j < env.array_size; j++)
+				total += compute_input[i];
+
+			if (!total)
+				igt_debug("compute_input is zeros\n");
+		}
+
 		free(compute_input);
 	}
 
@@ -2524,6 +2553,7 @@ int igt_main()
 		{ "once-device-host", TOUCH_ONCE | ACCESS_DEVICE_HOST },
 		{ "range-device", 0 },
 		{ "range-device-host", ACCESS_DEVICE_HOST },
+		{ "range-device-host-madvise-dontneed", ACCESS_DEVICE_HOST | USE_MADV_DONTNEED },
 		{ NULL },
 	};
 
-- 
2.43.0


             reply	other threads:[~2026-04-24  8:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24  8:16 Francois Dugast [this message]
2026-04-24 15:30 ` ✓ Xe.CI.BAT: success for tests/intel/xe_exec_system_allocator: Test madvise(MADV_DONTNEED) Patchwork
2026-04-24 16:07 ` ✓ i915.CI.BAT: " Patchwork
2026-04-24 16:40 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-24 20:07 ` ✗ i915.CI.Full: " Patchwork
2026-05-07  7:21 ` [PATCH i-g-t] " Zbigniew Kempczyński

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=20260424081647.516473-1-francois.dugast@intel.com \
    --to=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@linux.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