drm/ttm: fix ttm_bo_bulk_move_helper
Subsystems (4)
PATCH 1/3 drm/ttm: fix ttm_bo_bulk_move_helper
Staring at the function for six hours, just to essentially move one line of code.
--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +8 -5
@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);static void ttm_bo_bulk_move_helper (struct ttm_lru_bulk_move_pos *pos,struct list_head *lru,bool is_swap) { +struct list_head *list;LIST_HEAD (entries);LIST_HEAD (before); -struct list_head *list1, *list2; - list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +reservation_object_assert_held (pos->last->resv); + list = is_swap ? &pos->last->swap : &pos->last->lru; +list_cut_position (&entries, lru, list); + +reservation_object_assert_held (pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +list_cut_position (&before, &entries, list); -list_cut_position (&entries, lru, list1); -list_cut_position (&before, &entries, list2);list_splice (&before, lru);list_splice_tail (&entries, lru); }
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180831131019.2486-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/3 drm/amdgpu: fix "use bulk moves for efficient VM LRU handling" v2
First step to fix the LRU corruption, we accidentially tried to move things on the LRU after dropping the lock.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -3
@@ -1237,6 +1237,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, ring =to_amdgpu_ring (entity->rq->sched);amdgpu_ring_priority_get (ring, priority); +amdgpu_vm_move_to_lru_tail (p->adev, &fpriv->vm); +ttm_eu_fence_buffer_objects (&p->ticket, &p->validated, p->fence);amdgpu_mn_unlock (p->mn);
@@ -1258,7 +1260,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)union drm_amdgpu_cs *cs = data;struct amdgpu_cs_parser parser = {};bool reserved_buffers = false; -struct amdgpu_fpriv *fpriv;int i, r;if (!adev->accel_working)
@@ -1303,8 +1304,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r =amdgpu_cs_submit (&parser, cs); - fpriv = filp->driver_priv; -amdgpu_vm_move_to_lru_tail (adev, &fpriv->vm); out:amdgpu_cs_parser_fini (&parser, r, reserved_buffers);return r;
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180831131019.2486-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Zhang, Jerry (Junwei)
Reviewed-by Junwei ZhangRe: [PATCH 2/3] drm/amdgpu: fix "use bulk moves for efficient VM LRU handling" v2
Quoted 4 lines · Christian König
First step to fix the LRU corruption, we accidentially tried to move things on the LRU after dropping the lock.
Signed-off-by Christian König <[email protected]>
Quoted 27 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2
-1@@ -1237,6 +1237,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, ring =to_amdgpu_ring (entity->rq->sched);amdgpu_ring_priority_get (ring, priority); +amdgpu_vm_move_to_lru_tail (p->adev, &fpriv->vm); +ttm_eu_fence_buffer_objects (&p->ticket, &p->validated, p->fence);amdgpu_mn_unlock (p->mn);@@ -1258,7 +1260,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)union drm_amdgpu_cs *cs = data;struct amdgpu_cs_parser parser = {};bool reserved_buffers = false; -struct amdgpu_fpriv *fpriv;int i, r;if (!adev->accel_working)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1309
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0
-2@@ -1303,8 +1304,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) r =amdgpu_cs_submit (&parser, cs); - fpriv = filp->driver_priv; -amdgpu_vm_move_to_lru_tail (adev, &fpriv->vm); out:amdgpu_cs_parser_fini (&parser, r, reserved_buffers);return r;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdgpu: fix idle state and bulk_moveavle flag
In reply to a message not in the archiveAdd BOs to the idle state again and correctly clear the flag when new BOs are added.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -5
@@ -156,12 +156,15 @@ static void amdgpu_vm_bo_base_init(struct amdgpu_vm_bo_base *base,return ;list_add_tail (&base->bo_list, &bo->va); -if (bo->tbo.type == ttm_bo_type_kernel) -list_move (&base->vm_status, &vm->relocated); -if (bo->tbo.resv != vm->root.base.bo->tbo.resv)return ; + vm->bulk_moveable = false; +if (bo->tbo.type == ttm_bo_type_kernel) +list_move (&base->vm_status, &vm->relocated); +else +list_move (&base->vm_status, &vm->idle); +if (bo->preferred_domains &amdgpu_mem_type_to_domain (bo->tbo.mem.mem_type))return ;
@@ -1121,7 +1124,7 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, struct amdgpu_vm_bo_base, vm_status); bo_base->moved = false; -list_del_init (&bo_base->vm_status); +list_move (&bo_base->vm_status, &vm->idle); bo = bo_base->bo->parent;if (!bo)
@@ -2646,7 +2649,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,return r; vm->pte_support_ats = false; - vm->bulk_moveable = true;if (vm_context ==AMDGPU_VM_CONTEXT_COMPUTE ) { vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180831131019.2486-3-christian.koenig-5C7GfCeVMHo@public.gmane.org
Michel Dänzer
Tested-byRe: [PATCH 3/3] drm/amdgpu: fix idle state and bulk_moveavle flag
Quoted 4 lines · Christian König
Add BOs to the idle state again and correctly clear the flag when new BOs are added.
Signed-off-by Christian König <[email protected]>
Typo in the shortlog: bulk_moveavle -> bulk_moveable
The series is
Thanks Christian!
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 2 lines · Christian König
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Quoted 17 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);static void ttm_bo_bulk_move_helper (struct ttm_lru_bulk_move_pos *pos,struct list_head *lru,bool is_swap) { +struct list_head *list;LIST_HEAD (entries);LIST_HEAD (before); -struct list_head *list1, *list2;
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 263
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +7
-2- list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +reservation_object_assert_held (pos->last->resv); + list = is_swap ? &pos->last->swap : &pos->last->lru; +list_cut_position (&entries, lru, list); + +reservation_object_assert_held (pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +list_cut_position (&before, &entries, list);
So the problem was that the first list_cut_position call could result in list2 pointing to la-la-land? Good catch!
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a186be44-e64b-f408-fa30-bb81b59322f6-otUistvHUpPR7s880joybQ@public.gmane.org
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
Quoted 25 lines · Christian König
Quoted 2 lines
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Quoted 18 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);static void ttm_bo_bulk_move_helper (struct ttm_lru_bulk_move_pos *pos,struct list_head *lru,bool is_swap) { +struct list_head *list;LIST_HEAD (entries);LIST_HEAD (before); -struct list_head *list1, *list2;
Quoted 11 lines
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 263
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +7
-2- list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +reservation_object_assert_held (pos->last->resv); + list = is_swap ? &pos->last->swap : &pos->last->lru; +list_cut_position (&entries, lru, list); + +reservation_object_assert_held (pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +list_cut_position (&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!
Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Can I get a tested-by? You where much better at reproducing that than I'm.
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): c8d0d5c6-1221-26be-4005-2f7ae21ade80-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 37 lines · Christian König
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
Quoted 27 lines · Christian König
Quoted 2 lines
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Quoted 20 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +2
-3@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);static void ttm_bo_bulk_move_helper (struct ttm_lru_bulk_move_pos *pos,struct list_head *lru,bool is_swap) { +struct list_head *list;LIST_HEAD (entries);LIST_HEAD (before); -struct list_head *list1, *list2; - list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +reservation_object_assert_held (pos->last->resv);Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 263
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +6
-0+ list = is_swap ? &pos->last->swap : &pos->last->lru; +list_cut_position (&entries, lru, list); + +reservation_object_assert_held (pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +list_cut_position (&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!
Quoted 5 lines
Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Can I get a tested-by? You where much better at reproducing that than I'm.
Michel, Christian, thanks so much to take care of this when I was on vacation. And sorry to let you take a long time for finding the cause.
Is that because I didn't hold the resveration before cut the list from position "first" and "last"? May I know in which cases, we must hold the bo's reservation firstly?
Thanks,
Ray
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 06.09.2018 um 12:02 schrieb Huang Rui:
Quoted 40 lines · Christian König
Quoted 39 lines
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
Quoted 27 lines · Christian König
Quoted 2 lines
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Quoted 20 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +2
-3@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);static void ttm_bo_bulk_move_helper (struct ttm_lru_bulk_move_pos *pos,struct list_head *lru,bool is_swap) { +struct list_head *list;LIST_HEAD (entries);LIST_HEAD (before); -struct list_head *list1, *list2; - list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +reservation_object_assert_held (pos->last->resv);Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 262
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +6
-0+ list = is_swap ? &pos->last->swap : &pos->last->lru; +list_cut_position (&entries, lru, list); + +reservation_object_assert_held (pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +list_cut_position (&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Quoted 7 lines
Quoted 2 lines
Can I get a tested-by? You where much better at reproducing that than I'm.
Michel, Christian, thanks so much to take care of this when I was on vacation. And sorry to let you take a long time for finding the cause.
Is that because I didn't hold the resveration before cut the list from position "first" and "last"?
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
Quoted 2 lines
May I know in which cases, we must hold the
bo's reservation firstly?
BOs are reserved to prevent moving them. E.g. when the BO isn't reserved it can move around and so the LRU where you want to add/remove it could change.
Christian.
Quoted 5 lines
Thanks,
Ray
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 3be7e67a-2ffe-21c0-2160-69a330413858-5C7GfCeVMHo@public.gmane.org
Quoted 3 lines
Quoted 3 lines
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
I went through again about the list cutting behavior and wrote down with the attached picture.
After do the second list_cut_position, the list2 should be point the end of "before" list. And list2 won't be used anymore after list cutting. May I know am I something missed?
Thanks,
Ray
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Thursday, September 6, 2018 6:06 PM
To: Huang, Ray
Cc: Michel Dänzer; [email protected]
Subject: Re: [PATCH 1/3] drm/ttm: fix ttm_bo_bulk_move_helper
Am 06.09.2018 um 12:02 schrieb Huang Rui:
Quoted 40 lines · Christian König
Quoted 39 lines
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
Quoted 27 lines · Christian König
Quoted 2 lines
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Quoted 20 lines
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c| 13 ++++++++-----1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +2
-3@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); static void ttm_bo_bulk_move_helper(struct ttm_lru_bulk_move_pos *pos, struct list_head *lru, bool is_swap) { + struct list_head *list; LIST_HEAD(entries); LIST_HEAD(before); - struct list_head *list1, *list2; - list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; + reservation_object_assert_held(pos->last->resv);Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 262
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +6
-0+ list = is_swap ? &pos->last->swap : &pos->last->lru; + list_cut_position(&entries, lru, list); + + reservation_object_assert_held(pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; + list_cut_position(&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Quoted 7 lines
Quoted 2 lines
Can I get a tested-by? You where much better at reproducing that than I'm.
Michel, Christian, thanks so much to take care of this when I was on vacation. And sorry to let you take a long time for finding the cause.
Is that because I didn't hold the resveration before cut the list from position "first" and "last"?
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
Quoted 2 lines
May I know in which cases, we must hold the
bo's reservation firstly?
BOs are reserved to prevent moving them. E.g. when the BO isn't reserved it can move around and so the LRU where you want to add/remove it could change.
Christian.
Quoted 5 lines
Thanks,
Ray
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY1PR12MB0043539F7EE805B3A98E1FE2EC000-1s8aH8ViOEdbUNsZNX5b0gdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 07.09.2018 um 13:02 schrieb Huang, Ray:
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
I went through again about the list cutting behavior and wrote down with the attached picture.
After do the secondlist_cut_position, the list2 should be point the end of "before" list. And list2 won't be used anymore after list cutting. May I know am I something missed?
Let's take a look at the original code:
Quoted 5 lines
list1 =
is_swap?&pos->last->swap:&pos->last->lru; list2 =is_swap?pos->first->swap.prev:pos->first->lru.prev;
list_cut_position(&entries, lru, list1);list_cut_position(&before, &entries, list2);
As far as I can see the problem is that the first list_cur_position could modify the value of pos->first->lru.prev and so make the second list_cut_position work on the wrong position.
Regards,
Christian.
Quoted 87 lines
Thanks,
RayFrom: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Thursday, September 6, 2018 6:06 PM
To: Huang, Ray
Cc: Michel Dänzer; [email protected]
Subject: Re: [PATCH 1/3] drm/ttm: fixttm_bo_bulk_move_helperAm 06.09.2018 um 12:02 schrieb Huang Rui:
Quoted 40 lines · Christian König
Quoted 39 lines
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
Quoted 27 lines · Christian König
Quoted 2 lines
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Quoted 20 lines
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +2
-3@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); static void ttm_bo_bulk_move_helper(struct ttm_lru_bulk_move_pos *pos, struct list_head *lru, bool is_swap) { + struct list_head *list; LIST_HEAD(entries); LIST_HEAD(before); - struct list_head *list1, *list2; - list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; + reservation_object_assert_held(pos->last->resv);Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 262
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +6
-0+ list = is_swap ? &pos->last->swap : &pos->last->lru; + list_cut_position(&entries, lru, list); + + reservation_object_assert_held(pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; + list_cut_position(&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Quoted 7 lines
Quoted 2 lines
Can I get a tested-by? You where much better at reproducing that than I'm.
Michel, Christian, thanks so much to take care of this when I was on vacation. And sorry to let you take a long time for finding the cause.
Is that because I didn't hold the resveration before cut the list from position "first" and "last"?
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
Quoted 2 lines
May I know in which cases, we must hold the
bo's reservation firstly?BOs are reserved to prevent moving them. E.g. when the BO isn't reserved it can move around and so the LRU where you want to add/remove it could change.
Christian.
Quoted 4 lines
Thanks,
Ray_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfxamd-gfx Info Page - freedesktop.org
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 24dbe7c4-63df-b8a7-28c3-df0e9866841f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 18 lines · Christian K�nig
Am 07.09.2018 um 13:02 schrieb Huang, Ray:
Yes, that was one problem. Another was that the cutting code was buggy
and determined one of the positions to cut at the wrong time.I went through again about the list cutting behavior and wrote down with the attached picture.
After do the secondlist_cut_position, the list2 should be point the end of "before" list. And list2 won't be used anymore after list cutting. May I know am I something missed?Let's take a look at the original code:
list1 = is_swap ? &pos->last->swap : &pos->last->lru; list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; list_cut_position(&entries, lru, list1); list_cut_position(&before, &entries, list2);
Quoted 4 lines
As far as I can see the problem is that the first
list_cur_positioncould modify the value ofpos->first->lru.prevand so make the secondlist_cut_positionwork on the wrong position.
I think I understood. In this case (the first element of LRU == pos->first->lru), please see the picture. If we store first->lru.prev as list2(LRU head), after do list cutting, the first->lru.prev will overwrite as new head (entries), however, the orignal list2 will still point previous head (that is the wrong position now). We actually expected to use the latest first->lru.prev as the second cutting position. So we should adjust code sequence like below:
list1 = is_swap ? &pos->last->swap : &pos->last->lru; list_cut_position(&entries, lru, list1);
list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; list_cut_position(&before, &entries, list2);
Am I understanding right?
Thanks,
Ray
Quoted 106 lines
Regards,
Christian.Thanks,
RayFrom: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Thursday, September 6, 2018 6:06 PM
To: Huang, Ray
Cc: Michel Dänzer; [email protected]
Subject: Re: [PATCH 1/3] drm/ttm: fixttm_bo_bulk_move_helperAm 06.09.2018 um 12:02 schrieb Huang Rui:
On Fri, Aug 31, 2018 at 05:17:33PM +0200, Christian König wrote:
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
On 2018-08-31 3:10 p.m., Christian König wrote:
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c| 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)diff --git
a/drivers/gpu/drm/ttm/ttm_bo.cb/drivers/gpu/drm/ttm/ttm_bo.cindex35d53d81f486..138c98902033100644
---a/drivers/gpu/drm/ttm/ttm_bo.c
+++b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -250,15 +250,18 @@EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
static void ttm_bo_bulk_move_helper(structttm_lru_bulk_move_pos*pos,
structlist_head*lru, boolis_swap)
{
+ structlist_head*list;
LIST_HEAD(entries);
LIST_HEAD(before);
- structlist_head*list1, *list2;
- list1 =is_swap?&pos->last->swap:&pos->last->lru;
- list2 =is_swap?pos->first->swap.prev:pos->first->lru.prev;
+reservation_object_assert_held(pos->last->resv);
+ list =is_swap?&pos->last->swap:&pos->last->lru;
+list_cut_position(&entries, lru, list);
+
+reservation_object_assert_held(pos->first->resv);
+ list =is_swap?pos->first->swap.prev:pos->first->lru.prev;
+list_cut_position(&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Can I get a tested-by? You where much better at reproducing that than I'm.
Michel, Christian, thanks so much to take care of this when I was on vacation. And sorry to let you take a long time for finding the cause.
Is that because I didn't hold the resveration before cut the list from position "first" and "last"?
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
May I know in which cases, we must hold the
bo's reservation firstly?BOs are reserved to prevent moving them. E.g. when the BO isn't reserved it can move around and so the LRU where you want to add/remove it could change.
Christian.
Thanks,
Ray_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfxamd-gfx Info Page - freedesktop.org
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected] You can subscribe to the list, or change your existing subscription, in the sections below.
Quoted 6 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 08.09.2018 um 09:54 schrieb Huang Rui:
Quoted 31 lines · Christian K�nig
Quoted 18 lines
Am 07.09.2018 um 13:02 schrieb Huang, Ray:
Yes, that was one problem. Another was that the cutting code was buggy
and determined one of the positions to cut at the wrong time.I went through again about the list cutting behavior and wrote down with the attached picture.
After do the secondlist_cut_position, the list2 should be point the end of "before" list. And list2 won't be used anymore after list cutting. May I know am I something missed?Let's take a look at the original code:
list1 = is_swap ? &pos->last->swap : &pos->last->lru; list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; list_cut_position(&entries, lru, list1); list_cut_position(&before, &entries, list2);Quoted 4 lines
As far as I can see the problem is that the first
list_cur_positioncould modify the value ofpos->first->lru.prevand so make the secondlist_cut_positionwork on the wrong position.I think I understood. In this case (the first element of LRU ==
pos->first->lru), please see the picture. If we storefirst->lru.prevas list2(LRU head), after do list cutting, thefirst->lru.prevwill overwrite as new head (entries), however, the orignal list2 will still point previous head (that is the wrong position now). We actually expected to use the latestfirst->lru.prevas the second cutting position. So we should adjust code sequence like below:
Quoted 7 lines
list1 =
is_swap?&pos->last->swap:&pos->last->lru;list_cut_position(&entries, lru, list1);list2 =
is_swap?pos->first->swap.prev:pos->first->lru.prev;list_cut_position(&before, &entries, list2);Am I understanding right?
Yes, exactly. And the fix looks like what I did as well. Just only used one variable and added some extra BUG_ON().
Christian.
Quoted 116 lines
Thanks,
RayQuoted 112 lines
Regards,
Christian.Thanks,
RayFrom: amd-gfx <[email protected]> on behalf of Christian König <[email protected]>
Sent: Thursday, September 6, 2018 6:06 PM
To: Huang, Ray
Cc: Michel Dänzer; [email protected]
Subject: Re: [PATCH 1/3] drm/ttm: fixttm_bo_bulk_move_helperAm 06.09.2018 um 12:02 schrieb Huang Rui:
On Fri, Aug 31, 2018 at 05:17:33PM +0200, Christian König wrote:
Am 31.08.2018 um 17:15 schrieb Michel Dänzer:
On 2018-08-31 3:10 p.m., Christian König wrote:
Staring at the function for six hours, just to essentially move one line of code.
That sucks, but the commit log should describe what the problem was and how this patch solves it.
Signed-off-by Christian König <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c| 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)diff --git
a/drivers/gpu/drm/ttm/ttm_bo.cb/drivers/gpu/drm/ttm/ttm_bo.cindex35d53d81f486..138c98902033100644
---a/drivers/gpu/drm/ttm/ttm_bo.c
+++b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -250,15 +250,18 @@EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
static void ttm_bo_bulk_move_helper(structttm_lru_bulk_move_pos*pos,
structlist_head*lru, boolis_swap)
{
+ structlist_head*list;
LIST_HEAD(entries);
LIST_HEAD(before);
- structlist_head*list1, *list2;
- list1 =is_swap?&pos->last->swap:&pos->last->lru;
- list2 =is_swap?pos->first->swap.prev:pos->first->lru.prev;
+reservation_object_assert_held(pos->last->resv);
+ list =is_swap?&pos->last->swap:&pos->last->lru;
+list_cut_position(&entries, lru, list);
+
+reservation_object_assert_held(pos->first->resv);
+ list =is_swap?pos->first->swap.prev:pos->first->lru.prev;
+list_cut_position(&before, &entries, list);So the problem was that the first
list_cut_positioncall could result in list2 pointing to la-la-land? Good catch!Yes, exactly. Thought that would be obvious, but going to add that to the commit log.
Can I get a tested-by? You where much better at reproducing that than I'm.
Michel, Christian, thanks so much to take care of this when I was on vacation. And sorry to let you take a long time for finding the cause.
Is that because I didn't hold the resveration before cut the list from position "first" and "last"?
Yes, that was one problem. Another was that the cutting code was buggy and determined one of the positions to cut at the wrong time.
May I know in which cases, we must hold the
bo's reservation firstly?BOs are reserved to prevent moving them. E.g. when the BO isn't reserved it can move around and so the LRU where you want to add/remove it could change.
Christian.
Thanks,
Ray_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfxamd-gfx Info Page - freedesktop.org
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message to all the list members, send email to [email protected]. You can subscribe to the list, or change your existing subscription, in the sections below._______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Zhang, Jerry (Junwei)
Reviewed-by Junwei ZhangQuoted 4 lines · Christian König
Staring at the function for six hours, just to essentially move one line of code.
Signed-off-by Christian König <[email protected]>
Quoted 23 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +4
-3@@ -250,15 +250,18 @@ EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);static void ttm_bo_bulk_move_helper (struct ttm_lru_bulk_move_pos *pos,struct list_head *lru,bool is_swap) { +struct list_head *list;LIST_HEAD (entries);LIST_HEAD (before); -struct list_head *list1, *list2; - list1 = is_swap ? &pos->last->swap : &pos->last->lru; - list2 = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +reservation_object_assert_held (pos->last->resv); + list = is_swap ? &pos->last->swap : &pos->last->lru; +list_cut_position (&entries, lru, list);
drivers/gpu/drm/ttm/ttm_bo.c EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); · line 267
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +4
-2+ +reservation_object_assert_held (pos->first->resv); + list = is_swap ? pos->first->swap.prev : pos->first->lru.prev; +list_cut_position (&before, &entries, list); -list_cut_position (&entries, lru, list1); -list_cut_position (&before, &entries, list2);list_splice (&before, lru);list_splice_tail (&entries, lru); }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx