From: Matthew Brost <matthew.brost@intel.com>
To: Arvind Yadav <arvind.yadav@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
<himal.prasad.ghimiray@intel.com>,
<thomas.hellstrom@linux.intel.com>, <pallavi.mishra@intel.com>
Subject: Re: [PATCH v5 0/9] drm/xe/madvise: Add support for purgeable buffer objects
Date: Wed, 11 Feb 2026 07:46:32 -0800 [thread overview]
Message-ID: <aYykWLYG1MsY46en@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20260211152644.1661165-1-arvind.yadav@intel.com>
On Wed, Feb 11, 2026 at 08:56:29PM +0530, Arvind Yadav wrote:
I have a feeling from the KMD POV we are getting close for this being
ready to merge. What is the status a UMD PR to use this feature (?) as
this is a prerequisite to merging.
Also it likely time to start collecting ack's from the UMD teams on the
the uAPI patch too.
Matt
> This patch series introduces comprehensive support for purgeable buffer objects
> in the Xe driver, enabling userspace to provide memory usage hints for better
> memory management under system pressure.
>
> Overview:
>
> Purgeable memory allows applications to mark buffer objects as "not currently
> needed" (DONTNEED), making them eligible for kernel reclamation during memory
> pressure. This helps prevent OOM conditions and enables more efficient GPU
> memory utilization for workloads with temporary or regeneratable data (caches,
> intermediate results, decoded frames, etc.).
>
> Purgeable BO Lifecycle:
> 1. WILLNEED (default): BO actively needed, kernel preserves backing store
> 2. DONTNEED (user hint): BO contents discardable, eligible for purging
> 3. PURGED (kernel action): Backing store reclaimed during memory pressure
>
> Key Design Principles:
> - i915 compatibility: "Once purged, always purged" semantics - purged BOs
> remain permanently invalid and must be destroyed/recreated
> - Per-VMA state tracking: Each VMA tracks its own purgeable state, BO is
> only marked DONTNEED when ALL VMAs across ALL VMs agree (Thomas Hellström)
> - Safety first: Imported/exported dma-bufs blocked from purgeable state -
> no visibility into external device usage (Matt Roper)
> - Multiple protection layers: Validation in madvise, VM bind, mmap, and
> fault handlers
> - Async TLB invalidation: Uses xe_bo_trigger_rebind() for non-blocking
> GPU mapping invalidation
> - Scratch PTE support: Fault-mode VMs use scratch pages for safe zero reads
> on purged BO access.
> - Purgeable state is not applied to imported/exported dma-bufs,
> those BOs always behave as WILLNEED.
> - TTM shrinker integration: Encapsulated helpers manage xe_ttm_tt->purgeable
> flag and shrinker page accounting (shrinkable vs purgeable buckets)
>
> v2 Changes:
> - Reordered patches: Moved shared BO helper before main implementation for
> proper dependency order
> - Fixed reference counting in mmap offset validation (use drm_gem_object_put)
> - Removed incorrect claims about madvise(WILLNEED) restoring purged BOs
> - Fixed error code documentation inconsistencies
> - Initialize purge_state_val fields to prevent kernel memory leaks
> - Use xe_bo_trigger_rebind() for async TLB invalidation (Thomas Hellström)
> - Add NULL rebind with scratch PTEs for fault mode (Thomas Hellström)
> - Implement i915-compatible retained field logic (Thomas Hellström)
> - Skip BO validation for purged BOs in page fault handler (crash fix)
> - Add scratch VM check in page fault path (non-scratch VMs fail fault)
>
> v3 Changes (addressing Matt and Thomas Hellström feedback):
> - Per-VMA purgeable state tracking: Added xe_vma->purgeable_state field
> - Complete VMA check: xe_bo_all_vmas_dontneed() walks all VMAs across all
> VMs to ensure unanimous DONTNEED before marking BO purgeable
> - VMA unbind recheck: Added xe_bo_recheck_purgeable_on_vma_unbind() to
> re-evaluate BO state when VMAs are destroyed
> - Block external dma-bufs: Added xe_bo_is_external_dmabuf() check using
> drm_gem_is_imported() and obj->dma_buf to prevent purging imported/exported BOs
> - Consistent lockdep enforcement: Added xe_bo_assert_held() to all helpers
> that access madv_purgeable state
> - Simplified page table logic: Renamed is_null to is_null_or_purged in
> xe_pt_stage_bind_entry() - purged BOs treated identically to null VMAs
> - Removed unnecessary checks: Dropped redundant "&& bo" check in xe_ttm_bo_purge()
> - Xe-specific warnings: Changed drm_warn() to XE_WARN_ON() in purge path
> - Moved purge checks under locks: Purge state validation now done after
> acquiring dma-resv lock in vma_lock_and_validate() and xe_pagefault_begin()
> - Race-free fault handling: Removed unlocked purge check from
> xe_pagefault_handle_vma(), moved to locked xe_pagefault_begin()
> - Shrinker helper functions: Added xe_bo_set_purgeable_shrinker() and
> xe_bo_clear_purgeable_shrinker() to encapsulate TTM purgeable flag updates
> and shrinker page accounting, improving code clarity and maintainability
>
> v4 Changes (addressing Matt and Thomas Hellström feedback):
> - UAPI: Removed '__u64 reserved' field from purge_state_val union to fit
> 16-byte size constraint (Matt)
> - Changed madv_purgeable from atomic_t to u32 across all patches (Matt)
> - CPU fault handling: Added purged check to fastpath (xe_bo_cpu_fault_fastpath)
> to prevent hang when accessing existing mmap of purged BO
>
> v5 Changes (addressing Matt and Thomas Hellström feedback):
> - Add locking documentation to madv_purgeable field comment (Matt)
> - Introduce xe_bo_set_purgeable_state() helper (void return) to centralize
> madv_purgeable updates with xe_bo_assert_held() and state transition
> validation using explicit enum checks (no transition out of PURGED) (Matt)
> - Make xe_ttm_bo_purge() return int and propagate failures from
> xe_bo_move(); handle xe_bo_trigger_rebind() failures (e.g. no_wait_gpu
> paths) rather than silently ignoring (Matt)
> - Replace drm_WARN_ON with xe_assert for better Xe-specific assertions (Matt)
> - Hook purgeable handling into madvise_funcs[DRM_XE_VMA_ATTR_PURGEABLE_STATE]
> instead of special-case path in xe_vm_madvise_ioctl() (Matt)
> - Track purgeable retained return via xe_madvise_details and perform
> copy_to_user() from xe_madvise_details_fini() after locks are dropped (Matt)
> - Set madvise_funcs[DRM_XE_VMA_ATTR_PURGEABLE_STATE] to NULL with
> __maybe_unused on madvise_purgeable() to maintain bisectability until
> shrinker integration is complete in final patch (Matt)
> - Call xe_bo_recheck_purgeable_on_vma_unbind() from xe_vma_destroy()
> right after drm_gpuva_unlink() where we already hold the BO lock,
> drop the trylock-based late destroy path (Matt)
> - Move purgeable_state into xe_vma_mem_attr with the other madvise
> attributes (Matt)
> - Drop READ_ONCE since the BO lock already protects us (Matt)
> - Keep returning false when there are no VMAs - otherwise we'd mark
> BOs purgeable without any user hint (Matt)
> - Use struct xe_vma_lock_and_validate_flags instead of multiple bool
> parameters to improve readability and prevent argument transposition (Matt)
> - Fix LRU crash while running shrink test
> - Skip xe_bo_validate() for purged BOs in xe_gpuvm_validate()
> - Split ghost BO and zero-refcount handling in xe_bo_shrink() (Thomas)
>
> Arvind Yadav (8):
> drm/xe/bo: Add purgeable bo state tracking and field madv to xe_bo
> drm/xe/madvise: Implement purgeable buffer object support
> drm/xe/bo: Handle CPU faults on purged buffer objects
> drm/xe/vm: Prevent binding of purged buffer objects
> drm/xe/madvise: Implement per-VMA purgeable state tracking
> drm/xe/madvise: Block imported and exported dma-bufs
> drm/xe/bo: Add purgeable shrinker state helpers
> drm/xe/madvise: Enable purgeable buffer object IOCTL support
>
> Himal Prasad Ghimiray (1):
> drm/xe/uapi: Add UAPI support for purgeable buffer objects
>
> drivers/gpu/drm/xe/xe_bo.c | 187 ++++++++++++++++++++--
> drivers/gpu/drm/xe/xe_bo.h | 60 +++++++
> drivers/gpu/drm/xe/xe_bo_types.h | 6 +
> drivers/gpu/drm/xe/xe_pagefault.c | 12 ++
> drivers/gpu/drm/xe/xe_pt.c | 40 ++++-
> drivers/gpu/drm/xe/xe_vm.c | 90 +++++++++--
> drivers/gpu/drm/xe/xe_vm_madvise.c | 249 +++++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_vm_madvise.h | 3 +
> drivers/gpu/drm/xe/xe_vm_types.h | 11 ++
> include/uapi/drm/xe_drm.h | 44 +++++
> 10 files changed, 667 insertions(+), 35 deletions(-)
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-02-11 15:46 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 15:26 [PATCH v5 0/9] drm/xe/madvise: Add support for purgeable buffer objects Arvind Yadav
2026-02-11 15:26 ` [PATCH v5 1/9] drm/xe/uapi: Add UAPI " Arvind Yadav
2026-02-24 10:50 ` Thomas Hellström
2026-02-26 17:58 ` Souza, Jose
2026-02-27 9:32 ` Yadav, Arvind
2026-02-11 15:26 ` [PATCH v5 2/9] drm/xe/bo: Add purgeable bo state tracking and field madv to xe_bo Arvind Yadav
2026-02-11 16:00 ` Matthew Brost
2026-02-11 15:26 ` [PATCH v5 3/9] drm/xe/madvise: Implement purgeable buffer object support Arvind Yadav
2026-02-24 12:21 ` Thomas Hellström
2026-02-24 14:56 ` Yadav, Arvind
2026-02-11 15:26 ` [PATCH v5 4/9] drm/xe/bo: Handle CPU faults on purged buffer objects Arvind Yadav
2026-02-11 15:26 ` [PATCH v5 5/9] drm/xe/vm: Prevent binding of " Arvind Yadav
2026-02-11 16:17 ` Matthew Brost
2026-02-11 15:26 ` [PATCH v5 6/9] drm/xe/madvise: Implement per-VMA purgeable state tracking Arvind Yadav
2026-02-24 12:48 ` Thomas Hellström
2026-02-24 15:07 ` Yadav, Arvind
2026-02-24 16:36 ` Matthew Brost
2026-02-25 5:35 ` Yadav, Arvind
2026-02-25 8:21 ` Thomas Hellström
2026-02-25 9:04 ` Matthew Brost
2026-02-25 9:18 ` Thomas Hellström
2026-02-25 9:40 ` Yadav, Arvind
2026-02-25 18:32 ` Matthew Brost
2026-02-11 15:26 ` [PATCH v5 7/9] drm/xe/madvise: Block imported and exported dma-bufs Arvind Yadav
2026-02-24 14:15 ` Thomas Hellström
2026-02-11 15:26 ` [PATCH v5 8/9] drm/xe/bo: Add purgeable shrinker state helpers Arvind Yadav
2026-02-24 14:21 ` Thomas Hellström
2026-02-24 15:09 ` Yadav, Arvind
2026-02-11 15:26 ` [PATCH v5 9/9] drm/xe/madvise: Enable purgeable buffer object IOCTL support Arvind Yadav
2026-02-11 15:40 ` Matthew Brost
2026-02-11 15:46 ` Matthew Brost [this message]
2026-02-25 10:10 ` [PATCH v5 0/9] drm/xe/madvise: Add support for purgeable buffer objects Yadav, Arvind
2026-02-11 16:21 ` ✗ CI.checkpatch: warning for drm/xe/madvise: Add support for purgeable buffer objects (rev6) Patchwork
2026-02-11 16:22 ` ✓ CI.KUnit: success " Patchwork
2026-02-11 17:11 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-02-13 1:15 ` ✗ Xe.CI.FULL: " 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=aYykWLYG1MsY46en@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=pallavi.mishra@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