From: "Sharma, Nishit" <nishit.sharma@intel.com>
To: Arvind Yadav <arvind.yadav@intel.com>, <igt-dev@lists.freedesktop.org>
Cc: <matthew.brost@intel.com>, <himal.prasad.ghimiray@intel.com>,
<thomas.hellstrom@linux.intel.com>, <pravalika.gurram@intel.com>
Subject: Re: [PATCH i-g-t v6 7/9] tests/intel/xe_madvise: Add dontneed-after-exec subtest
Date: Tue, 7 Apr 2026 20:21:52 +0530 [thread overview]
Message-ID: <1ee02fbb-b190-4b35-8fb8-e9e9cfdeab6b@intel.com> (raw)
In-Reply-To: <20260325124426.3265234-8-arvind.yadav@intel.com>
On 3/25/2026 6:14 PM, Arvind Yadav wrote:
> This test verifies that memory can be marked purgeable and reclaimed
> after successful GPU execution. The test first executes a batch that
> writes to a data BO and verifies the result. It then marks the BO as
> DONTNEED, triggers memory pressure to purge it, and attempts a second
> execution. The second execution may fail or succeed with scratch
> rebind, validating that the kernel correctly handles purged BOs in
> GPU submissions.
>
> v4:
> - Added proper resource cleanup before calling igt_skip(). (Nishit)
> - Added assertion for xe_bo_map. (Nishit)
> - Now using sync[0] consistently. (Nishit)
> - Added clarifying comment. (Nishit)
>
> Cc: Nishit Sharma <nishit.sharma@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> Reviewed-by: Pravalika Gurram <pravalika.gurram@intel.com>
> Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
> ---
> tests/intel/xe_madvise.c | 108 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 108 insertions(+)
>
> diff --git a/tests/intel/xe_madvise.c b/tests/intel/xe_madvise.c
> index d126db9ed..28ea81442 100644
> --- a/tests/intel/xe_madvise.c
> +++ b/tests/intel/xe_madvise.c
> @@ -16,6 +16,7 @@
>
> #include "xe/xe_ioctl.h"
> #include "xe/xe_query.h"
> +#include "lib/igt_syncobj.h"
>
> static bool xe_has_purgeable_support(int fd)
> {
> @@ -444,6 +445,107 @@ static void test_dontneed_before_exec(int fd, struct drm_xe_engine_class_instanc
> xe_vm_destroy(fd, vm);
> }
>
> +/**
> + * SUBTEST: dontneed-after-exec
> + * Description: Mark BO as DONTNEED after GPU exec, verify memory becomes inaccessible
> + * Test category: functionality test
> + */
> +static void test_dontneed_after_exec(int fd, struct drm_xe_engine_class_instance *hwe)
> +{
> + uint32_t vm, exec_queue, bo, batch_bo, bind_engine;
> + uint64_t data_addr = PURGEABLE_ADDR;
> + uint64_t batch_addr = PURGEABLE_BATCH_ADDR;
> + size_t data_size = PURGEABLE_BO_SIZE;
> + size_t batch_size = PURGEABLE_BO_SIZE;
> + struct drm_xe_sync sync[2] = {
> + { .type = DRM_XE_SYNC_TYPE_USER_FENCE,
> + .flags = DRM_XE_SYNC_FLAG_SIGNAL,
> + .timeline_value = PURGEABLE_FENCE_VAL },
> + { .type = DRM_XE_SYNC_TYPE_SYNCOBJ,
> + .flags = DRM_XE_SYNC_FLAG_SIGNAL },
> + };
> + struct drm_xe_exec exec = {
> + .num_batch_buffer = 1,
> + .num_syncs = 2,
> + .syncs = to_user_pointer(sync),
> + };
> + uint32_t *data, *batch;
> + uint32_t syncobj;
> + int b, ret;
> +
> + purgeable_setup_batch_and_data(fd, &vm, &bind_engine, &batch_bo,
> + &bo, &batch, &data, batch_addr,
> + data_addr, batch_size, data_size);
> + memset(data, 0, data_size);
> +
> + syncobj = syncobj_create(fd, 0);
> +
> + /* Prepare batch to write to data BO */
> + b = 0;
> + batch[b++] = MI_STORE_DWORD_IMM_GEN4;
> + batch[b++] = data_addr;
> + batch[b++] = data_addr >> 32;
> + batch[b++] = 0xfeed0001;
> + batch[b++] = MI_BATCH_BUFFER_END;
> +
> + exec_queue = xe_exec_queue_create(fd, vm, hwe, 0);
> + exec.exec_queue_id = exec_queue;
> + exec.address = batch_addr;
> +
> + /* Use only syncobj for exec (not USER_FENCE) */
> + sync[0].type = DRM_XE_SYNC_TYPE_SYNCOBJ;
> + sync[0].flags = DRM_XE_SYNC_FLAG_SIGNAL;
> + sync[0].handle = syncobj;
> + exec.num_syncs = 1;
> + exec.syncs = to_user_pointer(&sync[0]);
> +
> + ret = __xe_exec(fd, &exec);
> + igt_assert_eq(ret, 0);
> +
> + igt_assert(syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL));
> + munmap(data, data_size);
> + data = xe_bo_map(fd, bo, data_size);
> + igt_assert(data != MAP_FAILED);
> + igt_assert_eq(data[0], 0xfeed0001);
> +
> + if (!purgeable_mark_and_verify_purged(fd, vm, data_addr, data_size)) {
> + munmap(data, data_size);
> + munmap(batch, batch_size);
> + gem_close(fd, bo);
> + gem_close(fd, batch_bo);
> + syncobj_destroy(fd, syncobj);
> + xe_exec_queue_destroy(fd, bind_engine);
> + xe_exec_queue_destroy(fd, exec_queue);
> + xe_vm_destroy(fd, vm);
> + igt_skip("Unable to induce purge on this platform/config");
> + }
> +
> + /* Prepare second batch (different value) */
> + b = 0;
> + batch[b++] = MI_STORE_DWORD_IMM_GEN4;
> + batch[b++] = data_addr;
> + batch[b++] = data_addr >> 32;
> + batch[b++] = 0xfeed0002;
> + batch[b++] = MI_BATCH_BUFFER_END;
> +
> + /*
> + * Second exec with purged BO - may succeed (scratch rebind) or fail.
> + * Either is valid, so don't check results.
> + */
> + ret = __xe_exec(fd, &exec);
> + if (ret == 0)
> + syncobj_wait(fd, &syncobj, 1, INT64_MAX, 0, NULL);
> +
> + munmap(data, data_size);
> + munmap(batch, batch_size);
> + gem_close(fd, bo);
> + gem_close(fd, batch_bo);
> + syncobj_destroy(fd, syncobj);
> + xe_exec_queue_destroy(fd, bind_engine);
> + xe_exec_queue_destroy(fd, exec_queue);
> + xe_vm_destroy(fd, vm);
> +}
> +
> int igt_main()
> {
> struct drm_xe_engine_class_instance *hwe;
> @@ -480,6 +582,12 @@ int igt_main()
> break;
> }
>
> + igt_subtest("dontneed-after-exec")
> + xe_for_each_engine(fd, hwe) {
> + test_dontneed_after_exec(fd, hwe);
> + break;
> + }
> +
> igt_fixture() {
> xe_device_put(fd);
> drm_close_driver(fd);
LGTM:
Reviewed-by: Nishit Sharma <nishit.sharma@intel.com>
next prev parent reply other threads:[~2026-04-07 14:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 12:44 [PATCH i-g-t v6 0/9] tests/xe: Add purgeable memory madvise tests for system allocator Arvind Yadav
2026-03-25 12:44 ` [PATCH i-g-t v6 1/9] drm-uapi/xe_drm: Add UAPI support for purgeable buffer objects Arvind Yadav
2026-04-06 5:23 ` Sharma, Nishit
2026-04-06 6:00 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 2/9] lib/xe: Add purgeable memory ioctl support Arvind Yadav
2026-04-06 6:59 ` Sharma, Nishit
2026-04-07 3:18 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 3/9] tests/intel/xe_madvise: Add dontneed-before-mmap subtest Arvind Yadav
2026-04-06 9:53 ` Sharma, Nishit
2026-04-06 10:30 ` Sharma, Nishit
2026-04-07 4:21 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 4/9] tests/intel/xe_madvise: Add purged-mmap-blocked subtest Arvind Yadav
2026-04-06 12:34 ` Sharma, Nishit
2026-04-07 5:09 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 5/9] tests/intel/xe_madvise: Add dontneed-after-mmap subtest Arvind Yadav
2026-04-06 13:33 ` Sharma, Nishit
2026-04-07 5:15 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 6/9] tests/intel/xe_madvise: Add dontneed-before-exec subtest Arvind Yadav
2026-04-06 16:48 ` Sharma, Nishit
2026-04-07 5:29 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 7/9] tests/intel/xe_madvise: Add dontneed-after-exec subtest Arvind Yadav
2026-04-07 14:51 ` Sharma, Nishit [this message]
2026-03-25 12:44 ` [PATCH i-g-t v6 8/9] tests/intel/xe_madvise: Add per-vma-tracking subtest Arvind Yadav
2026-04-07 7:20 ` Sharma, Nishit
2026-04-07 8:49 ` Yadav, Arvind
2026-03-25 12:44 ` [PATCH i-g-t v6 9/9] tests/intel/xe_madvise: Add per-vma-protection subtest Arvind Yadav
2026-04-07 7:31 ` Sharma, Nishit
2026-04-07 8:54 ` Yadav, Arvind
2026-03-25 22:59 ` ✓ Xe.CI.BAT: success for tests/xe: Add purgeable memory madvise tests for system allocator (rev6) Patchwork
2026-03-25 23:15 ` ✓ i915.CI.BAT: " Patchwork
2026-03-26 9:19 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-26 11:22 ` ✓ i915.CI.Full: success " Patchwork
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=1ee02fbb-b190-4b35-8fb8-e9e9cfdeab6b@intel.com \
--to=nishit.sharma@intel.com \
--cc=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=pravalika.gurram@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.