Skip to contentSkip to conversation

drm/amdkfd: don't gate userptr cleanup on the owning mm

PATCH New Perry Yuan 1 participant 1 message Sep 2

Subsystems (3)
lore
Share & tools
lore

Perry Yuan

author
#0 lore raw

PATCH 1/1 drm/amdkfd: don't gate userptr cleanup on the owning mm

amdgpu_ttm_tt_get_usermm() returns gtt->usertask->mm. By the time KFD frees its BOs from kfd_process_wq_release(), the process has long since run exit_mm() and that pointer is NULL, so the cleanup below is simply skipped on process teardown. mem->user_pages then leaks along with the page references it still holds, or mem->range on HMM builds.

Check the USERPTR alloc flag instead. It is set when the BO is created and stays valid no matter what the process does.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 7882f1385248..a5d1d83ee5d3 100644
@@ -1954,7 +1954,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
 		return ret;
 
 	/* Cleanup user pages and MMU notifiers */
-	if (amdgpu_ttm_tt_get_usermm(mem->bo->tbo.ttm)) {
+	if (mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_USERPTR) {
 		amdgpu_hmm_unregister(mem->bo);
 		amdgpu_hmm_range_free(mem->range);
 		mem->range = NULL;
Signature · 1 line
2.34.1