aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2005-12-12 03:37:11 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-12-12 11:57:43 -0500
commitb88cb42428f14fabdaf947150c00d65891820635 (patch)
tree21546720b90d1263f2e61760eb515c00f350ee12 /include/linux
parent5650b736ad328f7f3e4120e8790940289b8ac144 (diff)
[PATCH] add hlist_replace_rcu()
Add list_replace_rcu: replace old entry by new one. Signed-off-by: Paul E. McKenney <paulmck@us.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/list.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index fbfca73355a3..8e3388284530 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -202,12 +202,15 @@ static inline void list_del_rcu(struct list_head *entry)
202 * 202 *
203 * The old entry will be replaced with the new entry atomically. 203 * The old entry will be replaced with the new entry atomically.
204 */ 204 */
205static inline void list_replace_rcu(struct list_head *old, struct list_head *new){ 205static inline void list_replace_rcu(struct list_head *old,
206 struct list_head *new)
207{
206 new->next = old->next; 208 new->next = old->next;
207 new->prev = old->prev; 209 new->prev = old->prev;
208 smp_wmb(); 210 smp_wmb();
209 new->next->prev = new; 211 new->next->prev = new;
210 new->prev->next = new; 212 new->prev->next = new;
213 old->prev = LIST_POISON2;
211} 214}
212 215
213/** 216/**
@@ -578,6 +581,27 @@ static inline void hlist_del_init(struct hlist_node *n)
578 } 581 }
579} 582}
580 583
584/*
585 * hlist_replace_rcu - replace old entry by new one
586 * @old : the element to be replaced
587 * @new : the new element to insert
588 *
589 * The old entry will be replaced with the new entry atomically.
590 */
591static inline void hlist_replace_rcu(struct hlist_node *old,
592 struct hlist_node *new)
593{
594 struct hlist_node *next = old->next;
595
596 new->next = next;
597 new->pprev = old->pprev;
598 smp_wmb();
599 if (next)
600 new->next->pprev = &new->next;
601 *new->pprev = new;
602 old->pprev = LIST_POISON2;
603}
604
581static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) 605static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
582{ 606{
583 struct hlist_node *first = h->first; 607 struct hlist_node *first = h->first;