Commit 6beeac76f5f96590fb751af5e138fbc3f62e8460

Authored by Andrea Arcangeli
Committed by Linus Torvalds
1 parent 93686ae835

mmu-notifiers: add list_del_init_rcu()

Introduce list_del_init_rcu() and document it.

Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Jack Steiner <steiner@sgi.com>
Cc: Robin Holt <holt@sgi.com>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Kanoj Sarcar <kanojsarcar@yahoo.com>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Steve Wise <swise@opengridcomputing.com>
Cc: Avi Kivity <avi@qumranet.com>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Chris Wright <chrisw@redhat.com>
Cc: Marcelo Tosatti <marcelo@kvack.org>
Cc: Eric Dumazet <dada1@cosmosbay.com>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: Izik Eidus <izike@qumranet.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 28 additions and 0 deletions Side-by-side Diff

include/linux/rculist.h
... ... @@ -98,6 +98,34 @@
98 98 }
99 99  
100 100 /**
  101 + * hlist_del_init_rcu - deletes entry from hash list with re-initialization
  102 + * @n: the element to delete from the hash list.
  103 + *
  104 + * Note: list_unhashed() on the node return true after this. It is
  105 + * useful for RCU based read lockfree traversal if the writer side
  106 + * must know if the list entry is still hashed or already unhashed.
  107 + *
  108 + * In particular, it means that we can not poison the forward pointers
  109 + * that may still be used for walking the hash list and we can only
  110 + * zero the pprev pointer so list_unhashed() will return true after
  111 + * this.
  112 + *
  113 + * The caller must take whatever precautions are necessary (such as
  114 + * holding appropriate locks) to avoid racing with another
  115 + * list-mutation primitive, such as hlist_add_head_rcu() or
  116 + * hlist_del_rcu(), running on this same list. However, it is
  117 + * perfectly legal to run concurrently with the _rcu list-traversal
  118 + * primitives, such as hlist_for_each_entry_rcu().
  119 + */
  120 +static inline void hlist_del_init_rcu(struct hlist_node *n)
  121 +{
  122 + if (!hlist_unhashed(n)) {
  123 + __hlist_del(n);
  124 + n->pprev = NULL;
  125 + }
  126 +}
  127 +
  128 +/**
101 129 * list_replace_rcu - replace old entry by new one
102 130 * @old : the element to be replaced
103 131 * @new : the new element to insert