From: Alex Hung <alex.hung@amd.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, nishit.sharma@intel.com,
pravalika.gurram@intel.com
Subject: Re: [PATCH i-g-t v10 0/8] tests/xe: Add purgeable memory madvise tests for system allocator
Date: Fri, 17 Apr 2026 17:57:20 -0600 [thread overview]
Message-ID: <3bda07ae-91b6-4812-8f75-47b0b6c1f1be@amd.com> (raw)
In-Reply-To: <20260414061703.2604112-1-arvind.yadav@intel.com>
Patch 2 & 3 seem to cause the following compilation failures on CI's
build:tests-debian-meson-armhf.
See https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/jobs/97703144
../tests/intel/xe_madvise.c: In function ‘test_purged_mmap_blocked’:
../tests/intel/xe_madvise.c:201:20: error: cast from pointer to integer
of different size [-Werror=pointer-to-int-cast]
201 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^
../lib/igt_core.h:796:20: note: in definition of macro ‘igt_assert_cmpu64’
796 | uint64_t __n1 = (n1), __n2 = (n2); \
| ^~
../tests/intel/xe_madvise.c:201:2: note: in expansion of macro
‘igt_assert_eq_u64’
201 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^~~~~~~~~~~~~~~~~
../tests/intel/xe_madvise.c:201:35: error: cast from pointer to integer
of different size [-Werror=pointer-to-int-cast]
201 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^
../lib/igt_core.h:796:33: note: in definition of macro ‘igt_assert_cmpu64’
796 | uint64_t __n1 = (n1), __n2 = (n2); \
| ^~
../tests/intel/xe_madvise.c:201:2: note: in expansion of macro
‘igt_assert_eq_u64’
201 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^~~~~~~~~~~~~~~~~
../tests/intel/xe_madvise.c: In function ‘test_dontneed_before_mmap’:
../tests/intel/xe_madvise.c:343:20: error: cast from pointer to integer
of different size [-Werror=pointer-to-int-cast]
343 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^
../lib/igt_core.h:796:20: note: in definition of macro ‘igt_assert_cmpu64’
796 | uint64_t __n1 = (n1), __n2 = (n2); \
| ^~
../tests/intel/xe_madvise.c:343:2: note: in expansion of macro
‘igt_assert_eq_u64’
343 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^~~~~~~~~~~~~~~~~
../tests/intel/xe_madvise.c:343:35: error: cast from pointer to integer
of different size [-Werror=pointer-to-int-cast]
343 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^
../lib/igt_core.h:796:33: note: in definition of macro ‘igt_assert_cmpu64’
796 | uint64_t __n1 = (n1), __n2 = (n2); \
| ^~
../tests/intel/xe_madvise.c:343:2: note: in expansion of macro
‘igt_assert_eq_u64’
343 | igt_assert_eq_u64((uint64_t)ptr, (uint64_t)MAP_FAILED);
| ^~~~~~~~~~~~~~~~~
On 4/14/26 00:16, Arvind Yadav wrote:
> This series adds IGT tests for the purgeable memory madvise functionality
> in the XE driver's system allocator path.
>
> Purgeable memory allows userspace to mark buffer objects as DONTNEED,
> making them eligible for kernel reclamation under memory pressure. This
> is critical for mobile and memory-constrained platforms to prevent OOM
> conditions while managing temporary or regeneratable GPU data.
>
> The test suite validates:
> - Basic purgeable lifecycle (WILLNEED -> DONTNEED -> PURGED)
> - "Once purged, always purged" semantics (i915 compatibility)
> - Per-VMA purgeable state tracking for shared buffers
> - CPU fault handling on purged BOs (SIGBUS/SIGSEGV)
> - GPU execution with purged memory and scratch page protection
> - Proper state transitions across multiple VMs
>
> Purgeable Memory States:-
> - **WILLNEED (0)**: Memory is actively needed, kernel should not
> reclaim it.
> - **DONTNEED (1)**: Application doesn't need this memory right now,
> kernel can reclaim it if needed
>
> Retained Value
> When querying purgeable state, the kernel returns:
> - retained = 1: Memory is still present (not purged)
> - retained = 0: Memory was purged/reclaimed
>
> Kernel dependency: https://patchwork.freedesktop.org/series/156651/
>
> Test Cases :
> 1. dontneed-before-mmap
> Purpose: Validate that mmap fails on dontneed BO
>
> 2. purged-mmap-blocked
> Purpose: Validate that mmap fails on already-purged
>
> 3. dontneed-after-mmap
> Purpose: Validate that accessing an existing mapping of purged memory
> triggers SIGBUS/SIGSEGV.
>
> 4. dontneed-before-exec
> Purpose: Validate GPU execution on purgeable BO (before it's used).
>
> 5. dontneed-after-exec
> Purpose: Validate that previously-used BO can be purged and becomes
> inaccessible.
>
> 6. per-vma-tracking
> Purpose: Validate per-VMA purgeable state tracking
>
> 7. per-vma-protection
> Purpose: Validate that WILLNEED VMA protects BO from purging during
> GPU operations.
> v2:
> - Move tests from xe_exec_system_allocator.c to dedicated
> xe_madvise.c (Thomas Hellström).
> - Fix trigger_memory_pressure to use scalable overpressure
> (25% of VRAM, minimum 64MB instead of fixed 64MB). (Pravalika)
> - Add MAP_FAILED check in trigger_memory_pressure.
> - Touch all pages in allocated chunks, not just first 4KB. (Pravalika)
> - Add 100ms sleep before freeing BOs to allow shrinker time
> to process memory pressure. (Pravalika)
> - Rename 'bo2' to 'handle' for clarity in trigger_memory_pressure.(Pravalika)
> - Add NEEDS_VISIBLE_VRAM flag to purgeable_setup_simple_bo
> for consistent CPU mapping support on discrete GPUs. (Pravalika)
> - Add proper NULL mmap handling in test_dontneed_before_mmap
> with cleanup and early return. (Pravalika)
>
> v3:
> - Added separate commits for each individual test case. (Pravalika)
>
> v4:
> - Move unmap outside the block. (Pravalika)
> - 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)
>
> v5:
> - Document DONTNEED BO access blocking behavior to prevent undefined
> behavior and clarify uAPI contract (Thomas, Matt)
> - Add query flag DRM_XE_QUERY_CONFIG_FLAG_HAS_PURGING_SUPPORT for
> feature detection. (Jose)
> - For DONTNEED BO's mmap offset ioctl blocked with -EBUSY.
> - Rename retained to retained_ptr. (Jose)
> - Add new subtest purged-mmap-blocked.
>
> v6:
> - Support iGPU in trigger_memory_pressure() by using total system RAM
> as pressure baseline; raise overpressure to 50% to force shrinker.
> - DONTNEED mmap blocking now enforced at mmap() time (xe_gem_object_mmap),
> not at DRM_IOCTL_XE_GEM_MMAP_OFFSET. Update dontneed-before-mmap and
> purged-mmap-blocked accordingly.
> - Fix graceful skip (instead of fail) in per-vma-tracking and
> per-vma-protection when purge cannot be induced. (Nishit)
>
> v7:
> - Commit message updated with kernel UAPI details (Nishit)
> - Moved trigger_memory_pressure(), purgeable_mark_and_verify_purged()
> and sigtrap() in 4/9 and other patch. (Nishit)
> - Use xe_has_vram() instead of checking xe_visible_vram_size() > 0 for
> clearer dGPU/iGPU detection. (Nishit)
> - Fix purgeable_mark_and_verify_purged(): handle retained == 0 from
> DONTNEED (BO already purged) as success instead of incorrectly
> returning false. (Nishit)
> - Drop unused vm parameter from trigger_memory_pressure(). (Nishit)
> - Mentioned this new ioctl instead of __xe_vm_madvise(). (Nishit)
>
> v8:
> - rebased.
> - Drop this "[i-g-t,v7,1/9] drm-uapi/xe_drm: Sync with Add UAPI
> support for purgeable buffer objects" patch. (Kamil)
>
> v9:
> - Added Reviewed-by tags. (Nishit)
>
> v10:
> - iGPU: use igt_purge_vm_caches() to trigger shrinker directly
> instead of flooding system RAM (avoids OOM on low-memory machines).
> - Simplified comments in trigger_memory_pressure().
>
> Arvind Yadav (8):
> lib/xe: Add purgeable memory ioctl support
> tests/intel/xe_madvise: Add dontneed-before-mmap subtest
> tests/intel/xe_madvise: Add purged-mmap-blocked subtest
> tests/intel/xe_madvise: Add dontneed-after-mmap subtest
> tests/intel/xe_madvise: Add dontneed-before-exec subtest
> tests/intel/xe_madvise: Add dontneed-after-exec subtest
> tests/intel/xe_madvise: Add per-vma-tracking subtest
> tests/intel/xe_madvise: Add per-vma-protection subtest
>
> lib/xe/xe_ioctl.c | 33 ++
> lib/xe/xe_ioctl.h | 2 +
> tests/intel/xe_madvise.c | 829 +++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 4 files changed, 865 insertions(+)
> create mode 100644 tests/intel/xe_madvise.c
>
prev parent reply other threads:[~2026-04-17 23:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 6:16 [PATCH i-g-t v10 0/8] tests/xe: Add purgeable memory madvise tests for system allocator Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 1/8] lib/xe: Add purgeable memory ioctl support Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 2/8] tests/intel/xe_madvise: Add dontneed-before-mmap subtest Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 3/8] tests/intel/xe_madvise: Add purged-mmap-blocked subtest Arvind Yadav
2026-04-14 11:19 ` Sharma, Nishit
2026-04-14 6:16 ` [PATCH i-g-t v10 4/8] tests/intel/xe_madvise: Add dontneed-after-mmap subtest Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 5/8] tests/intel/xe_madvise: Add dontneed-before-exec subtest Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 6/8] tests/intel/xe_madvise: Add dontneed-after-exec subtest Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 7/8] tests/intel/xe_madvise: Add per-vma-tracking subtest Arvind Yadav
2026-04-14 6:16 ` [PATCH i-g-t v10 8/8] tests/intel/xe_madvise: Add per-vma-protection subtest Arvind Yadav
2026-04-14 7:37 ` ✓ Xe.CI.BAT: success for tests/xe: Add purgeable memory madvise tests for system allocator (rev10) Patchwork
2026-04-14 7:46 ` ✓ i915.CI.BAT: " Patchwork
2026-04-14 9:50 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-17 7:00 ` Yadav, Arvind
2026-04-14 12:26 ` ✗ i915.CI.Full: " Patchwork
2026-04-17 23:57 ` Alex Hung [this message]
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=3bda07ae-91b6-4812-8f75-47b0b6c1f1be@amd.com \
--to=alex.hung@amd.com \
--cc=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=nishit.sharma@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