aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/RCU/rcuref.txt
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2008-10-22 23:57:26 -0400
committerLen Brown <len.brown@intel.com>2008-10-23 00:11:07 -0400
commit057316cc6a5b521b332a1d7ccc871cd60c904c74 (patch)
tree4333e608da237c73ff69b10878025cca96dcb4c8 /Documentation/RCU/rcuref.txt
parent3e2dab9a1c2deb03c311eb3f83466009147ed4d3 (diff)
parent2515ddc6db8eb49a79f0fe5e67ff09ac7c81eab4 (diff)
Merge branch 'linus' into test
Conflicts: MAINTAINERS arch/x86/kernel/acpi/boot.c arch/x86/kernel/acpi/sleep.c drivers/acpi/Kconfig drivers/pnp/Makefile drivers/pnp/quirks.c Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'Documentation/RCU/rcuref.txt')
-rw-r--r--Documentation/RCU/rcuref.txt16
1 files changed, 8 insertions, 8 deletions
diff --git a/Documentation/RCU/rcuref.txt b/Documentation/RCU/rcuref.txt
index 451de2ad8329..4202ad093130 100644
--- a/Documentation/RCU/rcuref.txt
+++ b/Documentation/RCU/rcuref.txt
@@ -29,9 +29,9 @@ release_referenced() delete()
29 } 29 }
30 30
31If this list/array is made lock free using RCU as in changing the 31If this list/array is made lock free using RCU as in changing the
32write_lock() in add() and delete() to spin_lock and changing read_lock 32write_lock() in add() and delete() to spin_lock() and changing read_lock()
33in search_and_reference to rcu_read_lock(), the atomic_get in 33in search_and_reference() to rcu_read_lock(), the atomic_inc() in
34search_and_reference could potentially hold reference to an element which 34search_and_reference() could potentially hold reference to an element which
35has already been deleted from the list/array. Use atomic_inc_not_zero() 35has already been deleted from the list/array. Use atomic_inc_not_zero()
36in this scenario as follows: 36in this scenario as follows:
37 37
@@ -40,20 +40,20 @@ add() search_and_reference()
40{ { 40{ {
41 alloc_object rcu_read_lock(); 41 alloc_object rcu_read_lock();
42 ... search_for_element 42 ... search_for_element
43 atomic_set(&el->rc, 1); if (atomic_inc_not_zero(&el->rc)) { 43 atomic_set(&el->rc, 1); if (!atomic_inc_not_zero(&el->rc)) {
44 write_lock(&list_lock); rcu_read_unlock(); 44 spin_lock(&list_lock); rcu_read_unlock();
45 return FAIL; 45 return FAIL;
46 add_element } 46 add_element }
47 ... ... 47 ... ...
48 write_unlock(&list_lock); rcu_read_unlock(); 48 spin_unlock(&list_lock); rcu_read_unlock();
49} } 49} }
503. 4. 503. 4.
51release_referenced() delete() 51release_referenced() delete()
52{ { 52{ {
53 ... write_lock(&list_lock); 53 ... spin_lock(&list_lock);
54 if (atomic_dec_and_test(&el->rc)) ... 54 if (atomic_dec_and_test(&el->rc)) ...
55 call_rcu(&el->head, el_free); delete_element 55 call_rcu(&el->head, el_free); delete_element
56 ... write_unlock(&list_lock); 56 ... spin_unlock(&list_lock);
57} ... 57} ...
58 if (atomic_dec_and_test(&el->rc)) 58 if (atomic_dec_and_test(&el->rc))
59 call_rcu(&el->head, el_free); 59 call_rcu(&el->head, el_free);