All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] adding into middle of RCU list
@ 2013-08-23  4:33 Stephen Hemminger
  0 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2013-08-23  4:33 UTC (permalink / raw)
  To: Paul E. McKenney, Mathieu Desnoyers, lttng-dev

I needed to add into the middle of an RCU list, does this make sense.



From a45892b0d49ac5fe449ba7e19c646cb17f7cee57 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu, 22 Aug 2013 21:27:04 -0700
Subject: [PATCH] Add list_splice_init_rcu to allow insertion into a RCU list

Simplified version of the version in kernel.
---
 urcu/rculist.h |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/urcu/rculist.h b/urcu/rculist.h
index 1fd2df3..2e8a5a0 100644
--- a/urcu/rculist.h
+++ b/urcu/rculist.h
@@ -72,6 +72,38 @@ void cds_list_del_rcu(struct cds_list_head *elem)
 	CMM_STORE_SHARED(elem->prev->next, elem->next);
 }
 
+
+/**
+ * Splice an RCU-protected list into an existing list.
+ *
+ * Note that this function blocks in synchronize_rcu()
+ *
+ * Important note: this function is not called concurrently
+ *       with other updates to the list.
+ */
+static inline void caa_list_splice_init_rcu(struct cds_list_head *list,
+					    struct cds_list_head *head)
+{
+	struct cds_list_head *first = list->next;
+	struct cds_list_head *last = list->prev;
+	struct cds_list_head *at = head->next;
+
+	if (cds_list_empty(list))
+		return;
+
+	/* "first" and "last" tracking list, so initialize it. */
+	CDS_INIT_LIST_HEAD(list);
+
+	/* Wait for any readers to finish using the list before splicing */
+	synchronize_rcu();
+
+	/* Readers are finished with the source list, so perform splice. */
+	last->next = at;
+	rcu_assign_pointer(head->next, first);
+	first->prev = head;
+	at->prev = last;
+}
+
 /*
  * Iteration through all elements of the list must be done while rcu_read_lock()
  * is held.
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-09-02  2:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20130822213318.49a57fa2@nehalam.linuxnetplumber.net>
2013-08-23 15:07 ` [RFC] adding into middle of RCU list Mathieu Desnoyers
2013-08-23 16:46 ` Paul E. McKenney
     [not found] ` <20130823164637.GB3871@linux.vnet.ibm.com>
2013-08-23 17:16   ` Mathieu Desnoyers
     [not found]   ` <20130823171653.GA16558@Krystal>
2013-08-23 19:09     ` Stephen Hemminger
     [not found]     ` <20130823120956.58ee74e3@nehalam.linuxnetplumber.net>
2013-08-23 21:05       ` Paul E. McKenney
     [not found]       ` <20130823210551.GC3871@linux.vnet.ibm.com>
2013-08-23 21:14         ` Stephen Hemminger
2013-08-23 21:08     ` Paul E. McKenney
     [not found]     ` <20130823210822.GD3871@linux.vnet.ibm.com>
2013-08-30  0:57       ` Paul E. McKenney
2013-08-30  2:16         ` Josh Triplett
2013-08-30  2:16         ` Josh Triplett
2013-08-31 21:32           ` Paul E. McKenney
2013-09-01 20:42             ` Josh Triplett
2013-09-01 22:26               ` Paul E. McKenney
2013-09-01 22:43                 ` Josh Triplett
2013-09-01 23:42                   ` [PATCH] rcu: Make rcu_assign_pointer's assignment volatile and type-safe Josh Triplett
2013-09-02  2:01                     ` Paul E. McKenney
2013-08-23  4:33 [RFC] adding into middle of RCU list Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.