From: "Sharma, Nishit" <nishit.sharma@intel.com>
To: "Gurram, Pravalika" <pravalika.gurram@intel.com>,
"Yadav, Arvind" <arvind.yadav@intel.com>,
"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Cc: "Brost, Matthew" <matthew.brost@intel.com>,
"Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>,
"thomas.hellstrom@linux.intel.com"
<thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH i-g-t v3 7/8] tests/intel/xe_madvise: Add per-vma-tracking subtest
Date: Mon, 23 Feb 2026 12:47:25 +0530 [thread overview]
Message-ID: <e9e69621-1ea5-4b9f-b908-425f565035c1@intel.com> (raw)
In-Reply-To: <BL1PR11MB55254273B6A331543901C8328477A@BL1PR11MB5525.namprd11.prod.outlook.com>
On 2/23/2026 10:41 AM, Gurram, Pravalika wrote:
>
>> -----Original Message-----
>> From: Yadav, Arvind <arvind.yadav@intel.com>
>> Sent: Tuesday, 17 February, 2026 08:04 AM
>> To: igt-dev@lists.freedesktop.org
>> Cc: Brost, Matthew <matthew.brost@intel.com>; Ghimiray, Himal Prasad
>> <himal.prasad.ghimiray@intel.com>; thomas.hellstrom@linux.intel.com;
>> Sharma, Nishit <nishit.sharma@intel.com>; Gurram, Pravalika
>> <pravalika.gurram@intel.com>
>> Subject: [PATCH i-g-t v3 7/8] tests/intel/xe_madvise: Add per-vma-tracking
>> subtest
>>
>> This test validates that purgeable state is tracked per-VMA when a single BO is
>> bound in multiple VMs. The test creates one BO shared across two VMs at
>> different virtual addresses. It verifies that marking only one VMA as
>> DONTNEED does not make the BO purgeable, but marking both VMAs as
>> DONTNEED allows the kernel to purge the shared BO. This ensures proper per-
>> VMA tracking for shared memory.
>>
>> Cc: Nishit Sharma <nishit.sharma@intel.com>
>> Cc: Pravalika Gurram <pravalika.gurram@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>
>> Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
>> ---
>> tests/intel/xe_madvise.c | 109
>> +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 109 insertions(+)
>>
>> diff --git a/tests/intel/xe_madvise.c b/tests/intel/xe_madvise.c index
>> 51ef4fad3..4e7df54a7 100644
>> --- a/tests/intel/xe_madvise.c
>> +++ b/tests/intel/xe_madvise.c
>> @@ -20,6 +20,7 @@
>>
>> /* Purgeable test constants */
>> #define PURGEABLE_ADDR 0x1a0000
>> +#define PURGEABLE_ADDR2 0x2b0000
>> #define PURGEABLE_BATCH_ADDR 0x3c0000
>> #define PURGEABLE_BO_SIZE 4096
>> #define PURGEABLE_FENCE_VAL 0xbeef
>> @@ -205,6 +206,58 @@ static void purgeable_setup_batch_and_data(int fd,
>> uint32_t *vm,
>> xe_wait_ufence(fd, &vm_sync, PURGEABLE_FENCE_VAL, 0,
>> NSEC_PER_SEC); }
>>
>> +/**
>> + * purgeable_setup_two_vms_shared_bo - Setup two VMs with one shared
>> BO
>> + * @fd: DRM file descriptor
>> + * @vm1: Output first VM handle
>> + * @vm2: Output second VM handle
>> + * @bo: Output shared BO handle
>> + * @addr1: Virtual address in VM1
>> + * @addr2: Virtual address in VM2
>> + * @size: Size of the BO
>> + * @use_scratch: Whether to use scratch page flag for VMs
>> + *
>> + * Helper to create two VMs and bind one shared BO in both VMs.
>> + * Returns mapped pointer to the BO.
>> + */
>> +static void *purgeable_setup_two_vms_shared_bo(int fd, uint32_t *vm1,
>> uint32_t *vm2,
>> + uint32_t *bo, uint64_t addr1,
>> + uint64_t addr2, size_t size,
>> + bool use_scratch)
>> +{
>> + struct drm_xe_sync sync = {
>> + .type = DRM_XE_SYNC_TYPE_USER_FENCE,
>> + .flags = DRM_XE_SYNC_FLAG_SIGNAL,
>> + .timeline_value = 1,
>> + };
>> + uint64_t sync_val = 0;
>> + void *map;
>> +
>> + /* Create two VMs */
>> + *vm1 = xe_vm_create(fd, use_scratch ?
>> DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE : 0, 0);
>> + *vm2 = xe_vm_create(fd, use_scratch ?
>> +DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE : 0, 0);
>> +
>> + /* Create shared BO */
>> + *bo = xe_bo_create(fd, 0, size, vram_if_possible(fd, 0),
>> +
>> DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
>> +
>> + map = xe_bo_map(fd, *bo, size);
>> + memset(map, 0xAB, size);
>> +
>> + /* Bind BO in VM1 */
>> + sync.addr = to_user_pointer(&sync_val);
>> + sync_val = 0;
>> + xe_vm_bind_async(fd, *vm1, 0, *bo, 0, addr1, size, &sync, 1);
>> + xe_wait_ufence(fd, &sync_val, 1, 0, NSEC_PER_SEC);
>> +
>> + /* Bind BO in VM2 */
>> + sync_val = 0;
>> + xe_vm_bind_async(fd, *vm2, 0, *bo, 0, addr2, size, &sync, 1);
>> + xe_wait_ufence(fd, &sync_val, 1, 0, NSEC_PER_SEC);
>> +
>> + return map;
>> +}
>> +
>> /**
>> * SUBTEST: dontneed-before-mmap
>> * Description: Mark BO as DONTNEED before mmap, verify mmap fails or
>> SIGBUS on access @@ -465,6 +518,56 @@ static void
>> test_dontneed_after_exec(int fd, struct drm_xe_engine_class_instance
>> xe_vm_destroy(fd, vm);
>> }
>>
>> +/**
>> + * SUBTEST: per-vma-tracking
>> + * Description: One BO in two VMs becomes purgeable only when both
>> VMAs
>> +are DONTNEED
>> + * Test category: functionality test
>> + */
>> +static void test_per_vma_tracking(int fd, struct
>> +drm_xe_engine_class_instance *hwe) {
>> + uint32_t bo, vm1, vm2;
>> + uint64_t addr1 = PURGEABLE_ADDR;
>> + uint64_t addr2 = PURGEABLE_ADDR2;
>> + size_t bo_size = PURGEABLE_BO_SIZE;
>> + uint32_t retained;
>> + void *map;
>> +
>> + map = purgeable_setup_two_vms_shared_bo(fd, &vm1, &vm2, &bo,
>> + addr1, addr2,
>> + bo_size, false);
>> +
>> + /* Mark VMA1 as DONTNEED */
>> + retained = xe_vm_madvise_purgeable(fd, vm1, addr1, bo_size,
>> +
>> DRM_XE_VMA_PURGEABLE_STATE_DONTNEED);
>> + igt_assert_eq(retained, 1);
>> +
>> + /* Verify BO NOT purgeable (VMA2 still WILLNEED) */
>> + retained = xe_vm_madvise_purgeable(fd, vm1, addr1, bo_size,
>> +
>> DRM_XE_VMA_PURGEABLE_STATE_WILLNEED);
>> + igt_assert_eq(retained, 1);
>> +
>> + /* Mark both VMAs as DONTNEED */
>> + retained = xe_vm_madvise_purgeable(fd, vm1, addr1, bo_size,
>> +
>> DRM_XE_VMA_PURGEABLE_STATE_DONTNEED);
>> + igt_assert_eq(retained, 1);
>> +
>> + retained = xe_vm_madvise_purgeable(fd, vm2, addr2, bo_size,
>> +
>> DRM_XE_VMA_PURGEABLE_STATE_DONTNEED);
>> + igt_assert_eq(retained, 1);
>> +
>> + /* Trigger pressure and verify BO was purged */
>> + trigger_memory_pressure(fd, vm1);
Triggering pressure on single VM is fine as both VMAs are DONTNEED. You
can mention in comment otherwise fine.
>> +
>> + retained = xe_vm_madvise_purgeable(fd, vm1, addr1, bo_size,
>> +
>> DRM_XE_VMA_PURGEABLE_STATE_WILLNEED);
>> + igt_assert_eq(retained, 0);
>> +
>> + munmap(map, bo_size);
>> + gem_close(fd, bo);
>> + xe_vm_destroy(fd, vm1);
>> + xe_vm_destroy(fd, vm2);
>> +}
>> +
>> int igt_main()
>> {
>> struct drm_xe_engine_class_instance *hwe; @@ -499,6 +602,12 @@
>> int igt_main()
>> break;
>> }
>>
>> + igt_subtest("per-vma-tracking")
>> + xe_for_each_engine(fd, hwe) {
>> + test_per_vma_tracking(fd, hwe);
>> + break;
>> + }
>> +
> Reviewed-by: Pravalika Gurram <pravalika.gurram@intel.com>
Reviewed-by: Nishit Sharma <nishit.sharma@intel.com>
>> igt_fixture() {
>> xe_device_put(fd);
>> drm_close_driver(fd);
>> --
>> 2.43.0
next prev parent reply other threads:[~2026-02-23 7:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 2:34 [PATCH i-g-t v3 0/8] tests/xe: Add purgeable memory madvise tests for system allocator Arvind Yadav
2026-02-17 2:34 ` [PATCH i-g-t v3 1/8] drm-uapi/xe_drm: Add UAPI support for purgeable buffer objects Arvind Yadav
2026-02-18 11:22 ` Kamil Konieczny
2026-02-23 4:29 ` Gurram, Pravalika
2026-02-23 9:33 ` Yadav, Arvind
2026-02-17 2:34 ` [PATCH i-g-t v3 2/8] lib/xe: Add purgeable memory ioctl support Arvind Yadav
2026-02-23 4:30 ` Gurram, Pravalika
2026-02-17 2:34 ` [PATCH i-g-t v3 3/8] tests/intel/xe_madvise: Add dontneed-before-mmap subtest Arvind Yadav
2026-02-19 4:58 ` Gurram, Pravalika
2026-02-20 6:06 ` Yadav, Arvind
2026-02-23 5:09 ` Gurram, Pravalika
2026-02-23 5:49 ` Sharma, Nishit
2026-02-23 9:36 ` Yadav, Arvind
2026-02-17 2:34 ` [PATCH i-g-t v3 4/8] tests/intel/xe_madvise: Add dontneed-after-mmap subtest Arvind Yadav
2026-02-19 5:01 ` Gurram, Pravalika
2026-02-20 6:13 ` Yadav, Arvind
2026-02-23 5:10 ` Gurram, Pravalika
2026-02-23 5:52 ` Sharma, Nishit
2026-02-23 9:37 ` Yadav, Arvind
2026-02-17 2:34 ` [PATCH i-g-t v3 5/8] tests/intel/xe_madvise: Add dontneed-before-exec subtest Arvind Yadav
2026-02-23 5:10 ` Gurram, Pravalika
2026-02-23 6:06 ` Sharma, Nishit
2026-02-23 9:45 ` Yadav, Arvind
2026-02-17 2:34 ` [PATCH i-g-t v3 6/8] tests/intel/xe_madvise: Add dontneed-after-exec subtest Arvind Yadav
2026-02-23 5:11 ` Gurram, Pravalika
2026-02-23 7:04 ` Sharma, Nishit
2026-02-24 4:07 ` Yadav, Arvind
2026-02-17 2:34 ` [PATCH i-g-t v3 7/8] tests/intel/xe_madvise: Add per-vma-tracking subtest Arvind Yadav
2026-02-23 5:11 ` Gurram, Pravalika
2026-02-23 7:17 ` Sharma, Nishit [this message]
2026-02-24 4:08 ` Yadav, Arvind
2026-02-17 2:34 ` [PATCH i-g-t v3 8/8] tests/intel/xe_madvise: Add per-vma-protection subtest Arvind Yadav
2026-02-23 5:12 ` Gurram, Pravalika
2026-02-23 7:25 ` Sharma, Nishit
2026-02-17 3:25 ` ✓ Xe.CI.BAT: success for tests/xe: Add purgeable memory madvise tests for system allocator (rev3) Patchwork
2026-02-17 4:22 ` ✓ Xe.CI.FULL: " Patchwork
2026-02-17 8:57 ` ✓ i915.CI.BAT: " Patchwork
2026-02-17 10:50 ` ✗ i915.CI.Full: failure " 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=e9e69621-1ea5-4b9f-b908-425f565035c1@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox