Skip to content

Commit bcc2872

Browse files
committed
drm/xe: Opportunistically skip TLB invalidaion on unbind
If a range or VMA is invalidated and scratch page is disabled, there is no reason to issue a TLB invalidation on unbind, skip TLB innvalidation is this condition is true. This is an opportunistic check as it is done without the notifier lock, thus it possible for the range to be invalidated after this check is performed. This should improve performance of the SVM garbage collector, for example, xe_exec_system_allocator --r many-stride-new-prefetch, went ~20s to ~9.5s on a BMG. v2: - Use helper for valid check (Thomas) v3: - Avoid skipping TLB invalidation if PTEs are removed at a higher level than the range - Never skip TLB invalidations for VMA - Drop Himal's RB Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Himal Prasad Ghimiray <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fab76ce commit bcc2872

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

drivers/gpu/drm/xe/xe_pt.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,32 @@ static int unbind_op_prepare(struct xe_tile *tile,
19951995
return 0;
19961996
}
19971997

1998+
static bool
1999+
xe_pt_op_check_range_skip_invalidation(struct xe_vm_pgtable_update_op *pt_op,
2000+
struct xe_svm_range *range)
2001+
{
2002+
struct xe_vm_pgtable_update *update = pt_op->entries;
2003+
2004+
XE_WARN_ON(!pt_op->num_entries);
2005+
2006+
/*
2007+
* We can't skip the invalidation if we are removing PTEs that span more
2008+
* than the range, do some checks to ensure we are removing PTEs that
2009+
* are invalid.
2010+
*/
2011+
2012+
if (pt_op->num_entries > 1)
2013+
return false;
2014+
2015+
if (update->pt->level == 0)
2016+
return true;
2017+
2018+
if (update->pt->level == 1)
2019+
return xe_svm_range_size(range) >= SZ_2M;
2020+
2021+
return false;
2022+
}
2023+
19982024
static int unbind_range_prepare(struct xe_vm *vm,
19992025
struct xe_tile *tile,
20002026
struct xe_vm_pgtable_update_ops *pt_update_ops,
@@ -2023,7 +2049,10 @@ static int unbind_range_prepare(struct xe_vm *vm,
20232049
range->base.itree.last + 1);
20242050
++pt_update_ops->current_op;
20252051
pt_update_ops->needs_svm_lock = true;
2026-
pt_update_ops->needs_invalidation = true;
2052+
pt_update_ops->needs_invalidation |= xe_vm_has_scratch(vm) ||
2053+
xe_vm_has_valid_gpu_mapping(tile, range->tile_present,
2054+
range->tile_invalidated) ||
2055+
!xe_pt_op_check_range_skip_invalidation(pt_op, range);
20272056

20282057
xe_pt_commit_prepare_unbind(XE_INVALID_VMA, pt_op->entries,
20292058
pt_op->num_entries);

0 commit comments

Comments
 (0)