mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
drm/xe/bo: optimise TT population for DONTNEED BOs
When a VRAM buffer object is marked as DONTNEED, like in Mesa, the driver skips migrating its contents to system memory and instead purges the backing store during eviction (via xe_ttm_bo_purge). However, xe_evict_flags() still returns tt_placement (XE_PL_TT) for VRAM BOs even if they were marked DONTNEED. This causes ttm_bo_handle_move_mem() to always call ttm_bo_populate() to allocate destination system pages, only for those pages to be immediately freed right after when xe_bo_move() calls xe_ttm_bo_purge(). Fix this by changing xe_evict_flags() to return sys_placement (XE_PL_SYSTEM) for DONTNEED BOs. This causes TTM to skip the population step while still ensuring that TTM calls xe_bo_move(), so xe_ttm_bo_purge() still triggers. v2 (Thomas): - Add a comment to highlight why sys_placement over purge_placement. Assisted-by: Copilot:gemini-3.1-pro-preview Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Maarten Lankhorst <dev@lankhorst.se> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260723161542.1220276-2-matthew.auld@intel.com
This commit is contained in:
@@ -341,6 +341,18 @@ static void xe_evict_flags(struct ttm_buffer_object *tbo,
|
||||
return;
|
||||
}
|
||||
|
||||
if (xe_bo_madv_is_dontneed(bo)) {
|
||||
/*
|
||||
* We can't use purge_placement here, since we need to trigger
|
||||
* our own purge procedure at the start of xe_bo_move(), which
|
||||
* would otherwise be skipped. At the same time we don't want
|
||||
* ttm to then populate the tt with dst pages, before the move
|
||||
* callback, hence use sys_placement here.
|
||||
*/
|
||||
*placement = sys_placement;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* For xe, sg bos that are evicted to system just triggers a
|
||||
* rebind of the sg list upon subsequent validation to XE_PL_TT.
|
||||
|
||||
Reference in New Issue
Block a user