On 2025-10-30 18:39, Felix Kuehling wrote:
On 2025-10-29 21:00, Harish Kasiviswanathan wrote:
Fix the following corner case:-
Consider a 2M huge page SVM allocation, followed by prefetch call for
the first 4K page. The whole range is initially mapped with single PTE.
After the prefetch, this range gets split to first page + rest of the
pages. Currently, the first page mapping is not updated on MI300A (APU)
since page hasn't migrated. However, after range split PTE mapping it not
valid.
Fix this by forcing page table update for the whole range when prefetch
is called. Calling prefetch on APU doesn't improve performance. If all
it deteriotes. However, functionality has to be supported.
v2: Use apu_prefer_gtt as this issue doesn't apply to APUs with carveout
VRAM
Suggested-by: Philip Yang<[email protected]>
Signed-off-by: Harish Kasiviswanathan<[email protected]>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index c30dfb8ec236..76cab1c8aaa2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -766,14 +766,21 @@ svm_range_apply_attrs(struct kfd_process *p, struct
svm_range *prange,
{
uint32_t i;
int gpuidx;
+ struct kfd_node *node;
for (i = 0; i < nattr; i++) {
switch (attrs[i].type) {
case KFD_IOCTL_SVM_ATTR_PREFERRED_LOC:
prange->preferred_loc = attrs[i].value;
+ node = svm_range_get_node_by_id(prange, attrs[i].value);
+ if (node && node->adev->apu_prefer_gtt &&
!p->xnack_enabled)
I don't think you even need the condition based on apu_prefer_gtt. You
can always set update_mapping. If you are migrating, it would update
the mapping anyway, so it shouldn't make a difference on dGPUs.
For dGPU xnack off case, prefetch range migrated, we should use restore
worker to update mapping, yes, you are right, if migrated and xnack off,
set_attr will skip update mapping regardless update_mapping true or false.
Thanks,
Philip
More importantly, I think this may apply to other attributes as well
that result in splitting of a range without causing a migration. So
this condition could be moved outside the switch-case block and the loop:
if (!p->xnack_enabled)
*update_mapping = true;
I see we already do the same for the access attributes. Just
generalize it.
Regards,
Felix
+ *update_mapping = true;
break;
case KFD_IOCTL_SVM_ATTR_PREFETCH_LOC:
prange->prefetch_loc = attrs[i].value;
+ node = svm_range_get_node_by_id(prange, attrs[i].value);
+ if (node && node->adev->apu_prefer_gtt &&
!p->xnack_enabled)
+ *update_mapping = true;
break;
case KFD_IOCTL_SVM_ATTR_ACCESS:
case KFD_IOCTL_SVM_ATTR_ACCESS_IN_PLACE: