mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH rcu 0/3] SRCU updates for v6.14
@ 2024-12-12 18:51 Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 1/3] srcu: Guarantee non-negative return value from srcu_read_lock() Paul E. McKenney
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paul E. McKenney @ 2024-12-12 18:51 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt

Hello!

This series contains SRCU updates:

1.	Guarantee non-negative return value from srcu_read_lock().

2.	Fix typo s/srcu_check_read_flavor()/__srcu_check_read_flavor()/.

3.	Remove redundant GP sequence checks in srcu_funnel_gp_start,
	courtesy of Feng Lee.

						Thanx, Paul

------------------------------------------------------------------------

 b/include/linux/srcu.h     |   15 ++++++++-------
 b/include/linux/srcutree.h |    2 +-
 b/kernel/rcu/srcutree.c    |    3 ++-
 kernel/rcu/srcutree.c      |    1 -
 4 files changed, 11 insertions(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rcu 1/3] srcu: Guarantee non-negative return value from srcu_read_lock()
  2024-12-12 18:51 [PATCH rcu 0/3] SRCU updates for v6.14 Paul E. McKenney
@ 2024-12-12 18:51 ` Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 2/3] srcu: Fix typo s/srcu_check_read_flavor()/__srcu_check_read_flavor()/ Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 3/3] srcu: Remove redundant GP sequence checks in srcu_funnel_gp_start Paul E. McKenney
  2 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2024-12-12 18:51 UTC (permalink / raw)
  To: rcu
  Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney,
	Andrii Nakryiko, Peter Zijlstra

For almost 20 years, the int return value from srcu_read_lock() has
been always either zero or one.  This commit therefore documents the
fact that it will be non-negative, and does the same for the underlying
__srcu_read_lock().

[ paulmck: Apply Andrii Nakryiko feedback. ]

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/linux/srcu.h  | 15 ++++++++-------
 kernel/rcu/srcutree.c |  3 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 08339eb8a01c8..abaddd7e6ddf7 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -232,13 +232,14 @@ static inline int srcu_read_lock_held(const struct srcu_struct *ssp)
  * a mutex that is held elsewhere while calling synchronize_srcu() or
  * synchronize_srcu_expedited().
  *
- * The return value from srcu_read_lock() must be passed unaltered
- * to the matching srcu_read_unlock().  Note that srcu_read_lock() and
- * the matching srcu_read_unlock() must occur in the same context, for
- * example, it is illegal to invoke srcu_read_unlock() in an irq handler
- * if the matching srcu_read_lock() was invoked in process context.  Or,
- * for that matter to invoke srcu_read_unlock() from one task and the
- * matching srcu_read_lock() from another.
+ * The return value from srcu_read_lock() is guaranteed to be
+ * non-negative.  This value must be passed unaltered to the matching
+ * srcu_read_unlock().  Note that srcu_read_lock() and the matching
+ * srcu_read_unlock() must occur in the same context, for example, it is
+ * illegal to invoke srcu_read_unlock() in an irq handler if the matching
+ * srcu_read_lock() was invoked in process context.  Or, for that matter to
+ * invoke srcu_read_unlock() from one task and the matching srcu_read_lock()
+ * from another.
  */
 static inline int srcu_read_lock(struct srcu_struct *ssp) __acquires(ssp)
 {
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 5e2e534647946..26ef58b481aae 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -738,7 +738,8 @@ EXPORT_SYMBOL_GPL(__srcu_check_read_flavor);
 /*
  * Counts the new reader in the appropriate per-CPU element of the
  * srcu_struct.
- * Returns an index that must be passed to the matching srcu_read_unlock().
+ * Returns a guaranteed non-negative index that must be passed to the
+ * matching __srcu_read_unlock().
  */
 int __srcu_read_lock(struct srcu_struct *ssp)
 {
-- 
2.40.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rcu 2/3] srcu: Fix typo s/srcu_check_read_flavor()/__srcu_check_read_flavor()/
  2024-12-12 18:51 [PATCH rcu 0/3] SRCU updates for v6.14 Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 1/3] srcu: Guarantee non-negative return value from srcu_read_lock() Paul E. McKenney
@ 2024-12-12 18:51 ` Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 3/3] srcu: Remove redundant GP sequence checks in srcu_funnel_gp_start Paul E. McKenney
  2 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2024-12-12 18:51 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Paul E. McKenney, Neeraj Upadhyay

This commit fixes a typo in which a comment needed to have been updated
from srcu_check_read_flavor() to __srcu_check_read_flavor().

Reported-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Closes: https://lore.kernel.org/all/b75d1fcd-6fcd-4619-bb5c-507fa599ee28@amd.com/
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 include/linux/srcutree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
index 490aeecc6bb47..4e69f88bcab9f 100644
--- a/include/linux/srcutree.h
+++ b/include/linux/srcutree.h
@@ -258,7 +258,7 @@ static inline void srcu_check_read_flavor_lite(struct srcu_struct *ssp)
 	if (likely(READ_ONCE(sdp->srcu_reader_flavor) & SRCU_READ_FLAVOR_LITE))
 		return;
 
-	// Note that the cmpxchg() in srcu_check_read_flavor() is fully ordered.
+	// Note that the cmpxchg() in __srcu_check_read_flavor() is fully ordered.
 	__srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_LITE);
 }
 
-- 
2.40.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rcu 3/3] srcu: Remove redundant GP sequence checks in srcu_funnel_gp_start
  2024-12-12 18:51 [PATCH rcu 0/3] SRCU updates for v6.14 Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 1/3] srcu: Guarantee non-negative return value from srcu_read_lock() Paul E. McKenney
  2024-12-12 18:51 ` [PATCH rcu 2/3] srcu: Fix typo s/srcu_check_read_flavor()/__srcu_check_read_flavor()/ Paul E. McKenney
@ 2024-12-12 18:51 ` Paul E. McKenney
  2 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2024-12-12 18:51 UTC (permalink / raw)
  To: rcu; +Cc: linux-kernel, kernel-team, rostedt, Feng Lee, Paul E . McKenney

From: Feng Lee <379943137@qq.com>

We will perform GP sequence checking at the beginning of srcu_gp_start,
thus making it safe to remove duplicate GP sequence checks prior to
calling srcu_gp_start.

Signed-off-by: Feng Lee <379943137@qq.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/srcutree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 26ef58b481aae..b83c74c4dcc0d 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1077,7 +1077,6 @@ static void srcu_funnel_gp_start(struct srcu_struct *ssp, struct srcu_data *sdp,
 	/* If grace period not already in progress, start it. */
 	if (!WARN_ON_ONCE(rcu_seq_done(&sup->srcu_gp_seq, s)) &&
 	    rcu_seq_state(sup->srcu_gp_seq) == SRCU_STATE_IDLE) {
-		WARN_ON_ONCE(ULONG_CMP_GE(sup->srcu_gp_seq, sup->srcu_gp_seq_needed));
 		srcu_gp_start(ssp);
 
 		// And how can that list_add() in the "else" clause
-- 
2.40.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-12 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-12 18:51 [PATCH rcu 0/3] SRCU updates for v6.14 Paul E. McKenney
2024-12-12 18:51 ` [PATCH rcu 1/3] srcu: Guarantee non-negative return value from srcu_read_lock() Paul E. McKenney
2024-12-12 18:51 ` [PATCH rcu 2/3] srcu: Fix typo s/srcu_check_read_flavor()/__srcu_check_read_flavor()/ Paul E. McKenney
2024-12-12 18:51 ` [PATCH rcu 3/3] srcu: Remove redundant GP sequence checks in srcu_funnel_gp_start Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®