Docs/RCU/rculist_nulls: Minor fixups
Subsystems (2)
v2 cover Docs/RCU/rculist_nulls: Minor fixups
Changes from v1
(https://lore.kernel.org/rcu/[email protected]/)
- Add Reviewed-by tags from Joel Fernandes for first three patches
- Fix the text for wrong extra _release()
---
Fix minor problems in example code snippets and the text of rculist_nulls.rst file.
SeongJae Park (4):
Docs/RCU/rculist_nulls: Fix trivial coding style Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj' Docs/RCU/rculist_nulls: Fix wrong text about atomic_set_release()
Documentation/RCU/rculist_nulls.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/4 Docs/RCU/rculist_nulls: Fix trivial coding style
Lookup example of non-hlist_nulls management is missing a semicolon, and having inconsistent indentation (one line is using single space indentation while others are using two spaces indentation). Fix the trivial issues.
--- Documentation/RCU/rculist_nulls.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/RCU/rculist_nulls.rst +3 -3
@@ -26,7 +26,7 @@ algorithms: :: begin: - rcu_read_lock() + rcu_read_lock(); obj = lockless_lookup(key); if (obj) { if (!try_get_ref(obj)) // might fail for free objects
@@ -68,8 +68,8 @@ And note the traditional hlist_for_each_entry_rcu() misses this smp_rmb():: pos && ({ prefetch(pos->next); 1; }) && ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); pos = rcu_dereference(pos->next)) - if (obj->key == key) - return obj; + if (obj->key == key) + return obj; return NULL; Quoting Corey Minyard::
Signature · 1 line
2.25.1
PATCH v2 2/4 Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples
In reply to SeongJae ParkLookup example code snippets in rculist_nulls.rst are using 'obj' without assignment. Fix the code to assign it properly.
--- Documentation/RCU/rculist_nulls.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/RCU/rculist_nulls.rst +2 -2
@@ -54,7 +54,7 @@ but a version with an additional memory barrier (smp_rmb()) struct hlist_node *node, *next; for (pos = rcu_dereference((head)->first); pos && ({ next = pos->next; smp_rmb(); prefetch(next); 1; }) && - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); + ({ obj = hlist_entry(pos, typeof(*obj), member); 1; }); pos = rcu_dereference(next)) if (obj->key == key) return obj;
@@ -66,7 +66,7 @@ And note the traditional hlist_for_each_entry_rcu() misses this smp_rmb():: struct hlist_node *node; for (pos = rcu_dereference((head)->first); pos && ({ prefetch(pos->next); 1; }) && - ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); + ({ obj = hlist_entry(pos, typeof(*obj), member); 1; }); pos = rcu_dereference(pos->next)) if (obj->key == key) return obj;
Signature · 1 line
2.25.1
PATCH v2 3/4 Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj'
In reply to SeongJae ParkThe example code snippets on rculist_nulls.rst are assuming 'obj' to have the 'hlist_head' field named 'obj_node', but a sentence is wrongly mentioning 'obj->obj_node.next' as 'obj->obj_next'. Fix it.
--- Documentation/RCU/rculist_nulls.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/RCU/rculist_nulls.rst +1 -1
@@ -86,7 +86,7 @@ Quoting Corey Minyard:: 2) Insertion algorithm ---------------------- -We need to make sure a reader cannot read the new 'obj->obj_next' value +We need to make sure a reader cannot read the new 'obj->obj_node.next' value and previous value of 'obj->key'. Otherwise, an item could be deleted from a chain, and inserted into another chain. If new chain was empty before the move, 'next' pointer is NULL, and lockless reader can not
Signature · 1 line
2.25.1
Paul E. McKenney
maintainerRe: [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj'
Quoted 15 lines · SeongJae Park
The example code snippets on
rculist_nulls.rstare assuming 'obj' to have the 'hlist_head' field named 'obj_node', but a sentence is wrongly mentioning 'obj->obj_node.next' as 'obj->obj_next'. Fix it.Signed-off-by SeongJae Park <[email protected]>Reviewed-by Joel Fernandes (Google) <[email protected]>--- Documentation/RCU/rculist_nulls.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/RCU/rculist_nulls.rst +0
-0
Documentation/RCU/rculist_nulls.rst Quoting Corey Minyard:: · line 89
Quoted 5 lines
Documentation/RCU/rculist_nulls.rst +1
-1@@ -86,7 +86,7 @@ Quoting Corey Minyard:: 2) Insertion algorithm ---------------------- -We need to make sure a reader cannot read the new 'obj->obj_next' value +We need to make sure a reader cannot read the new 'obj->obj_node.next' value
I do like this being more specific, but if we are going do add this level of specificity, shouldn't we refer to a definition of ->obj_node?
(I queued and pushed 1/4 and 2/4, thank you, and stopped here.)
Thanx, Paul
Quoted 6 lines
Documentation/RCU/rculist_nulls.rst +0
-0and previous value of 'obj->key'. Otherwise, an item could be deleted from a chain, and inserted into another chain. If new chain was empty before the move, 'next' pointer is NULL, and lockless reader can notSignature · 1 line
2.25.1
Re: [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj'
Quoted 19 lines · On Wed, 14 Jun 2023 09:36:50 -0700 "Paul E. McKenney" <[email protected]>…
Quoted 18 lines · SeongJae Park
The example code snippets on
rculist_nulls.rstare assuming 'obj' to have the 'hlist_head' field named 'obj_node', but a sentence is wrongly mentioning 'obj->obj_node.next' as 'obj->obj_next'. Fix it.Signed-off-by SeongJae Park <[email protected]>Reviewed-by Joel Fernandes (Google) <[email protected]>--- Documentation/RCU/rculist_nulls.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/RCU/rculist_nulls.rst +0
-0@@ -86,7 +86,7 @@ Quoting Corey Minyard:: 2) Insertion algorithm ----------------------
Quoted 5 lines
Documentation/RCU/rculist_nulls.rst Quoting Corey Minyard:: · line 89
Quoted 2 lines
Documentation/RCU/rculist_nulls.rst +1
-1-We need to make sure a reader cannot read the new 'obj->obj_next' value +We need to make sure a reader cannot read the new 'obj->obj_node.next' valueI do like this being more specific, but if we are going do add this level of specificity, shouldn't we refer to a definition of ->obj_node?
Agreed, I will add the example definition in the next spin. I also found we would better to further fix wrong 'member' field assumption, like below:
- ({ obj = hlist_entry(pos, typeof(*obj), member); 1; });
+ ({ obj = hlist_entry(pos, typeof(*obj), obj_node); 1; });
Thanks,
SJ
Quoted 12 lines
(I queued and pushed 1/4 and 2/4, thank you, and stopped here.)
Thanx, Paul
Quoted 6 lines
Documentation/RCU/rculist_nulls.rst +0
-0and previous value of 'obj->key'. Otherwise, an item could be deleted from a chain, and inserted into another chain. If new chain was empty before the move, 'next' pointer is NULL, and lockless reader can notSignature · 1 line
2.25.1
PATCH v2 4/4 Docs/RCU/rculist_nulls: Fix wrong text about atomic_set_release()
In reply to SeongJae ParkThe document says we can avoid extra _release() in insert function when hlist_nulls is used, but that's not true[1]. Drop it.
[1] https://lore.kernel.org/rcu/46440869-644a-4982-b790-b71b43976c66@paulmck-laptop/
--- Documentation/RCU/rculist_nulls.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/RCU/rculist_nulls.rst +4 -2
@@ -129,8 +129,7 @@ very very fast (before the end of RCU grace period) Avoiding extra smp_rmb() ======================== -With hlist_nulls we can avoid extra smp_rmb() in lockless_lookup() -and extra _release() in insert function. +With hlist_nulls we can avoid extra smp_rmb() in lockless_lookup(). For example, if we choose to store the slot number as the 'nulls' end-of-list marker for each slot of the hash table, we can detect
@@ -182,6 +181,9 @@ scan the list again without harm. 2) Insert algorithm ------------------- +Same to the above one, but uses hlist_nulls_add_head_rcu() instead of +hlist_add_head_rcu(). + :: /*
Signature · 1 line
2.25.1