* [PATCH 1/2] drm/xe: count UMA shrinkable BOs as reclaimable without swap
@ 2026-06-26 11:26 aquiles
2026-06-26 11:26 ` [PATCH 2/2] drm/xe: skip resv fence wait in xe_svm_invalidate if no ranges are bound aquiles
0 siblings, 1 reply; 2+ messages in thread
From: aquiles @ 2026-06-26 11:26 UTC (permalink / raw)
To: matthew.brost, thomas.hellstrom, rodrigo.vivi
Cc: airlied, simona, intel-xe, dri-devel, linux-kernel, aquiles
On integrated (UMA) devices all GPU buffer objects reside in system RAM.
xe_shrinker_count() previously gated shrinkable (non-purgeable) page
counts on ttm_backup_bytes_avail(), so those pages were invisible to
the kernel's memory reclaim on systems without swap configured.
On UMA, shrinkable system-memory BOs can be reclaimed independently of
swap availability. Report them unconditionally so the shrinker can
always request their eviction under memory pressure.
Signed-off-by: aquiles <achillezongo07@gmail.com>
---
drivers/gpu/drm/xe/xe_shrinker.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_shrinker.c b/drivers/gpu/drm/xe/xe_shrinker.c
index 83374cd57..3ca2de342 100644
--- a/drivers/gpu/drm/xe/xe_shrinker.c
+++ b/drivers/gpu/drm/xe/xe_shrinker.c
@@ -140,16 +140,22 @@ xe_shrinker_count(struct shrinker *shrink, struct shrink_control *sc)
{
struct xe_shrinker *shrinker = to_xe_shrinker(shrink);
unsigned long num_pages;
+ long uma_reclaimable_pages;
bool can_backup = !!(sc->gfp_mask & __GFP_FS);
+ bool is_uma = !IS_DGFX(shrinker->xe);
num_pages = ttm_backup_bytes_avail() >> PAGE_SHIFT;
read_lock(&shrinker->lock);
+ uma_reclaimable_pages = is_uma ? shrinker->shrinkable_pages : 0;
+
if (can_backup)
- num_pages = min_t(unsigned long, num_pages, shrinker->shrinkable_pages);
+ num_pages = min_t(unsigned long, num_pages,
+ shrinker->shrinkable_pages - uma_reclaimable_pages);
else
num_pages = 0;
+ num_pages += uma_reclaimable_pages;
num_pages += shrinker->purgeable_pages;
read_unlock(&shrinker->lock);
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 2/2] drm/xe: skip resv fence wait in xe_svm_invalidate if no ranges are bound
2026-06-26 11:26 [PATCH 1/2] drm/xe: count UMA shrinkable BOs as reclaimable without swap aquiles
@ 2026-06-26 11:26 ` aquiles
0 siblings, 0 replies; 2+ messages in thread
From: aquiles @ 2026-06-26 11:26 UTC (permalink / raw)
To: matthew.brost, thomas.hellstrom, rodrigo.vivi
Cc: airlied, simona, intel-xe, dri-devel, linux-kernel, aquiles
xe_svm_invalidate() waited on the VM's reservation object fences before
processing MMU notifier events, even when no range in the affected
address region had active GPU bindings (tile_present == 0).
Add a pre-scan over the affected ranges and skip dma_resv_wait_timeout()
entirely when none require invalidation. This avoids stalling CPU reclaim
for the common case where MMU notifier events fire on unbound SVM ranges,
which is frequent on UMA systems under memory pressure.
Signed-off-by: aquiles <achillezongo07@gmail.com>
---
drivers/gpu/drm/xe/xe_svm.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
index e1651e70c..5d071bab3 100644
--- a/drivers/gpu/drm/xe/xe_svm.c
+++ b/drivers/gpu/drm/xe/xe_svm.c
@@ -233,6 +233,7 @@ static void xe_svm_invalidate(struct drm_gpusvm *gpusvm,
ktime_t start = xe_gt_stats_ktime_get();
u64 adj_start = mmu_range->start, adj_end = mmu_range->end;
u8 tile_mask = 0, id;
+ bool needs_inval = false;
long err;
xe_svm_assert_in_notifier(vm);
@@ -258,11 +259,22 @@ static void xe_svm_invalidate(struct drm_gpusvm *gpusvm,
if (xe_vm_is_closed(vm))
goto range_notifier_event_end;
- /*
- * XXX: Less than ideal to always wait on VM's resv slots if an
- * invalidation is not required. Could walk range list twice to figure
- * out if an invalidations is need, but also not ideal.
- */
+ /* Pre-scan: skip fence wait if no range has active GPU bindings. */
+
+ r = first;
+ drm_gpusvm_for_each_range(r, notifier, adj_start, adj_end) {
+ struct xe_svm_range *range = to_xe_range(r);
+
+ if (!range->base.pages.flags.unmapped && range->tile_present) {
+ needs_inval = true;
+ break;
+ }
+
+ }
+ if (!needs_inval)
+ goto range_notifier_event_end;
+
+
err = dma_resv_wait_timeout(xe_vm_resv(vm),
DMA_RESV_USAGE_BOOKKEEP,
false, MAX_SCHEDULE_TIMEOUT);
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-26 11:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-26 11:26 [PATCH 1/2] drm/xe: count UMA shrinkable BOs as reclaimable without swap aquiles
2026-06-26 11:26 ` [PATCH 2/2] drm/xe: skip resv fence wait in xe_svm_invalidate if no ranges are bound aquiles
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®