<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2023-10-02 13:08, Chen, Xiaogang
wrote:<br>
</div>
<blockquote type="cite" cite="mid:678650fb-8fb1-7f2c-cdb9-6a01d9095a34@amd.com">
<br>
On 9/29/2023 9:11 AM, Philip Yang wrote:
<br>
<blockquote type="cite">Caution: This message originated from an
External Source. Use proper caution when opening attachments,
clicking links, or responding.
<br>
<br>
<br>
Use bitmap_mapped flag to check if range already mapped to the
specific
<br>
GPU, to skip the retry fault from different page of the same
range.
<br>
<br>
Remove prange validate_timestamp which is not accurate for
multiple
<br>
GPUs.
<br>
<br>
Signed-off-by: Philip Yang <a class="moz-txt-link-rfc2396E" href="mailto:Philip.Yang@amd.com"><Philip.Yang@amd.com></a>
<br>
---
<br>
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 24
++++++++----------------
<br>
drivers/gpu/drm/amd/amdkfd/kfd_svm.h | 1 -
<br>
2 files changed, 8 insertions(+), 17 deletions(-)
<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
<br>
index ac65bf25c685..5e063d902a46 100644
<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
<br>
@@ -43,10 +43,6 @@
<br>
<br>
#define AMDGPU_SVM_RANGE_RESTORE_DELAY_MS 1
<br>
<br>
-/* Long enough to ensure no retry fault comes after svm range
is restored and
<br>
- * page table is updated.
<br>
- */
<br>
-#define AMDGPU_SVM_RANGE_RETRY_FAULT_PENDING (2UL *
NSEC_PER_MSEC)
<br>
#if IS_ENABLED(CONFIG_DYNAMIC_DEBUG)
<br>
#define dynamic_svm_range_dump(svms) \
<br>
_dynamic_func_call_no_desc("svm_range_dump",
svm_range_debug_dump, svms)
<br>
@@ -365,7 +361,6 @@ svm_range *svm_range_new(struct
svm_range_list *svms, uint64_t start,
<br>
INIT_LIST_HEAD(&prange->deferred_list);
<br>
INIT_LIST_HEAD(&prange->child_list);
<br>
atomic_set(&prange->invalid, 0);
<br>
- prange->validate_timestamp = 0;
<br>
mutex_init(&prange->migrate_mutex);
<br>
mutex_init(&prange->lock);
<br>
<br>
@@ -1876,8 +1871,6 @@ static int
svm_range_validate_and_map(struct mm_struct *mm,
<br>
}
<br>
<br>
svm_range_unreserve_bos(ctx);
<br>
- if (!r)
<br>
- prange->validate_timestamp =
ktime_get_boottime();
<br>
<br>
free_ctx:
<br>
kfree(ctx);
<br>
@@ -3162,15 +3155,6 @@ svm_range_restore_pages(struct
amdgpu_device *adev, unsigned int pasid,
<br>
goto out_unlock_range;
<br>
}
<br>
<br>
- /* skip duplicate vm fault on different pages of same
range */
<br>
- if (ktime_before(timestamp,
ktime_add_ns(prange->validate_timestamp,
<br>
-
AMDGPU_SVM_RANGE_RETRY_FAULT_PENDING))) {
<br>
- pr_debug("svms 0x%p [0x%lx %lx] already
restored\n",
<br>
- svms, prange->start,
prange->last);
<br>
- r = 0;
<br>
- goto out_unlock_range;
<br>
- }
<br>
-
<br>
/* __do_munmap removed VMA, return success as we are
handling stale
<br>
* retry fault.
<br>
*/
<br>
@@ -3196,6 +3180,14 @@ svm_range_restore_pages(struct
amdgpu_device *adev, unsigned int pasid,
<br>
goto out_unlock_range;
<br>
}
<br>
<br>
+ /* skip duplicate vm fault on different pages of same
range */
<br>
</blockquote>
<br>
I think the following call means if the prange->granularity
range that the addr is in is mapped on gpuidex already, not
different pages of same range.
<br>
</blockquote>
yes, the comment should update to "skip duplicate vm fault on
different pages of same granularity range"
<blockquote type="cite" cite="mid:678650fb-8fb1-7f2c-cdb9-6a01d9095a34@amd.com">
<br>
Regards
<br>
<br>
Xiaogang
<br>
<br>
<blockquote type="cite">+ if
(svm_range_partial_mapped_dev(gpuidx, prange, addr, addr)) {
<br>
+ pr_debug("svms 0x%p [0x%lx %lx] already restored
on gpu %d\n",
<br>
+ svms, prange->start,
prange->last, gpuidx);
<br>
+ r = 0;
<br>
+ goto out_unlock_range;
<br>
+ }
<br>
+
<br>
pr_debug("svms %p [0x%lx 0x%lx] best restore 0x%x,
actual loc 0x%x\n",
<br>
svms, prange->start, prange->last,
best_loc,
<br>
prange->actual_loc);
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
b/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
<br>
index 10c92c5e23a7..3afc33a3dd30 100644
<br>
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
<br>
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.h
<br>
@@ -125,7 +125,6 @@ struct svm_range {
<br>
uint32_t actual_loc;
<br>
uint8_t granularity;
<br>
atomic_t invalid;
<br>
- ktime_t validate_timestamp;
<br>
struct mmu_interval_notifier notifier;
<br>
struct svm_work_list_item work_item;
<br>
struct list_head deferred_list;
<br>
--
<br>
2.35.1
<br>
<br>
</blockquote>
</blockquote>
</body>
</html>