list.h: drop prefetch()

Around the same time as the initial import of list.h, Linus removed
all the prefetch() stuff from the kernel's list.h (75d65a425c01 and
e66eed651fd1, with a followup later in c0d15cc7ee8c).

Make our list.h a little easier to read and a little closer to
upstream's version by removing the stubbed-out prefetching.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
This commit is contained in:
Rasmus Villemoes 2020-11-24 10:41:14 +01:00
parent 207ce8df40
commit 5dc2e2220c

34
list.h
View File

@ -13,7 +13,6 @@
#define LIST_POISON1 ((void *) 0x00100100) #define LIST_POISON1 ((void *) 0x00100100)
#define LIST_POISON2 ((void *) 0x00200200) #define LIST_POISON2 ((void *) 0x00200200)
static inline void prefetch(const void *x) {;}
struct list_head { struct list_head {
struct list_head *next, *prev; struct list_head *next, *prev;
@ -275,29 +274,16 @@ static inline void list_splice_init(struct list_head *list,
* @head: the head for your list. * @head: the head for your list.
*/ */
#define list_for_each(pos, head) \ #define list_for_each(pos, head) \
for (pos = (head)->next; prefetch(pos->next), pos != (head); \ for (pos = (head)->next; pos != (head); \
pos = pos->next) pos = pos->next)
/**
* __list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list.
*
* This variant differs from list_for_each() in that it's the
* simplest possible list iteration code, no prefetching is done.
* Use this for code that knows the list to be very short (empty
* or 1 entry) most of the time.
*/
#define __list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
/** /**
* list_for_each_prev - iterate over a list backwards * list_for_each_prev - iterate over a list backwards
* @pos: the &struct list_head to use as a loop cursor. * @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list. * @head: the head for your list.
*/ */
#define list_for_each_prev(pos, head) \ #define list_for_each_prev(pos, head) \
for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ for (pos = (head)->prev; pos != (head); \
pos = pos->prev) pos = pos->prev)
/** /**
@ -318,7 +304,7 @@ static inline void list_splice_init(struct list_head *list,
*/ */
#define list_for_each_entry(pos, head, member) \ #define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \ for (pos = list_entry((head)->next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \ &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member)) pos = list_entry(pos->member.next, typeof(*pos), member))
/** /**
@ -329,7 +315,7 @@ static inline void list_splice_init(struct list_head *list,
*/ */
#define list_for_each_entry_reverse(pos, head, member) \ #define list_for_each_entry_reverse(pos, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member); \ for (pos = list_entry((head)->prev, typeof(*pos), member); \
prefetch(pos->member.prev), &pos->member != (head); \ &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member)) pos = list_entry(pos->member.prev, typeof(*pos), member))
/** /**
@ -354,7 +340,7 @@ static inline void list_splice_init(struct list_head *list,
*/ */
#define list_for_each_entry_continue(pos, head, member) \ #define list_for_each_entry_continue(pos, head, member) \
for (pos = list_entry(pos->member.next, typeof(*pos), member); \ for (pos = list_entry(pos->member.next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \ &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member)) pos = list_entry(pos->member.next, typeof(*pos), member))
/** /**
@ -366,7 +352,7 @@ static inline void list_splice_init(struct list_head *list,
* Iterate over list of given type, continuing from current position. * Iterate over list of given type, continuing from current position.
*/ */
#define list_for_each_entry_from(pos, head, member) \ #define list_for_each_entry_from(pos, head, member) \
for (; prefetch(pos->member.next), &pos->member != (head); \ for (; &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member)) pos = list_entry(pos->member.next, typeof(*pos), member))
/** /**
@ -545,7 +531,7 @@ static inline void hlist_add_after(struct hlist_node *n,
#define hlist_entry(ptr, type, member) container_of(ptr,type,member) #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
#define hlist_for_each(pos, head) \ #define hlist_for_each(pos, head) \
for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ for (pos = (head)->first; pos; \
pos = pos->next) pos = pos->next)
#define hlist_for_each_safe(pos, n, head) \ #define hlist_for_each_safe(pos, n, head) \
@ -561,7 +547,7 @@ static inline void hlist_add_after(struct hlist_node *n,
*/ */
#define hlist_for_each_entry(tpos, pos, head, member) \ #define hlist_for_each_entry(tpos, pos, head, member) \
for (pos = (head)->first; \ for (pos = (head)->first; \
pos && ({ prefetch(pos->next); 1;}) && \ pos && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next) pos = pos->next)
@ -573,7 +559,7 @@ static inline void hlist_add_after(struct hlist_node *n,
*/ */
#define hlist_for_each_entry_continue(tpos, pos, member) \ #define hlist_for_each_entry_continue(tpos, pos, member) \
for (pos = (pos)->next; \ for (pos = (pos)->next; \
pos && ({ prefetch(pos->next); 1;}) && \ pos && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next) pos = pos->next)
@ -584,7 +570,7 @@ static inline void hlist_add_after(struct hlist_node *n,
* @member: the name of the hlist_node within the struct. * @member: the name of the hlist_node within the struct.
*/ */
#define hlist_for_each_entry_from(tpos, pos, member) \ #define hlist_for_each_entry_from(tpos, pos, member) \
for (; pos && ({ prefetch(pos->next); 1;}) && \ for (; pos && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next) pos = pos->next)