aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-09-13 05:17:23 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-10-10 16:20:54 -0400
commitdf2fc43d09d3ee5ede82cab9299df5e78aa427b5 (patch)
treecb487e12ebde6c70e8877d99871296fe1947c331 /include/linux
parenta553c19d158535a62b513f5a9ef9f036a54b511f (diff)
list: introduce list_bulk_move_tail helper
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 the list. Used as a band aid in TTM, but better placed in the common list headers. Acked-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/list.h23
1 files changed, 23 insertions, 0 deletions
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
@@ -184,6 +184,29 @@ static inline void list_move_tail(struct list_head *list,
184} 184}
185 185
186/** 186/**
187 * list_bulk_move_tail - move a subsection of a list to its tail
188 * @head: the head that will follow our entry
189 * @first: first entry to move
190 * @last: last entry to move, can be the same as first
191 *
192 * Move all entries between @first and including @last before @head.
193 * All three entries must belong to the same linked list.
194 */
195static inline void list_bulk_move_tail(struct list_head *head,
196 struct list_head *first,
197 struct list_head *last)
198{
199 first->prev->next = last->next;
200 last->next->prev = first->prev;
201
202 head->prev->next = first;
203 first->prev = head->prev;
204
205 last->next = head;
206 head->prev = last;
207}
208
209/**
187 * list_is_last - tests whether @list is the last entry in list @head 210 * list_is_last - tests whether @list is the last entry in list @head
188 * @list: the entry to test 211 * @list: the entry to test
189 * @head: the head of the list 212 * @head: the head of the list