]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/add-hlist_add_tail_rcu-merge-git-git.kernel.org-pub-scm-linux-kernel-git-davem-net.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / add-hlist_add_tail_rcu-merge-git-git.kernel.org-pub-scm-linux-kernel-git-davem-net.patch
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)
5
6 From: David S. Miller <davem@davemloft.net>
7
8 commit 1602f49b58abcb0d34a5f0a29d68e7c1769547aa upstream.
9
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
12 - gregkh]
13
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16
17 ---
18 include/linux/rculist.h | 36 ++++++++++++++++++++++++++++++++++++
19 1 file changed, 36 insertions(+)
20
21 --- a/include/linux/rculist.h
22 +++ b/include/linux/rculist.h
23 @@ -402,6 +402,42 @@ static inline void hlist_add_head_rcu(st
24 }
25
26 /**
27 + * hlist_add_tail_rcu
28 + * @n: the element to add to the hash list.
29 + * @h: the list to add to.
30 + *
31 + * Description:
32 + * Adds the specified element to the specified hlist,
33 + * while permitting racing traversals.
34 + *
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().
44 + */
45 +static inline void hlist_add_tail_rcu(struct hlist_node *n,
46 + struct hlist_head *h)
47 +{
48 + struct hlist_node *i, *last = NULL;
49 +
50 + for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i))
51 + last = i;
52 +
53 + if (last) {
54 + n->next = last->next;
55 + n->pprev = &last->next;
56 + rcu_assign_pointer(hlist_next_rcu(last), n);
57 + } else {
58 + hlist_add_head_rcu(n, h);
59 + }
60 +}
61 +
62 +/**
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.