Skip to contentSkip to conversation

SRCU changes for v4.19

PATCH In review Paul E. McKenney 2 participants 7 messages Jun 25, 2018 Sleepable read-copy update (SRCU)

lore
Share & tools
lore
#0 lore raw

cover SRCU changes for v4.19

Hello!

This series contains SRCU updates:

1. Fix typos in __call_srcu() comment header.

2. Document that srcu_funnel_gp_start() implies srcu_funnel_exp_start().

3. Add address of the first callback to rcutorture output to allow
this output to show (lack of) forward progress.

4. Introduce srcu_read_{un,}lock_notrace() to avoid lockdep issues
when applying SRCU to tracepoints.

Thanx, Paul

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

 include/linux/srcu.h  |   17 +++++++++++++++++
 kernel/rcu/srcutree.c |   26 +++++++++++++++-----------
 2 files changed, 32 insertions(+), 11 deletions(-)
#1 lore raw

PATCH 1/4 srcu: Fix typos in __call_srcu() header comment

This commit simply changes some copy-pasta call_rcu() instances to the correct call_srcu().

---
 kernel/rcu/srcutree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/srcutree.c +4 -4
index b4123d7a2cec..615e414b0c1e 100644
@@ -823,17 +823,17 @@ static void srcu_leak_callback(struct rcu_head *rhp)
  * more than one CPU, this means that when "func()" is invoked, each CPU
  * is guaranteed to have executed a full memory barrier since the end of
  * its last corresponding SRCU read-side critical section whose beginning
- * preceded the call to call_rcu().  It also means that each CPU executing
+ * preceded the call to call_srcu().  It also means that each CPU executing
  * an SRCU read-side critical section that continues beyond the start of
- * "func()" must have executed a memory barrier after the call_rcu()
+ * "func()" must have executed a memory barrier after the call_srcu()
  * but before the beginning of that SRCU read-side critical section.
  * Note that these guarantees include CPUs that are offline, idle, or
  * executing in user mode, as well as CPUs that are executing in the kernel.
  *
- * Furthermore, if CPU A invoked call_rcu() and CPU B invoked the
+ * Furthermore, if CPU A invoked call_srcu() and CPU B invoked the
  * resulting SRCU callback function "func()", then both CPU A and CPU
  * B are guaranteed to execute a full memory barrier during the time
- * interval between the call to call_rcu() and the invocation of "func()".
+ * interval between the call to call_srcu() and the invocation of "func()".
  * This guarantee applies even if CPU A and CPU B are the same CPU (but
  * again only if the system has more than one CPU).
  *
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH tip/core/rcu 1/4] srcu: Fix typos in __call_srcu() header comment

Quoted 1 line · Paul E. McKenney

This commit simply changes some copy-pasta call_rcu() instances to

                                       ^^^^^ cute :)
Quoted 6 lines

the correct call_srcu().

---
 kernel/rcu/srcutree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
~Randy
#3 lore raw

Re: [PATCH tip/core/rcu 1/4] srcu: Fix typos in __call_srcu() header comment

Quoted 4 lines · Randy Dunlap
Quoted 1 line · Paul E. McKenney

This commit simply changes some copy-pasta call_rcu() instances to

                                       ^^^^^ cute :)

Glad you like it! I was unable to determine if this copy-pasta constituted copy-spaghetti, copy-macaroni, copy-cannelloni, copy-rotelle, copy-linguini, copy-lasagne, or something else altogether.

You all can decide for yourselves. ;-)

Thanx, Paul

Quoted 11 lines
Quoted 6 lines

the correct call_srcu().

---
 kernel/rcu/srcutree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
~Randy
#4 lore raw

PATCH 2/4 srcu: Document that srcu_funnel_gp_start() implies srcu_funnel_exp_start()

In reply to Paul E. McKenney

This commit updates the header comment of srcu_funnel_gp_start() to document the fact that srcu_funnel_gp_start() does the work of srcu_funnel_exp_start(), in some cases by invoking it directly.

---
 kernel/rcu/srcutree.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/rcu/srcutree.c +3 -0
index 615e414b0c1e..37bef2fe80e6 100644
@@ -641,6 +641,9 @@ static void srcu_funnel_exp_start(struct srcu_struct *sp, struct srcu_node *snp,
  * period s.  Losers must either ensure that their desired grace-period
  * number is recorded on at least their leaf srcu_node structure, or they
  * must take steps to invoke their own callbacks.
+ *
+ * Note that this function also does the work of srcu_funnel_exp_start(),
+ * in some cases by directly invoking it.
  */
 static void srcu_funnel_gp_start(struct srcu_struct *sp, struct srcu_data *sdp,
 				 unsigned long s, bool do_norm)
Signature · 1 line
2.17.1
#5 lore raw

PATCH 3/4 srcu: Add address of first callback to rcutorture output

In reply to Paul E. McKenney

This commit adds the address of the first callback to the per-CPU rcutorture output in order to allow lost wakeups to be more efficiently tracked down.

---
 kernel/rcu/srcutree.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
kernel/rcu/srcutree.c +8 -7
index 37bef2fe80e6..5a1a9a07b407 100644
@@ -1271,11 +1271,11 @@ void srcu_torture_stats_print(struct srcu_struct *sp, char *tt, char *tf)
 		unsigned long l0, l1;
 		unsigned long u0, u1;
 		long c0, c1;
-		struct srcu_data *counts;
+		struct srcu_data *sdp;
 
-		counts = per_cpu_ptr(sp->sda, cpu);
-		u0 = counts->srcu_unlock_count[!idx];
-		u1 = counts->srcu_unlock_count[idx];
+		sdp = per_cpu_ptr(sp->sda, cpu);
+		u0 = sdp->srcu_unlock_count[!idx];
+		u1 = sdp->srcu_unlock_count[idx];
 
 		/*
 		 * Make sure that a lock is always counted if the corresponding
@@ -1283,12 +1283,13 @@ void srcu_torture_stats_print(struct srcu_struct *sp, char *tt, char *tf)
 		 */
 		smp_rmb();
 
-		l0 = counts->srcu_lock_count[!idx];
-		l1 = counts->srcu_lock_count[idx];
+		l0 = sdp->srcu_lock_count[!idx];
+		l1 = sdp->srcu_lock_count[idx];
 
 		c0 = l0 - u0;
 		c1 = l1 - u1;
-		pr_cont(" %d(%ld,%ld)", cpu, c0, c1);
+		pr_cont(" %d(%ld,%ld %1p)",
+			cpu, c0, c1, rcu_segcblist_head(&sdp->srcu_cblist));
 		s0 += c0;
 		s1 += c1;
 	}
Signature · 1 line
2.17.1
#6 lore raw

PATCH 4/4 srcu: Introduce srcu_read_{un,}lock_notrace()

In reply to Paul E. McKenney

Joel Fernandes is using SRCU to protect from-idle tracepoints, which requires notrace variants of srcu_read_lock() and srcu_read_unlock() in order to avoid problems with tracepoints in lockdep. This commit therefore adds srcu_read_lock_notrace() and srcu_read_unlock_notrace().

[1] http://lkml.kernel.org/r/[email protected]

---
 include/linux/srcu.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/linux/srcu.h +17 -0
index 91494d7e8e41..3e72a291c401 100644
@@ -195,6 +195,16 @@ static inline int srcu_read_lock(struct srcu_struct *sp) __acquires(sp)
 	return retval;
 }
 
+/* Used by tracing, cannot be traced and cannot invoke lockdep. */
+static inline notrace int
+srcu_read_lock_notrace(struct srcu_struct *sp) __acquires(sp)
+{
+	int retval;
+
+	retval = __srcu_read_lock(sp);
+	return retval;
+}
+
 /**
  * srcu_read_unlock - unregister a old reader from an SRCU-protected structure.
  * @sp: srcu_struct in which to unregister the old reader.
@@ -209,6 +219,13 @@ static inline void srcu_read_unlock(struct srcu_struct *sp, int idx)
 	__srcu_read_unlock(sp, idx);
 }
 
+/* Used by tracing, cannot be traced and cannot call lockdep. */
+static inline notrace void
+srcu_read_unlock_notrace(struct srcu_struct *sp, int idx) __releases(sp)
+{
+	__srcu_read_unlock(sp, idx);
+}
+
 /**
  * smp_mb__after_srcu_read_unlock - ensure full ordering after srcu_read_unlock
  *
Signature · 1 line
2.17.1