Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Docs/RCU/rculist_nulls: Fix hlist_[nulls]_head field names of 'obj'

The example code snippets on rculist_nulls.rst are assuming 'obj' to
have the 'hlist_head' or 'hlist_nulls_head' field named 'obj_node', but
a sentence and some code snippets are wrongly calling
'obj->obj_node.next' as 'obj->obj_next', or 'obj->obj_node' as 'member'.
Fix it.

Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

authored by

SeongJae Park and committed by
Paul E. McKenney
d186204a 5326caa7

+4 -4
+4 -4
Documentation/RCU/rculist_nulls.rst
··· 65 65 struct hlist_node *node, *next; 66 66 for (pos = rcu_dereference((head)->first); 67 67 pos && ({ next = pos->next; smp_rmb(); prefetch(next); 1; }) && 68 - ({ obj = hlist_entry(pos, typeof(*obj), member); 1; }); 68 + ({ obj = hlist_entry(pos, typeof(*obj), obj_node); 1; }); 69 69 pos = rcu_dereference(next)) 70 70 if (obj->key == key) 71 71 return obj; ··· 77 77 struct hlist_node *node; 78 78 for (pos = rcu_dereference((head)->first); 79 79 pos && ({ prefetch(pos->next); 1; }) && 80 - ({ obj = hlist_entry(pos, typeof(*obj), member); 1; }); 80 + ({ obj = hlist_entry(pos, typeof(*obj), obj_node); 1; }); 81 81 pos = rcu_dereference(pos->next)) 82 82 if (obj->key == key) 83 83 return obj; ··· 97 97 2) Insertion algorithm 98 98 ---------------------- 99 99 100 - We need to make sure a reader cannot read the new 'obj->obj_next' value 100 + We need to make sure a reader cannot read the new 'obj->obj_node.next' value 101 101 and previous value of 'obj->key'. Otherwise, an item could be deleted 102 102 from a chain, and inserted into another chain. If new chain was empty 103 103 before the move, 'next' pointer is NULL, and lockless reader can not ··· 165 165 head = &table[slot]; 166 166 begin: 167 167 rcu_read_lock(); 168 - hlist_nulls_for_each_entry_rcu(obj, node, head, member) { 168 + hlist_nulls_for_each_entry_rcu(obj, node, head, obj_node) { 169 169 if (obj->key == key) { 170 170 if (!try_get_ref(obj)) { // might fail for free objects 171 171 rcu_read_unlock();