* [PATCH 1/2] list: introduce list_bulk_move_tail helper @ 2018-09-13 11:22 Christian König 2018-09-13 11:22 ` [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 Christian König 2018-09-14 2:53 ` Huang Rui 0 siblings, 2 replies; 5+ messages in thread From: Christian König @ 2018-09-13 11:22 UTC (permalink / raw) To: amd-gfx, dri-devel, linux-kernel Move all entries between @first and including @last before @head. This is useful for LRU lists where a whole block of entries should be moved to the end of an list. Signed-off-by: Christian König <christian.koenig@amd.com> --- include/linux/list.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index de04cc5ed536..edb7628e46ed 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -183,6 +183,29 @@ static inline void list_move_tail(struct list_head *list, list_add_tail(list, head); } +/** + * list_bulk_move_tail - move a subsection of a list to its tail + * @head: the head that will follow our entry + * @first: first entry to move + * @last: last entry to move, can be the same as first + * + * Move all entries between @first and including @last before @head. + * All three entries must belong to the same linked list. + */ +static inline void list_bulk_move_tail(struct list_head *head, + struct list_head *first, + struct list_head *last) +{ + first->prev->next = last->next; + last->next->prev = first->prev; + + head->prev->next = first; + first->prev = head->prev; + + last->next = head; + head->prev = last; +} + /** * list_is_last - tests whether @list is the last entry in list @head * @list: the entry to test -- 2.14.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 2018-09-13 11:22 [PATCH 1/2] list: introduce list_bulk_move_tail helper Christian König @ 2018-09-13 11:22 ` Christian König 2018-09-13 15:52 ` Mike Lothian 2018-09-14 2:53 ` Huang Rui 1 sibling, 1 reply; 5+ messages in thread From: Christian König @ 2018-09-13 11:22 UTC (permalink / raw) To: amd-gfx, dri-devel, linux-kernel While cutting the lists we sometimes accidentally added a list_head from the stack to the LRUs, effectively corrupting the list. Remove the list cutting and use explicit list manipulation instead. v2: separate out new list_bulk_move_tail helper Signed-off-by: Christian König <christian.koenig@amd.com> --- drivers/gpu/drm/ttm/ttm_bo.c | 46 +++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 138c98902033..26b889f86670 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -247,47 +247,38 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, } 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); - - 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_splice(&before, lru); - list_splice_tail(&entries, lru); -} - void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) { unsigned i; for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i]; struct ttm_mem_type_manager *man; - if (!bulk->tt[i].first) + if (!pos->first) continue; - man = &bulk->tt[i].first->bdev->man[TTM_PL_TT]; - ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false); + reservation_object_assert_held(pos->first->resv); + reservation_object_assert_held(pos->last->resv); + + man = &pos->first->bdev->man[TTM_PL_TT]; + list_bulk_move_tail(&man->lru[i], &pos->first->lru, + &pos->last->lru); } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { + struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i]; struct ttm_mem_type_manager *man; - if (!bulk->vram[i].first) + if (!pos->first) continue; - man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM]; - ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], false); + reservation_object_assert_held(pos->first->resv); + reservation_object_assert_held(pos->last->resv); + + man = &pos->first->bdev->man[TTM_PL_VRAM]; + list_bulk_move_tail(&man->lru[i], &pos->first->lru, + &pos->last->lru); } for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { @@ -297,8 +288,11 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) if (!pos->first) continue; + reservation_object_assert_held(pos->first->resv); + reservation_object_assert_held(pos->last->resv); + lru = &pos->first->bdev->glob->swap_lru[i]; - ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true); + list_bulk_move_tail(lru, &pos->first->swap, &pos->last->swap); } } EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); -- 2.14.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 2018-09-13 11:22 ` [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 Christian König @ 2018-09-13 15:52 ` Mike Lothian 0 siblings, 0 replies; 5+ messages in thread From: Mike Lothian @ 2018-09-13 15:52 UTC (permalink / raw) To: Christian König; +Cc: dri-devel, amd-gfx, linux-kernel [-- Attachment #1.1: Type: text/plain, Size: 4377 bytes --] Hi This fixes a boot issue I had on Raven ( https://bugs.freedesktop.org/show_bug.cgi?id=107922) Feel free to add to both patches: Tested-by: Mike Lothian <mike@fireburn.co.uk> Cheers Mike On Thu, 13 Sep 2018 at 12:22 Christian König < ckoenig.leichtzumerken@gmail.com> wrote: > While cutting the lists we sometimes accidentally added a list_head from > the stack to the LRUs, effectively corrupting the list. > > Remove the list cutting and use explicit list manipulation instead. > > v2: separate out new list_bulk_move_tail helper > > Signed-off-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 46 > +++++++++++++++++++------------------------- > 1 file changed, 20 insertions(+), 26 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index 138c98902033..26b889f86670 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -247,47 +247,38 @@ void ttm_bo_move_to_lru_tail(struct > ttm_buffer_object *bo, > } > 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); > - > - 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_splice(&before, lru); > - list_splice_tail(&entries, lru); > -} > - > void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) > { > unsigned i; > > for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { > + struct ttm_lru_bulk_move_pos *pos = &bulk->tt[i]; > struct ttm_mem_type_manager *man; > > - if (!bulk->tt[i].first) > + if (!pos->first) > continue; > > - man = &bulk->tt[i].first->bdev->man[TTM_PL_TT]; > - ttm_bo_bulk_move_helper(&bulk->tt[i], &man->lru[i], false); > + reservation_object_assert_held(pos->first->resv); > + reservation_object_assert_held(pos->last->resv); > + > + man = &pos->first->bdev->man[TTM_PL_TT]; > + list_bulk_move_tail(&man->lru[i], &pos->first->lru, > + &pos->last->lru); > } > > for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { > + struct ttm_lru_bulk_move_pos *pos = &bulk->vram[i]; > struct ttm_mem_type_manager *man; > > - if (!bulk->vram[i].first) > + if (!pos->first) > continue; > > - man = &bulk->vram[i].first->bdev->man[TTM_PL_VRAM]; > - ttm_bo_bulk_move_helper(&bulk->vram[i], &man->lru[i], > false); > + reservation_object_assert_held(pos->first->resv); > + reservation_object_assert_held(pos->last->resv); > + > + man = &pos->first->bdev->man[TTM_PL_VRAM]; > + list_bulk_move_tail(&man->lru[i], &pos->first->lru, > + &pos->last->lru); > } > > for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { > @@ -297,8 +288,11 @@ void ttm_bo_bulk_move_lru_tail(struct > ttm_lru_bulk_move *bulk) > if (!pos->first) > continue; > > + reservation_object_assert_held(pos->first->resv); > + reservation_object_assert_held(pos->last->resv); > + > lru = &pos->first->bdev->glob->swap_lru[i]; > - ttm_bo_bulk_move_helper(&bulk->swap[i], lru, true); > + list_bulk_move_tail(lru, &pos->first->swap, > &pos->last->swap); > } > } > EXPORT_SYMBOL(ttm_bo_bulk_move_lru_tail); > -- > 2.14.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel > [-- Attachment #1.2: Type: text/html, Size: 5979 bytes --] [-- Attachment #2: Type: text/plain, Size: 160 bytes --] _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] list: introduce list_bulk_move_tail helper 2018-09-13 11:22 [PATCH 1/2] list: introduce list_bulk_move_tail helper Christian König @ 2018-09-14 2:53 ` Huang Rui 2018-09-14 2:53 ` Huang Rui 1 sibling, 0 replies; 5+ messages in thread From: Huang Rui @ 2018-09-14 2:53 UTC (permalink / raw) To: Christian König; +Cc: amd-gfx, dri-devel, linux-kernel On Thu, Sep 13, 2018 at 01:22:07PM +0200, Christian König wrote: > Move all entries between @first and including @last before @head. > > This is useful for LRU lists where a whole block of entries should be > moved to the end of an list. > > Signed-off-by: Christian König <christian.koenig@amd.com> Bulk move helper is useful for TTM driver to improve the LRU moving efficiency. Please go on with my RB. Series are Reviewed-and-Tested-by: Huang Rui <ray.huang@amd.com> > --- > include/linux/list.h | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/include/linux/list.h b/include/linux/list.h > index de04cc5ed536..edb7628e46ed 100644 > --- a/include/linux/list.h > +++ b/include/linux/list.h > @@ -183,6 +183,29 @@ static inline void list_move_tail(struct list_head *list, > list_add_tail(list, head); > } > > +/** > + * list_bulk_move_tail - move a subsection of a list to its tail > + * @head: the head that will follow our entry > + * @first: first entry to move > + * @last: last entry to move, can be the same as first > + * > + * Move all entries between @first and including @last before @head. > + * All three entries must belong to the same linked list. > + */ > +static inline void list_bulk_move_tail(struct list_head *head, > + struct list_head *first, > + struct list_head *last) > +{ > + first->prev->next = last->next; > + last->next->prev = first->prev; > + > + head->prev->next = first; > + first->prev = head->prev; > + > + last->next = head; > + head->prev = last; > +} > + > /** > * list_is_last - tests whether @list is the last entry in list @head > * @list: the entry to test > -- > 2.14.1 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] list: introduce list_bulk_move_tail helper @ 2018-09-14 2:53 ` Huang Rui 0 siblings, 0 replies; 5+ messages in thread From: Huang Rui @ 2018-09-14 2:53 UTC (permalink / raw) To: Christian König; +Cc: amd-gfx, dri-devel, linux-kernel On Thu, Sep 13, 2018 at 01:22:07PM +0200, Christian König wrote: > Move all entries between @first and including @last before @head. > > This is useful for LRU lists where a whole block of entries should be > moved to the end of an list. > > Signed-off-by: Christian König <christian.koenig@amd.com> Bulk move helper is useful for TTM driver to improve the LRU moving efficiency. Please go on with my RB. Series are Reviewed-and-Tested-by: Huang Rui <ray.huang@amd.com> > --- > include/linux/list.h | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/include/linux/list.h b/include/linux/list.h > index de04cc5ed536..edb7628e46ed 100644 > --- a/include/linux/list.h > +++ b/include/linux/list.h > @@ -183,6 +183,29 @@ static inline void list_move_tail(struct list_head *list, > list_add_tail(list, head); > } > > +/** > + * list_bulk_move_tail - move a subsection of a list to its tail > + * @head: the head that will follow our entry > + * @first: first entry to move > + * @last: last entry to move, can be the same as first > + * > + * Move all entries between @first and including @last before @head. > + * All three entries must belong to the same linked list. > + */ > +static inline void list_bulk_move_tail(struct list_head *head, > + struct list_head *first, > + struct list_head *last) > +{ > + first->prev->next = last->next; > + last->next->prev = first->prev; > + > + head->prev->next = first; > + first->prev = head->prev; > + > + last->next = head; > + head->prev = last; > +} > + > /** > * list_is_last - tests whether @list is the last entry in list @head > * @list: the entry to test > -- > 2.14.1 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-09-14 2:53 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-09-13 11:22 [PATCH 1/2] list: introduce list_bulk_move_tail helper Christian König 2018-09-13 11:22 ` [PATCH 2/2] drm/ttm: once more fix ttm_bo_bulk_move_lru_tail v2 Christian König 2018-09-13 15:52 ` Mike Lothian 2018-09-14 2:53 ` [PATCH 1/2] list: introduce list_bulk_move_tail helper Huang Rui 2018-09-14 2:53 ` Huang Rui
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.