aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-19 17:15:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-19 17:15:29 -0400
commite66eed651fd18a961f11cda62f3b5286c8cc4f9f (patch)
tree0b86980050e63623b103f1b6378aa3c457f63e87
parent75d65a425c0163d3ec476ddc12b51087217a070c (diff)
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: Ingo Molnar <mingo@elte.hu> Acked-by: David S. Miller <davem@davemloft.net> Cc: linux-arch@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/list.h26
-rw-r--r--include/linux/rculist.h6
2 files changed, 14 insertions, 18 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 9ac11148e037..cc6d2aa6b415 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -4,7 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/stddef.h> 5#include <linux/stddef.h>
6#include <linux/poison.h> 6#include <linux/poison.h>
7#include <linux/prefetch.h> 7#include <linux/const.h>
8 8
9/* 9/*
10 * Simple doubly linked list implementation. 10 * Simple doubly linked list implementation.
@@ -367,18 +367,15 @@ static inline void list_splice_tail_init(struct list_head *list,
367 * @head: the head for your list. 367 * @head: the head for your list.
368 */ 368 */
369#define list_for_each(pos, head) \ 369#define list_for_each(pos, head) \
370 for (pos = (head)->next; prefetch(pos->next), pos != (head); \ 370 for (pos = (head)->next; pos != (head); pos = pos->next)
371 pos = pos->next)
372 371
373/** 372/**
374 * __list_for_each - iterate over a list 373 * __list_for_each - iterate over a list
375 * @pos: the &struct list_head to use as a loop cursor. 374 * @pos: the &struct list_head to use as a loop cursor.
376 * @head: the head for your list. 375 * @head: the head for your list.
377 * 376 *
378 * This variant differs from list_for_each() in that it's the 377 * This variant doesn't differ from list_for_each() any more.
379 * simplest possible list iteration code, no prefetching is done. 378 * We don't do prefetching in either case.
380 * Use this for code that knows the list to be very short (empty
381 * or 1 entry) most of the time.
382 */ 379 */
383#define __list_for_each(pos, head) \ 380#define __list_for_each(pos, head) \
384 for (pos = (head)->next; pos != (head); pos = pos->next) 381 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 * @head: the head for your list. 386 * @head: the head for your list.
390 */ 387 */
391#define list_for_each_prev(pos, head) \ 388#define list_for_each_prev(pos, head) \
392 for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ 389 for (pos = (head)->prev; pos != (head); pos = pos->prev)
393 pos = pos->prev)
394 390
395/** 391/**
396 * list_for_each_safe - iterate over a list safe against removal of list entry 392 * 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 */ 406 */
411#define list_for_each_prev_safe(pos, n, head) \ 407#define list_for_each_prev_safe(pos, n, head) \
412 for (pos = (head)->prev, n = pos->prev; \ 408 for (pos = (head)->prev, n = pos->prev; \
413 prefetch(pos->prev), pos != (head); \ 409 pos != (head); \
414 pos = n, n = pos->prev) 410 pos = n, n = pos->prev)
415 411
416/** 412/**
@@ -421,7 +417,7 @@ static inline void list_splice_tail_init(struct list_head *list,
421 */ 417 */
422#define list_for_each_entry(pos, head, member) \ 418#define list_for_each_entry(pos, head, member) \
423 for (pos = list_entry((head)->next, typeof(*pos), member); \ 419 for (pos = list_entry((head)->next, typeof(*pos), member); \
424 prefetch(pos->member.next), &pos->member != (head); \ 420 &pos->member != (head); \
425 pos = list_entry(pos->member.next, typeof(*pos), member)) 421 pos = list_entry(pos->member.next, typeof(*pos), member))
426 422
427/** 423/**
@@ -432,7 +428,7 @@ static inline void list_splice_tail_init(struct list_head *list,
432 */ 428 */
433#define list_for_each_entry_reverse(pos, head, member) \ 429#define list_for_each_entry_reverse(pos, head, member) \
434 for (pos = list_entry((head)->prev, typeof(*pos), member); \ 430 for (pos = list_entry((head)->prev, typeof(*pos), member); \
435 prefetch(pos->member.prev), &pos->member != (head); \ 431 &pos->member != (head); \
436 pos = list_entry(pos->member.prev, typeof(*pos), member)) 432 pos = list_entry(pos->member.prev, typeof(*pos), member))
437 433
438/** 434/**
@@ -457,7 +453,7 @@ static inline void list_splice_tail_init(struct list_head *list,
457 */ 453 */
458#define list_for_each_entry_continue(pos, head, member) \ 454#define list_for_each_entry_continue(pos, head, member) \
459 for (pos = list_entry(pos->member.next, typeof(*pos), member); \ 455 for (pos = list_entry(pos->member.next, typeof(*pos), member); \
460 prefetch(pos->member.next), &pos->member != (head); \ 456 &pos->member != (head); \
461 pos = list_entry(pos->member.next, typeof(*pos), member)) 457 pos = list_entry(pos->member.next, typeof(*pos), member))
462 458
463/** 459/**
@@ -471,7 +467,7 @@ static inline void list_splice_tail_init(struct list_head *list,
471 */ 467 */
472#define list_for_each_entry_continue_reverse(pos, head, member) \ 468#define list_for_each_entry_continue_reverse(pos, head, member) \
473 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ 469 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
474 prefetch(pos->member.prev), &pos->member != (head); \ 470 &pos->member != (head); \
475 pos = list_entry(pos->member.prev, typeof(*pos), member)) 471 pos = list_entry(pos->member.prev, typeof(*pos), member))
476 472
477/** 473/**
@@ -483,7 +479,7 @@ static inline void list_splice_tail_init(struct list_head *list,
483 * Iterate over list of given type, continuing from current position. 479 * Iterate over list of given type, continuing from current position.
484 */ 480 */
485#define list_for_each_entry_from(pos, head, member) \ 481#define list_for_each_entry_from(pos, head, member) \
486 for (; prefetch(pos->member.next), &pos->member != (head); \ 482 for (; &pos->member != (head); \
487 pos = list_entry(pos->member.next, typeof(*pos), member)) 483 pos = list_entry(pos->member.next, typeof(*pos), member))
488 484
489/** 485/**
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 900a97a44769..e3beb315517a 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -253,7 +253,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
253 */ 253 */
254#define list_for_each_entry_rcu(pos, head, member) \ 254#define list_for_each_entry_rcu(pos, head, member) \
255 for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ 255 for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \
256 prefetch(pos->member.next), &pos->member != (head); \ 256 &pos->member != (head); \
257 pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) 257 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
258 258
259 259
@@ -270,7 +270,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
270 */ 270 */
271#define list_for_each_continue_rcu(pos, head) \ 271#define list_for_each_continue_rcu(pos, head) \
272 for ((pos) = rcu_dereference_raw(list_next_rcu(pos)); \ 272 for ((pos) = rcu_dereference_raw(list_next_rcu(pos)); \
273 prefetch((pos)->next), (pos) != (head); \ 273 (pos) != (head); \
274 (pos) = rcu_dereference_raw(list_next_rcu(pos))) 274 (pos) = rcu_dereference_raw(list_next_rcu(pos)))
275 275
276/** 276/**
@@ -284,7 +284,7 @@ static inline void list_splice_init_rcu(struct list_head *list,
284 */ 284 */
285#define list_for_each_entry_continue_rcu(pos, head, member) \ 285#define list_for_each_entry_continue_rcu(pos, head, member) \
286 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \ 286 for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
287 prefetch(pos->member.next), &pos->member != (head); \ 287 &pos->member != (head); \
288 pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) 288 pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
289 289
290/** 290/**