1 From 1602f49b58abcb0d34a5f0a29d68e7c1769547aa Mon Sep 17 00:00:00 2001
2 From: "David S. Miller" <davem@davemloft.net>
3 Date: Sat, 23 Apr 2016 18:26:24 -0400
4 Subject: Add hlist_add_tail_rcu() (Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net)
6 From: David S. Miller <davem@davemloft.net>
8 commit 1602f49b58abcb0d34a5f0a29d68e7c1769547aa upstream.
10 [This commit was a merge, but it added hlist_add_tail_rcu(), which is what we
11 need in this stable tree, so I've changed the subject to be more descriptive
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 include/linux/rculist.h | 36 ++++++++++++++++++++++++++++++++++++
19 1 file changed, 36 insertions(+)
21 --- a/include/linux/rculist.h
22 +++ b/include/linux/rculist.h
23 @@ -405,6 +405,42 @@ static inline void hlist_add_head_rcu(st
27 + * hlist_add_tail_rcu
28 + * @n: the element to add to the hash list.
29 + * @h: the list to add to.
32 + * Adds the specified element to the specified hlist,
33 + * while permitting racing traversals.
35 + * The caller must take whatever precautions are necessary
36 + * (such as holding appropriate locks) to avoid racing
37 + * with another list-mutation primitive, such as hlist_add_head_rcu()
38 + * or hlist_del_rcu(), running on this same list.
39 + * However, it is perfectly legal to run concurrently with
40 + * the _rcu list-traversal primitives, such as
41 + * hlist_for_each_entry_rcu(), used to prevent memory-consistency
42 + * problems on Alpha CPUs. Regardless of the type of CPU, the
43 + * list-traversal primitive must be guarded by rcu_read_lock().
45 +static inline void hlist_add_tail_rcu(struct hlist_node *n,
46 + struct hlist_head *h)
48 + struct hlist_node *i, *last = NULL;
50 + for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i))
54 + n->next = last->next;
55 + n->pprev = &last->next;
56 + rcu_assign_pointer(hlist_next_rcu(last), n);
58 + hlist_add_head_rcu(n, h);
63 * hlist_add_before_rcu
64 * @n: the new element to add to the hash list.
65 * @next: the existing element to add the new element before.