[PATCH] drm/amdgpu: Fix tlb_cb memory leaking
Philip Yang
Philip.Yang at amd.com
Mon Apr 8 13:06:56 UTC 2024
After updating GPU page table via CPU on large bar system, no fence
callback, call amdgpu_vm_tlb_seq_cb directly after command committed
to free tlb_cb.
memory leaking backtrace from kmemleakd:
unreferenced object 0xffffa036816b00c0 (size 32):
backtrace:
__kmem_cache_alloc_node+0x3fe/0x4d0
kmalloc_trace+0x2a/0xb0
amdgpu_vm_update_range+0x9b/0x8d0 [amdgpu]
amdgpu_vm_clear_freed+0xc1/0x210 [amdgpu]
unmap_bo_from_gpuvm.isra.36+0x37/0x50 [amdgpu]
amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu+0x118/0x1b0 [amdgpu]
kfd_process_device_free_bos+0x7c/0xe0 [amdgpu]
kfd_process_wq_release+0x273/0x3c0 [amdgpu]
process_scheduled_works+0x2a7/0x500
worker_thread+0x186/0x340
Fixes: 220ecde84bc8 ("drm/amdgpu: implement TLB flush fence")
Signed-off-by: Philip Yang <Philip.Yang at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 8af3f0fd3073..d0ef727cd7e1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -901,12 +901,9 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,
{
struct amdgpu_vm *vm = params->vm;
- if (!fence || !*fence)
- return;
-
tlb_cb->vm = vm;
- if (!dma_fence_add_callback(*fence, &tlb_cb->cb,
- amdgpu_vm_tlb_seq_cb)) {
+ if (fence && *fence &&
+ !dma_fence_add_callback(*fence, &tlb_cb->cb, amdgpu_vm_tlb_seq_cb)) {
dma_fence_put(vm->last_tlb_flush);
vm->last_tlb_flush = dma_fence_get(*fence);
} else {
--
2.43.2
More information about the amd-gfx
mailing list