summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHuang Ying <ying.huang@intel.com>2011-09-08 08:00:44 +0200
committerIngo Molnar <mingo@elte.hu>2011-10-04 12:43:39 +0200
commita3127336b71f6833d1483c856dce91fe558dc3a9 (patch)
treec025279c450994f25661c2ab004f0be98997cf8a /include
parentllist: Remove the platform-dependent NMI checks (diff)
downloadlinux-a3127336b71f6833d1483c856dce91fe558dc3a9.tar.xz
linux-a3127336b71f6833d1483c856dce91fe558dc3a9.zip
llist: Move cpu_relax() to after the cmpxchg()
If in llist_add()/etc. functions the first cmpxchg() call succeeds, it is not necessary to use cpu_relax() before the cmpxchg(). So cpu_relax() in a busy loop involving cmpxchg() should go after cmpxchg() instead of before that. This patch fixes this for all involved llist functions. Signed-off-by: Huang Ying <ying.huang@intel.com> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1315461646-1379-4-git-send-email-ying.huang@intel.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include')
-rw-r--r--include/linux/llist.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/llist.h b/include/linux/llist.h
index 65fca1cbf514..ca91875286bf 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -148,11 +148,14 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head)
struct llist_node *entry, *old_entry;
entry = head->first;
- do {
+ for (;;) {
old_entry = entry;
new->next = entry;
+ entry = cmpxchg(&head->first, old_entry, new);
+ if (entry == old_entry)
+ break;
cpu_relax();
- } while ((entry = cmpxchg(&head->first, old_entry, new)) != old_entry);
+ }
}
/**