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(-)
--
2.25.1
Lookup example code snippets in rculist_nulls.rst are using 'obj'
without assignment. Fix the code to assign it properly.
Signed-off-by: SeongJae Park <[email protected]>
Reviewed-by: Joel Fernandes (Google) <[email protected]>
---
Documentation/RCU/rculist_nulls.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst
index 253ecd869fc2..94a8bfe9f560 100644
--- a/Documentation/RCU/rculist_nulls.rst
+++ b/Documentation/RCU/rculist_nulls.rst
@@ -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;
--
2.25.1
The 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.
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(-)
diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst
index 94a8bfe9f560..5cd6f3f8810f 100644
--- a/Documentation/RCU/rculist_nulls.rst
+++ b/Documentation/RCU/rculist_nulls.rst
@@ -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
--
2.25.1
The 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/
Signed-off-by: SeongJae Park <[email protected]>
---
Documentation/RCU/rculist_nulls.rst | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst
index 5cd6f3f8810f..018cc100d19b 100644
--- a/Documentation/RCU/rculist_nulls.rst
+++ b/Documentation/RCU/rculist_nulls.rst
@@ -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().
+
::
/*
--
2.25.1
On Tue, Jun 13, 2023 at 06:24:33PM +0000, SeongJae Park wrote:
> The 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.
>
> 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(-)
>
> diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst
> index 94a8bfe9f560..5cd6f3f8810f 100644
> --- a/Documentation/RCU/rculist_nulls.rst
> +++ b/Documentation/RCU/rculist_nulls.rst
> @@ -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
> 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
> --
> 2.25.1
>
On Wed, 14 Jun 2023 09:36:50 -0700 "Paul E. McKenney" <[email protected]> wrote:
> On Tue, Jun 13, 2023 at 06:24:33PM +0000, SeongJae Park wrote:
> > The 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.
> >
> > 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(-)
> >
> > diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst
> > index 94a8bfe9f560..5cd6f3f8810f 100644
> > --- a/Documentation/RCU/rculist_nulls.rst
> > +++ b/Documentation/RCU/rculist_nulls.rst
> > @@ -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?
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
>
> (I queued and pushed 1/4 and 2/4, thank you, and stopped here.)
>
> Thanx, Paul
>
> > 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
> > --
> > 2.25.1
> >
>