Re: [PATCH 1/1] drm/amdgpu: fix ftrace event amdgpu_bo_move always move on same heap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 11.12.23 um 05:29 schrieb Wang, Beyond:

[AMD Official Use Only - General]


Subject: [PATCH 1/1] drm/amdgpu: fix ftrace event amdgpu_bo_move always move on same heap

 

Issue: during evict or validate happened on amdgpu_bo, the 'from' and

'to' is always same in ftrace event of amdgpu_bo_move

 

where calling the 'trace_amdgpu_bo_move', the comment says move_notify

is called before move happens, but actually it is called after move

happens, here the new_mem is same as bo->resource

 

Fix: pass old_mem instead when calling amdgpu_bo_move_notify


Good catch, but the tracepoint should probably be removed altogether.

amdgpu_bo_move_notify() is more for invalidation the mappings when something is moved or released.

We should rather add that to amdgpu_bo_move().

Regards,
Christian.

 

Signed-off-by: Wang, Beyond Wang.Beyond@xxxxxxx

---

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 +++++-----

drivers/gpu/drm/amd/amdgpu/amdgpu_object.h |  2 +-

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    |  2 +-

3 files changed, 7 insertions(+), 7 deletions(-)

 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 7416799..0288495 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

@@ -1282,7 +1282,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,

  * amdgpu_bo_move_notify - notification about a memory move

  * @bo: pointer to a buffer object

  * @evict: if this move is evicting the buffer from the graphics address space

- * @new_mem: new information of the bufer object

+ * @old_mem: old information of the buffer object

  *

  * Marks the corresponding &amdgpu_bo buffer object as invalid, also performs

  * bookkeeping.

@@ -1290,11 +1290,11 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,

  */

void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,

                           bool evict,

-                          struct ttm_resource *new_mem)

+                          struct ttm_resource *old_mem)

{

        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);

        struct amdgpu_bo *abo;

-       struct ttm_resource *old_mem = bo->resource;

+       struct ttm_resource *new_mem = bo->resource;

 

        if (!amdgpu_bo_is_amdgpu_bo(bo))

                return;

@@ -1315,10 +1315,10 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,

                atomic64_inc(&adev->num_evictions);

 

        /* update statistics */

-       if (!new_mem)

+       if (!old_mem || !new_mem)

                return;

 

-       /* move_notify is called before move happens */

+       /* move_notify is called after move happens in amdgpu_bo_move */

        trace_amdgpu_bo_move(abo, new_mem->mem_type, old_mem->mem_type);

}

 

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

index 876acde..88be4b8 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

@@ -362,7 +362,7 @@ int amdgpu_bo_get_metadata(struct amdgpu_bo *bo, void *buffer,

                           uint64_t *flags);

void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,

                           bool evict,

-                          struct ttm_resource *new_mem);

+                          struct ttm_resource *old_mem);

void amdgpu_bo_release_notify(struct ttm_buffer_object *bo);

vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo);

void amdgpu_bo_fence(struct amdgpu_bo *bo, struct dma_fence *fence,

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 41ed6a3..8cc85d3 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

@@ -579,7 +579,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,

out:

        /* update statistics */

        atomic64_add(bo->base.size, &adev->num_bytes_moved);

-       amdgpu_bo_move_notify(bo, evict, new_mem);

+       amdgpu_bo_move_notify(bo, evict, old_mem);

        return 0;

}

 

--

2.34.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux