fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/43151?usp=email )
Change subject: linuxlist: drop no-op prefetch() calls ......................................................................
linuxlist: drop no-op prefetch() calls
prefetch() has always been a no-op stub in this header so calling it buys nothing at runtime. Drop all call sites and remove the now-dead stub itself.
The macro was copied over from the Linux kernel, where prefetch() is a real, arch-specific cache prefetch hint; here it never was anything but an empty inline function.
Change-Id: Id84973330df44b4efdd1bd85e4b7c3cb88642f92 Related: OS#7036, OS#6858 --- M include/osmocom/core/linuxlist.h 1 file changed, 16 insertions(+), 29 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/51/43151/1
diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h index e5e5075..94191e6 100644 --- a/include/osmocom/core/linuxlist.h +++ b/include/osmocom/core/linuxlist.h @@ -22,8 +22,6 @@ #define inline __inline__ #endif
-static inline void prefetch(const void *x) {;} - /*! Cast a member of a structure out to the containing structure. * \param[in] ptr the pointer to the member. * \param[in] type the type of the container struct this is embedded in. @@ -283,15 +281,13 @@ * \param head the head of the list over which to iterate. */ #define llist_for_each(pos, head) \ - for (pos = (head)->next, prefetch(pos->next); pos != (head); \ - pos = pos->next, prefetch(pos->next)) + for (pos = (head)->next; pos != (head); pos = pos->next)
-/*! Iterate over a linked list (no prefetch). +/*! Iterate over a linked list. * \param pos the llist_head to use as a loop counter. * \param head the head of the list over which to iterate. * - * This variant differs from llist_for_each() in that it's the - * simplest possible llist iteration code, no prefetching is done. + * Equivalent to llist_for_each(); kept for API compatibility. * Use this for code that knows the llist to be very short (empty * or 1 entry) most of the time. */ @@ -303,8 +299,7 @@ * \param head the head of the list over which to iterate. */ #define llist_for_each_prev(pos, head) \ - for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ - pos = pos->prev, prefetch(pos->prev)) + for (pos = (head)->prev; pos != (head); pos = pos->prev)
/*! Iterate over a linked list, safe against removal of llist entry. * \param pos the llist_head to use as a loop counter. @@ -321,11 +316,9 @@ * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry(pos, head, member) \ - for (pos = llist_entry((head)->next, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->next); \ + for (pos = llist_entry((head)->next, typeof(*pos), member); \ __llist_member(pos, member) != (head); \ - pos = llist_entry(__llist_member(pos, member)->next, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->next)) + pos = llist_entry(__llist_member(pos, member)->next, typeof(*pos), member))
/*! Iterate backwards over a linked list of a given type. * \param pos the 'type *' to use as a loop counter. @@ -333,11 +326,9 @@ * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry_reverse(pos, head, member) \ - for (pos = llist_entry((head)->prev, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->prev); \ + for (pos = llist_entry((head)->prev, typeof(*pos), member); \ __llist_member(pos, member) != (head); \ - pos = llist_entry(__llist_member(pos, member)->prev, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->prev)) + pos = llist_entry(__llist_member(pos, member)->prev, typeof(*pos), member))
/*! Iterate over a linked list of a given type, * continuing after an existing point. @@ -346,11 +337,9 @@ * \param member the name of the llist_head within the struct pos. */ #define llist_for_each_entry_continue(pos, head, member) \ - for (pos = llist_entry(pos->member.next, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->next); \ + for (pos = llist_entry(pos->member.next, typeof(*pos), member); \ __llist_member(pos, member) != (head); \ - pos = llist_entry(__llist_member(pos, member)->next, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->next)) + pos = llist_entry(__llist_member(pos, member)->next, typeof(*pos), member))
/*! Iterate over llist of given type, safe against removal of llist entry. * \param pos the 'type *' to use as a loop counter. @@ -369,8 +358,8 @@ * \param head the head of the list over which to iterate. */ #define llist_for_each_rcu(pos, head) \ - for (pos = (head)->next, prefetch(pos->next); pos != (head); \ - pos = pos->next, ({ smp_read_barrier_depends(); 0;}), prefetch(pos->next)) + for (pos = (head)->next; pos != (head); \ + pos = pos->next, ({ smp_read_barrier_depends(); 0;}))
#define __llist_for_each_rcu(pos, head) \ for (pos = (head)->next; pos != (head); \ @@ -391,12 +380,10 @@ * \param member the name of the llist_struct within the struct. */ #define llist_for_each_entry_rcu(pos, head, member) \ - for (pos = llist_entry((head)->next, typeof(*pos), member), \ - prefetch(__llist_member(pos, member)->next); \ + for (pos = llist_entry((head)->next, typeof(*pos), member); \ __llist_member(pos, member) != (head); \ pos = llist_entry(__llist_member(pos, member)->next, typeof(*pos), member), \ - ({ smp_read_barrier_depends(); 0;}), \ - prefetch(__llist_member(pos, member)->next)) + ({ smp_read_barrier_depends(); 0;}))
/*! Iterate over an rcu-protected llist, continuing after existing point. @@ -404,8 +391,8 @@ * \param head the head of the list over which to iterate. */ #define llist_for_each_continue_rcu(pos, head) \ - for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \ - (pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next)) + for ((pos) = (pos)->next; (pos) != (head); \ + (pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}))
/*! Count number of llist items by iterating. * \param head the llist head to count items of.