Commit e66eed65 authored by Linus Torvalds's avatar Linus Torvalds

list: remove prefetching from regular list iterators

This is removes the use of software prefetching from the regular list
iterators.  We don't want it.  If you do want to prefetch in some
iterator of yours, go right ahead.  Just don't expect the iterator to do
it, since normally the downsides are bigger than the upsides.

It also replaces <linux/prefetch.h> with <linux/const.h>, because the
use of LIST_POISON ends up needing it.  <linux/poison.h> is sadly not
self-contained, and including prefetch.h just happened to hide that.

Suggested by David Miller (networking has a lot of regular lists that
are often empty or a single entry, and prefetching is not going to do
anything but add useless instructions).
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: linux-arch@vger.kernel.org
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 75d65a42
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/poison.h> #include <linux/poison.h>
#include <linux/prefetch.h> #include <linux/const.h>
/* /*
* Simple doubly linked list implementation. * Simple doubly linked list implementation.
...@@ -367,18 +367,15 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -367,18 +367,15 @@ static inline void list_splice_tail_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 * __list_for_each - iterate over a list
* @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.
* *
* This variant differs from list_for_each() in that it's the * This variant doesn't differ from list_for_each() any more.
* simplest possible list iteration code, no prefetching is done. * We don't do prefetching in either case.
* 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) \ #define __list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next) for (pos = (head)->next; pos != (head); pos = pos->next)
...@@ -389,8 +386,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -389,8 +386,7 @@ static inline void list_splice_tail_init(struct list_head *list,
* @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)
/** /**
* list_for_each_safe - iterate over a list safe against removal of list entry * list_for_each_safe - iterate over a list safe against removal of list entry
...@@ -410,7 +406,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -410,7 +406,7 @@ static inline void list_splice_tail_init(struct list_head *list,
*/ */
#define list_for_each_prev_safe(pos, n, head) \ #define list_for_each_prev_safe(pos, n, head) \
for (pos = (head)->prev, n = pos->prev; \ for (pos = (head)->prev, n = pos->prev; \
prefetch(pos->prev), pos != (head); \ pos != (head); \
pos = n, n = pos->prev) pos = n, n = pos->prev)
/** /**
...@@ -421,7 +417,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -421,7 +417,7 @@ static inline void list_splice_tail_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))
/** /**
...@@ -432,7 +428,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -432,7 +428,7 @@ static inline void list_splice_tail_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))
/** /**
...@@ -457,7 +453,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -457,7 +453,7 @@ static inline void list_splice_tail_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))
/** /**
...@@ -471,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -471,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head *list,
*/ */
#define list_for_each_entry_continue_reverse(pos, head, member) \ #define list_for_each_entry_continue_reverse(pos, head, member) \
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ for (pos = list_entry(pos->member.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))
/** /**
...@@ -483,7 +479,7 @@ static inline void list_splice_tail_init(struct list_head *list, ...@@ -483,7 +479,7 @@ static inline void list_splice_tail_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))
/** /**
......
...@@ -253,7 +253,7 @@ static inline void list_splice_init_rcu(struct list_head *list, ...@@ -253,7 +253,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
*/ */
#define list_for_each_entry_rcu(pos, head, member) \ #define list_for_each_entry_rcu(pos, head, member) \
for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \ &pos->member != (head); \
pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
...@@ -270,7 +270,7 @@ static inline void list_splice_init_rcu(struct list_head *list, ...@@ -270,7 +270,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
*/ */
#define list_for_each_continue_rcu(pos, head) \ #define list_for_each_continue_rcu(pos, head) \
for ((pos) = rcu_dereference_raw(list_next_rcu(pos)); \ for ((pos) = rcu_dereference_raw(list_next_rcu(pos)); \
prefetch((pos)->next), (pos) != (head); \ (pos) != (head); \
(pos) = rcu_dereference_raw(list_next_rcu(pos))) (pos) = rcu_dereference_raw(list_next_rcu(pos)))
/** /**
...@@ -284,7 +284,7 @@ static inline void list_splice_init_rcu(struct list_head *list, ...@@ -284,7 +284,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
*/ */
#define list_for_each_entry_continue_rcu(pos, head, member) \ #define list_for_each_entry_continue_rcu(pos, head, member) \
for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \ for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \ &pos->member != (head); \
pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment