[PATCH 1/2] drm/ttm: set ttm_buffer_object pointer as null after it's freed

Huang Rui ray.huang at amd.com
Tue Sep 11 07:34:04 UTC 2018


On Mon, Sep 10, 2018 at 09:10:00PM +0800, Koenig, Christian wrote:
> Am 10.09.2018 um 15:05 schrieb Tom St Denis:
> > On 2018-09-10 9:04 a.m., Christian König wrote:
> >> Hi Tom,
> >>
> >> I'm talking about adding new printks to figure out what the heck is 
> >> going wrong here.
> >>
> >> Thanks,
> >> Christian.
> >
> > Hi Christian,
> >
> > Sure, if you want to send me a simple patch that adds more printk I'll 
> > gladly give it a try (doubly so since my workstation depends on our 
> > staging tree to work properly...).
> 
> Just add a printk to ttm_bo_bulk_move_helper to print pos->first and 
> pos->last.
> 
> And another one to amdgpu_bo_destroy to printk the value of tbo.
> 

Hi Tom,

Could you help to add below traces to check when the bo is freed.

8<---
>From 919cabfbf4d202876a510cd51caa9c86cf7c8fd5 Mon Sep 17 00:00:00 2001
From: Huang Rui <ray.huang at amd.com>
Date: Tue, 11 Sep 2018 15:24:27 +0800
Subject: [PATCH] drm/amdgpu: add traces for lru bulk move

Signed-off-by: Huang Rui <ray.huang at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h  | 47 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     |  1 +
 3 files changed, 50 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index de990bd..ce28326 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -89,6 +89,8 @@ static void amdgpu_bo_destroy(struct ttm_buffer_object *tbo)
 	struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev);
 	struct amdgpu_bo *bo = ttm_to_amdgpu_bo(tbo);
 
+	trace_amdgpu_bo_destroy(bo);
+
 	if (bo->pin_count > 0)
 		amdgpu_bo_subtract_pin_size(bo);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
index 2e87414..5d93431 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
@@ -383,6 +383,53 @@ TRACE_EVENT(amdgpu_vm_flush,
 		      __entry->vm_hub,__entry->pd_addr)
 );
 
+TRACE_EVENT(amdgpu_vm_lru_bulk_move,
+	    TP_PROTO(struct amdgpu_vm *vm,
+		     struct amdgpu_bo *bo),
+	    TP_ARGS(vm, bo),
+	    TP_STRUCT__entry(
+			     __field(struct amdgpu_bo *, bo)
+			     __field(u32, mem_type)
+			     __field(struct ttm_buffer_object *, tt_first)
+			     __field(struct ttm_buffer_object *, tt_last)
+			     __field(struct ttm_buffer_object *, vram_first)
+			     __field(struct ttm_buffer_object *, vram_last)
+			     __field(struct ttm_buffer_object *, swap_first)
+			     __field(struct ttm_buffer_object *, swap_last)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->bo = bo;
+			   __entry->mem_type = bo->tbo.mem.mem_type;
+			   __entry->tt_first = vm->lru_bulk_move.tt[bo->tbo.priority].first;
+			   __entry->tt_last = vm->lru_bulk_move.tt[bo->tbo.priority].last;
+			   __entry->vram_first = vm->lru_bulk_move.vram[bo->tbo.priority].first;
+			   __entry->vram_last = vm->lru_bulk_move.vram[bo->tbo.priority].last;
+			   __entry->swap_first = vm->lru_bulk_move.swap[bo->tbo.priority].first;
+			   __entry->swap_last = vm->lru_bulk_move.swap[bo->tbo.priority].last;
+			   ),
+	    TP_printk("bo=%p, mem_type=%d, tt_first=%p, tt_last=%p, vram_first=%p, vram_last=%p, swap_first=%p, swap_last=%p",
+		      __entry->bo, __entry->mem_type,
+		      __entry->tt_first, __entry->tt_last,
+		      __entry->vram_first, __entry->vram_last,
+		      __entry->swap_first, __entry->swap_last)
+);
+
+TRACE_EVENT(amdgpu_bo_destroy,
+	    TP_PROTO(struct amdgpu_bo *bo),
+	    TP_ARGS(bo),
+	    TP_STRUCT__entry(
+			     __field(struct amdgpu_bo *, bo)
+			     __field(struct ttm_buffer_object *, tbo)
+			     ),
+
+	    TP_fast_assign(
+			   __entry->bo = bo;
+			   __entry->tbo = &bo->tbo;
+			   ),
+	    TP_printk("bo=%p, tbo=%p", __entry->bo, __entry->tbo)
+);
+
 DECLARE_EVENT_CLASS(amdgpu_pasid,
 	    TP_PROTO(unsigned pasid),
 	    TP_ARGS(pasid),
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ab95a9c..351bc58 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -391,6 +391,7 @@ void amdgpu_vm_move_to_lru_tail(struct amdgpu_device *adev,
 			continue;
 
 		ttm_bo_move_to_lru_tail(&bo->tbo, &vm->lru_bulk_move);
+		trace_amdgpu_vm_lru_bulk_move(vm, bo);
 		if (bo->shadow)
 			ttm_bo_move_to_lru_tail(&bo->shadow->tbo,
 						&vm->lru_bulk_move);
-- 
2.7.4



More information about the amd-gfx mailing list