torture: Trace long read-side delays
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 11 Oct 2016 01:26:04 +0000 (18:26 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 14 Nov 2016 18:46:30 +0000 (10:46 -0800)
Although rcutorture will occasionally do a 50-millisecond grace-period
delay, these delays are quite rare.  And rightly so, because otherwise
the read rate would be quite low.  Thie means that it can be important
to identify whether or not a given run contained a long-delay read.
This commit therefore inserts a trace_rcu_torture_read() event to flag
runs containing long delays.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
include/trace/events/rcu.h
kernel/rcu/rcutorture.c

index d3e7565..9d4f9b3 100644 (file)
@@ -698,7 +698,10 @@ TRACE_EVENT(rcu_batch_end,
 /*
  * Tracepoint for rcutorture readers.  The first argument is the name
  * of the RCU flavor from rcutorture's viewpoint and the second argument
- * is the callback address.
+ * is the callback address.  The third argument is the start time in
+ * seconds, and the last two arguments are the grace period numbers
+ * at the beginning and end of the read, respectively.  Note that the
+ * callback address can be NULL.
  */
 TRACE_EVENT(rcu_torture_read,
 
index bf08fee..87c5122 100644 (file)
@@ -289,15 +289,24 @@ static int rcu_torture_read_lock(void) __acquires(RCU)
 
 static void rcu_read_delay(struct torture_random_state *rrsp)
 {
+       unsigned long started;
+       unsigned long completed;
        const unsigned long shortdelay_us = 200;
        const unsigned long longdelay_ms = 50;
+       unsigned long long ts;
 
        /* We want a short delay sometimes to make a reader delay the grace
         * period, and we want a long delay occasionally to trigger
         * force_quiescent_state. */
 
-       if (!(torture_random(rrsp) % (nrealreaders * 2000 * longdelay_ms)))
+       if (!(torture_random(rrsp) % (nrealreaders * 2000 * longdelay_ms))) {
+               started = cur_ops->completed();
+               ts = rcu_trace_clock_local();
                mdelay(longdelay_ms);
+               completed = cur_ops->completed();
+               do_trace_rcu_torture_read(cur_ops->name, NULL, ts,
+                                         started, completed);
+       }
        if (!(torture_random(rrsp) % (nrealreaders * 2 * shortdelay_us)))
                udelay(shortdelay_us);
 #ifdef CONFIG_PREEMPT