* [PATCH v2 0/4] Docs/RCU/rculist_nulls: Minor fixups
@ 2023-06-13 18:24 SeongJae Park
2023-06-13 18:24 ` [PATCH v2 1/4] Docs/RCU/rculist_nulls: Fix trivial coding style SeongJae Park
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: SeongJae Park @ 2023-06-13 18:24 UTC (permalink / raw)
To: paulmck
Cc: SeongJae Park, joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
Changes from v1
(https://lore.kernel.org/rcu/20230518224008.2468-1-sj@kernel.org/)
- 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/4] Docs/RCU/rculist_nulls: Fix trivial coding style
2023-06-13 18:24 [PATCH v2 0/4] Docs/RCU/rculist_nulls: Minor fixups SeongJae Park
@ 2023-06-13 18:24 ` SeongJae Park
2023-06-13 18:24 ` [PATCH v2 2/4] Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples SeongJae Park
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2023-06-13 18:24 UTC (permalink / raw)
To: paulmck
Cc: SeongJae Park, joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
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.
Signed-off-by: SeongJae Park <sj@kernel.org>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
Documentation/RCU/rculist_nulls.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/RCU/rculist_nulls.rst b/Documentation/RCU/rculist_nulls.rst
index 9a734bf54b76..253ecd869fc2 100644
--- a/Documentation/RCU/rculist_nulls.rst
+++ b/Documentation/RCU/rculist_nulls.rst
@@ -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::
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples
2023-06-13 18:24 [PATCH v2 0/4] Docs/RCU/rculist_nulls: Minor fixups SeongJae Park
2023-06-13 18:24 ` [PATCH v2 1/4] Docs/RCU/rculist_nulls: Fix trivial coding style SeongJae Park
@ 2023-06-13 18:24 ` SeongJae Park
2023-06-13 18:24 ` [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj' SeongJae Park
2023-06-13 18:24 ` [PATCH v2 4/4] Docs/RCU/rculist_nulls: Fix wrong text about atomic_set_release() SeongJae Park
3 siblings, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2023-06-13 18:24 UTC (permalink / raw)
To: paulmck
Cc: SeongJae Park, joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
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 <sj@kernel.org>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj'
2023-06-13 18:24 [PATCH v2 0/4] Docs/RCU/rculist_nulls: Minor fixups SeongJae Park
2023-06-13 18:24 ` [PATCH v2 1/4] Docs/RCU/rculist_nulls: Fix trivial coding style SeongJae Park
2023-06-13 18:24 ` [PATCH v2 2/4] Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples SeongJae Park
@ 2023-06-13 18:24 ` SeongJae Park
2023-06-14 16:36 ` Paul E. McKenney
2023-06-13 18:24 ` [PATCH v2 4/4] Docs/RCU/rculist_nulls: Fix wrong text about atomic_set_release() SeongJae Park
3 siblings, 1 reply; 7+ messages in thread
From: SeongJae Park @ 2023-06-13 18:24 UTC (permalink / raw)
To: paulmck
Cc: SeongJae Park, joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
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 <sj@kernel.org>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] Docs/RCU/rculist_nulls: Fix wrong text about atomic_set_release()
2023-06-13 18:24 [PATCH v2 0/4] Docs/RCU/rculist_nulls: Minor fixups SeongJae Park
` (2 preceding siblings ...)
2023-06-13 18:24 ` [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj' SeongJae Park
@ 2023-06-13 18:24 ` SeongJae Park
3 siblings, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2023-06-13 18:24 UTC (permalink / raw)
To: paulmck
Cc: SeongJae Park, joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
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 <sj@kernel.org>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj'
2023-06-13 18:24 ` [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj' SeongJae Park
@ 2023-06-14 16:36 ` Paul E. McKenney
2023-06-15 17:30 ` SeongJae Park
0 siblings, 1 reply; 7+ messages in thread
From: Paul E. McKenney @ 2023-06-14 16:36 UTC (permalink / raw)
To: SeongJae Park; +Cc: joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
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 <sj@kernel.org>
> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
> 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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj'
2023-06-14 16:36 ` Paul E. McKenney
@ 2023-06-15 17:30 ` SeongJae Park
0 siblings, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2023-06-15 17:30 UTC (permalink / raw)
To: Paul E. McKenney
Cc: SeongJae Park, joel, mmpgouride, corbet, rcu, linux-doc, linux-kernel
On Wed, 14 Jun 2023 09:36:50 -0700 "Paul E. McKenney" <paulmck@kernel.org> 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 <sj@kernel.org>
> > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> > ---
> > 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
> >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-06-15 17:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 18:24 [PATCH v2 0/4] Docs/RCU/rculist_nulls: Minor fixups SeongJae Park
2023-06-13 18:24 ` [PATCH v2 1/4] Docs/RCU/rculist_nulls: Fix trivial coding style SeongJae Park
2023-06-13 18:24 ` [PATCH v2 2/4] Docs/RCU/rculist_nulls: Assign 'obj' before use from the examples SeongJae Park
2023-06-13 18:24 ` [PATCH v2 3/4] Docs/RCU/rculist_nulls: Fix hlist_head field name of 'obj' SeongJae Park
2023-06-14 16:36 ` Paul E. McKenney
2023-06-15 17:30 ` SeongJae Park
2023-06-13 18:24 ` [PATCH v2 4/4] Docs/RCU/rculist_nulls: Fix wrong text about atomic_set_release() SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).