From 1746056588ce2c701fae30208669b00e55f0c0ed Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Sat, 10 Feb 2007 01:45:42 -0800 Subject: [PATCH] --- yaml --- r: 47567 b: refs/heads/master c: 3678d62f028689abc8ac5693b254e48f605f94ba h: refs/heads/master i: 47565: 05cbc2e19fa5357bb5bef76bbf0368077061f2b3 47563: 551e22f0c990995f2c2dfbc29eac149a06201b67 47559: 2b3e95bd3a7f3da45e7527dd599cf374f66f17a2 47551: 53949988fb2770e25d15e8962e5aa8709a3181e5 v: v3 --- [refs] | 2 +- trunk/include/linux/list.h | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 9f7af6092535..929fb838d70f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 16cf5b39b81b95d1e3d81df3ba8c82cadf54f551 +refs/heads/master: 3678d62f028689abc8ac5693b254e48f605f94ba diff --git a/trunk/include/linux/list.h b/trunk/include/linux/list.h index 611059d633f4..cdc96559e5ae 100644 --- a/trunk/include/linux/list.h +++ b/trunk/include/linux/list.h @@ -359,6 +359,62 @@ static inline void list_splice_init(struct list_head *list, } } +/** + * list_splice_init_rcu - splice an RCU-protected list into an existing list. + * @list: the RCU-protected list to splice + * @head: the place in the list to splice the first list into + * @sync: function to sync: synchronize_rcu(), synchronize_sched(), ... + * + * @head can be RCU-read traversed concurrently with this function. + * + * Note that this function blocks. + * + * Important note: the caller must take whatever action is necessary to + * prevent any other updates to @head. In principle, it is possible + * to modify the list as soon as sync() begins execution. + * If this sort of thing becomes necessary, an alternative version + * based on call_rcu() could be created. But only if -really- + * needed -- there is no shortage of RCU API members. + */ +static inline void list_splice_init_rcu(struct list_head *list, + struct list_head *head, + void (*sync)(void)) +{ + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->next; + + if (list_empty(head)) + return; + + /* "first" and "last" tracking list, so initialize it. */ + + INIT_LIST_HEAD(list); + + /* + * At this point, the list body still points to the source list. + * Wait for any readers to finish using the list before splicing + * the list body into the new list. Any new readers will see + * an empty list. + */ + + sync(); + + /* + * Readers are finished with the source list, so perform splice. + * The order is important if the new list is global and accessible + * to concurrent RCU readers. Note that RCU readers are not + * permitted to traverse the prev pointers without excluding + * this function. + */ + + last->next = at; + smp_wmb(); + head->next = first; + first->prev = head; + at->prev = last; +} + /** * list_entry - get the struct for this entry * @ptr: the &struct list_head pointer.