* [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt
@ 2018-06-07 10:01 ` Andrea Parri
0 siblings, 0 replies; 4+ messages in thread
From: Andrea Parri @ 2018-06-07 10:01 UTC (permalink / raw)
To: linux-kernel, linux-doc
Cc: Andrea Parri, Paul E . McKenney, Josh Triplett, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Jonathan Corbet
The synchronize_rcu() definition based on RW-locks in whatisRCU.txt
does not meet the "Memory-Barrier Guarantees" in Requirements.html;
for example, the following SB-like test:
P0: P1:
WRITE_ONCE(x, 1); WRITE_ONCE(y, 1);
synchronize_rcu(); smp_mb();
r0 = READ_ONCE(y); r1 = READ_ONCE(x);
should not be allowed to reach the state "r0 = 0 AND r1 = 0", but
the current write_lock()+write_unlock() definition can not ensure
this. Remedies this by inserting an smp_mb__after_spinlock().
Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
---
Documentation/RCU/whatisRCU.txt | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index a27fbfb0efb82..86a54ff911fc2 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -586,6 +586,7 @@ It is extremely simple:
void synchronize_rcu(void)
{
write_lock(&rcu_gp_mutex);
+ smp_mb__after_spinlock();
write_unlock(&rcu_gp_mutex);
}
@@ -607,12 +608,15 @@ don't forget about them when submitting patches making use of RCU!]
The rcu_read_lock() and rcu_read_unlock() primitive read-acquire
and release a global reader-writer lock. The synchronize_rcu()
-primitive write-acquires this same lock, then immediately releases
-it. This means that once synchronize_rcu() exits, all RCU read-side
-critical sections that were in progress before synchronize_rcu() was
-called are guaranteed to have completed -- there is no way that
-synchronize_rcu() would have been able to write-acquire the lock
-otherwise.
+primitive write-acquires this same lock, then releases it. This means
+that once synchronize_rcu() exits, all RCU read-side critical sections
+that were in progress before synchronize_rcu() was called are guaranteed
+to have completed -- there is no way that synchronize_rcu() would have
+been able to write-acquire the lock otherwise. The smp_mb__after_spinlock()
+promotes synchronize_rcu() to a full memory barrier in compliance with
+the "Memory-Barrier Guarantees" listed in:
+
+ Documentation/RCU/Design/Requirements/Requirements.html.
It is possible to nest rcu_read_lock(), since reader-writer locks may
be recursively acquired. Note also that rcu_read_lock() is immune
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt
@ 2018-06-07 10:01 ` Andrea Parri
0 siblings, 0 replies; 4+ messages in thread
From: Andrea Parri @ 2018-06-07 10:01 UTC (permalink / raw)
To: linux-kernel, linux-doc
Cc: Andrea Parri, Paul E . McKenney, Josh Triplett, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Jonathan Corbet
The synchronize_rcu() definition based on RW-locks in whatisRCU.txt
does not meet the "Memory-Barrier Guarantees" in Requirements.html;
for example, the following SB-like test:
P0: P1:
WRITE_ONCE(x, 1); WRITE_ONCE(y, 1);
synchronize_rcu(); smp_mb();
r0 = READ_ONCE(y); r1 = READ_ONCE(x);
should not be allowed to reach the state "r0 = 0 AND r1 = 0", but
the current write_lock()+write_unlock() definition can not ensure
this. Remedies this by inserting an smp_mb__after_spinlock().
Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
---
Documentation/RCU/whatisRCU.txt | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index a27fbfb0efb82..86a54ff911fc2 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -586,6 +586,7 @@ It is extremely simple:
void synchronize_rcu(void)
{
write_lock(&rcu_gp_mutex);
+ smp_mb__after_spinlock();
write_unlock(&rcu_gp_mutex);
}
@@ -607,12 +608,15 @@ don't forget about them when submitting patches making use of RCU!]
The rcu_read_lock() and rcu_read_unlock() primitive read-acquire
and release a global reader-writer lock. The synchronize_rcu()
-primitive write-acquires this same lock, then immediately releases
-it. This means that once synchronize_rcu() exits, all RCU read-side
-critical sections that were in progress before synchronize_rcu() was
-called are guaranteed to have completed -- there is no way that
-synchronize_rcu() would have been able to write-acquire the lock
-otherwise.
+primitive write-acquires this same lock, then releases it. This means
+that once synchronize_rcu() exits, all RCU read-side critical sections
+that were in progress before synchronize_rcu() was called are guaranteed
+to have completed -- there is no way that synchronize_rcu() would have
+been able to write-acquire the lock otherwise. The smp_mb__after_spinlock()
+promotes synchronize_rcu() to a full memory barrier in compliance with
+the "Memory-Barrier Guarantees" listed in:
+
+ Documentation/RCU/Design/Requirements/Requirements.html.
It is possible to nest rcu_read_lock(), since reader-writer locks may
be recursively acquired. Note also that rcu_read_lock() is immune
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt
2018-06-07 10:01 ` Andrea Parri
@ 2018-06-08 9:38 ` Paul E. McKenney
-1 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2018-06-08 9:38 UTC (permalink / raw)
To: Andrea Parri
Cc: linux-kernel, linux-doc, Josh Triplett, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Jonathan Corbet
On Thu, Jun 07, 2018 at 12:01:57PM +0200, Andrea Parri wrote:
> The synchronize_rcu() definition based on RW-locks in whatisRCU.txt
> does not meet the "Memory-Barrier Guarantees" in Requirements.html;
> for example, the following SB-like test:
>
> P0: P1:
>
> WRITE_ONCE(x, 1); WRITE_ONCE(y, 1);
> synchronize_rcu(); smp_mb();
> r0 = READ_ONCE(y); r1 = READ_ONCE(x);
>
> should not be allowed to reach the state "r0 = 0 AND r1 = 0", but
> the current write_lock()+write_unlock() definition can not ensure
> this. Remedies this by inserting an smp_mb__after_spinlock().
>
> Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Queued for review, thank you!
Thanx, Paul
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> Cc: Jonathan Corbet <corbet@lwn.net>
> ---
> Documentation/RCU/whatisRCU.txt | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
> index a27fbfb0efb82..86a54ff911fc2 100644
> --- a/Documentation/RCU/whatisRCU.txt
> +++ b/Documentation/RCU/whatisRCU.txt
> @@ -586,6 +586,7 @@ It is extremely simple:
> void synchronize_rcu(void)
> {
> write_lock(&rcu_gp_mutex);
> + smp_mb__after_spinlock();
> write_unlock(&rcu_gp_mutex);
> }
>
> @@ -607,12 +608,15 @@ don't forget about them when submitting patches making use of RCU!]
>
> The rcu_read_lock() and rcu_read_unlock() primitive read-acquire
> and release a global reader-writer lock. The synchronize_rcu()
> -primitive write-acquires this same lock, then immediately releases
> -it. This means that once synchronize_rcu() exits, all RCU read-side
> -critical sections that were in progress before synchronize_rcu() was
> -called are guaranteed to have completed -- there is no way that
> -synchronize_rcu() would have been able to write-acquire the lock
> -otherwise.
> +primitive write-acquires this same lock, then releases it. This means
> +that once synchronize_rcu() exits, all RCU read-side critical sections
> +that were in progress before synchronize_rcu() was called are guaranteed
> +to have completed -- there is no way that synchronize_rcu() would have
> +been able to write-acquire the lock otherwise. The smp_mb__after_spinlock()
> +promotes synchronize_rcu() to a full memory barrier in compliance with
> +the "Memory-Barrier Guarantees" listed in:
> +
> + Documentation/RCU/Design/Requirements/Requirements.html.
>
> It is possible to nest rcu_read_lock(), since reader-writer locks may
> be recursively acquired. Note also that rcu_read_lock() is immune
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt
@ 2018-06-08 9:38 ` Paul E. McKenney
0 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2018-06-08 9:38 UTC (permalink / raw)
To: Andrea Parri
Cc: linux-kernel, linux-doc, Josh Triplett, Steven Rostedt,
Mathieu Desnoyers, Lai Jiangshan, Jonathan Corbet
On Thu, Jun 07, 2018 at 12:01:57PM +0200, Andrea Parri wrote:
> The synchronize_rcu() definition based on RW-locks in whatisRCU.txt
> does not meet the "Memory-Barrier Guarantees" in Requirements.html;
> for example, the following SB-like test:
>
> P0: P1:
>
> WRITE_ONCE(x, 1); WRITE_ONCE(y, 1);
> synchronize_rcu(); smp_mb();
> r0 = READ_ONCE(y); r1 = READ_ONCE(x);
>
> should not be allowed to reach the state "r0 = 0 AND r1 = 0", but
> the current write_lock()+write_unlock() definition can not ensure
> this. Remedies this by inserting an smp_mb__after_spinlock().
>
> Suggested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Queued for review, thank you!
Thanx, Paul
> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Cc: Josh Triplett <josh@joshtriplett.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> Cc: Jonathan Corbet <corbet@lwn.net>
> ---
> Documentation/RCU/whatisRCU.txt | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
> index a27fbfb0efb82..86a54ff911fc2 100644
> --- a/Documentation/RCU/whatisRCU.txt
> +++ b/Documentation/RCU/whatisRCU.txt
> @@ -586,6 +586,7 @@ It is extremely simple:
> void synchronize_rcu(void)
> {
> write_lock(&rcu_gp_mutex);
> + smp_mb__after_spinlock();
> write_unlock(&rcu_gp_mutex);
> }
>
> @@ -607,12 +608,15 @@ don't forget about them when submitting patches making use of RCU!]
>
> The rcu_read_lock() and rcu_read_unlock() primitive read-acquire
> and release a global reader-writer lock. The synchronize_rcu()
> -primitive write-acquires this same lock, then immediately releases
> -it. This means that once synchronize_rcu() exits, all RCU read-side
> -critical sections that were in progress before synchronize_rcu() was
> -called are guaranteed to have completed -- there is no way that
> -synchronize_rcu() would have been able to write-acquire the lock
> -otherwise.
> +primitive write-acquires this same lock, then releases it. This means
> +that once synchronize_rcu() exits, all RCU read-side critical sections
> +that were in progress before synchronize_rcu() was called are guaranteed
> +to have completed -- there is no way that synchronize_rcu() would have
> +been able to write-acquire the lock otherwise. The smp_mb__after_spinlock()
> +promotes synchronize_rcu() to a full memory barrier in compliance with
> +the "Memory-Barrier Guarantees" listed in:
> +
> + Documentation/RCU/Design/Requirements/Requirements.html.
>
> It is possible to nest rcu_read_lock(), since reader-writer locks may
> be recursively acquired. Note also that rcu_read_lock() is immune
> --
> 2.7.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-06-08 9:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 10:01 [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt Andrea Parri
2018-06-07 10:01 ` Andrea Parri
2018-06-08 9:38 ` Paul E. McKenney
2018-06-08 9:38 ` Paul E. McKenney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.