Commit ce0a1db3 authored by KaiGai Kohei's avatar KaiGai Kohei Committed by Linus Torvalds

[PATCH] list_replace_rcu() in include/linux/list.h

This attached patch adds list_replace_rcu() to include/linux/list.h for
atomic updating operations according to RCU-model.

void list_replace_rcu(struct list_head *old, struct list_head *new)

The 'old' element is detached from the linked list, and the 'new' element
is inserted to the same point of the linked list concurrently.

This patch is necessary for the performance improvement of SELinux.
See, http://lkml.org/lkml/2004/8/16/54
       (Subject: RCU issue with SELinux)
     http://lkml.org/lkml/2004/8/30/63
       (Subject: [PATCH]SELinux performance improvement by RCU)
Signed-off-by: default avatarKaiGai, Kohei <kaigai@ak.jp.nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1a5ad5dd
......@@ -195,6 +195,21 @@ static inline void list_del_rcu(struct list_head *entry)
entry->prev = LIST_POISON2;
}
/*
* list_replace_rcu - replace old entry by new one
* @old : the element to be replaced
* @new : the new element to insert
*
* The old entry will be replaced with the new entry atomically.
*/
static inline void list_replace_rcu(struct list_head *old, struct list_head *new){
new->next = old->next;
new->prev = old->prev;
smp_wmb();
new->next->prev = new;
new->prev->next = new;
}
/**
* list_del_init - deletes entry from list and reinitialize it.
* @entry: the element to delete from the list.
......
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