瀏覽代碼

rcu: Track CPU-hotplug duration statistics

Many rcutorture runs include CPU-hotplug operations in their stress
testing.  This commit accumulates statistics on the durations of these
operations in deference to the recent concern about the overhead and
latency of these operations.

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Paul E. McKenney 13 年之前
父節點
當前提交
13dbf9140c
共有 1 個文件被更改,包括 37 次插入5 次删除
  1. 37 5
      kernel/rcutorture.c

+ 37 - 5
kernel/rcutorture.c

@@ -177,8 +177,14 @@ static long n_rcu_torture_boosts;
 static long n_rcu_torture_timers;
 static long n_rcu_torture_timers;
 static long n_offline_attempts;
 static long n_offline_attempts;
 static long n_offline_successes;
 static long n_offline_successes;
+static unsigned long sum_offline;
+static int min_offline = -1;
+static int max_offline;
 static long n_online_attempts;
 static long n_online_attempts;
 static long n_online_successes;
 static long n_online_successes;
+static unsigned long sum_online;
+static int min_online = -1;
+static int max_online;
 static long n_barrier_attempts;
 static long n_barrier_attempts;
 static long n_barrier_successes;
 static long n_barrier_successes;
 static struct list_head rcu_torture_removed;
 static struct list_head rcu_torture_removed;
@@ -1215,11 +1221,13 @@ rcu_torture_printk(char *page)
 		       n_rcu_torture_boost_failure,
 		       n_rcu_torture_boost_failure,
 		       n_rcu_torture_boosts,
 		       n_rcu_torture_boosts,
 		       n_rcu_torture_timers);
 		       n_rcu_torture_timers);
-	cnt += sprintf(&page[cnt], "onoff: %ld/%ld:%ld/%ld ",
-		       n_online_successes,
-		       n_online_attempts,
-		       n_offline_successes,
-		       n_offline_attempts);
+	cnt += sprintf(&page[cnt],
+		       "onoff: %ld/%ld:%ld/%ld %d,%d:%d,%d %lu:%lu (HZ=%d) ",
+		       n_online_successes, n_online_attempts,
+		       n_offline_successes, n_offline_attempts,
+		       min_online, max_online,
+		       min_offline, max_offline,
+		       sum_online, sum_offline, HZ);
 	cnt += sprintf(&page[cnt], "barrier: %ld/%ld:%ld",
 	cnt += sprintf(&page[cnt], "barrier: %ld/%ld:%ld",
 		       n_barrier_successes,
 		       n_barrier_successes,
 		       n_barrier_attempts,
 		       n_barrier_attempts,
@@ -1491,8 +1499,10 @@ static int __cpuinit
 rcu_torture_onoff(void *arg)
 rcu_torture_onoff(void *arg)
 {
 {
 	int cpu;
 	int cpu;
+	unsigned long delta;
 	int maxcpu = -1;
 	int maxcpu = -1;
 	DEFINE_RCU_RANDOM(rand);
 	DEFINE_RCU_RANDOM(rand);
+	unsigned long starttime;
 
 
 	VERBOSE_PRINTK_STRING("rcu_torture_onoff task started");
 	VERBOSE_PRINTK_STRING("rcu_torture_onoff task started");
 	for_each_online_cpu(cpu)
 	for_each_online_cpu(cpu)
@@ -1510,6 +1520,7 @@ rcu_torture_onoff(void *arg)
 				printk(KERN_ALERT "%s" TORTURE_FLAG
 				printk(KERN_ALERT "%s" TORTURE_FLAG
 				       "rcu_torture_onoff task: offlining %d\n",
 				       "rcu_torture_onoff task: offlining %d\n",
 				       torture_type, cpu);
 				       torture_type, cpu);
+			starttime = jiffies;
 			n_offline_attempts++;
 			n_offline_attempts++;
 			if (cpu_down(cpu) == 0) {
 			if (cpu_down(cpu) == 0) {
 				if (verbose)
 				if (verbose)
@@ -1517,12 +1528,23 @@ rcu_torture_onoff(void *arg)
 					       "rcu_torture_onoff task: offlined %d\n",
 					       "rcu_torture_onoff task: offlined %d\n",
 					       torture_type, cpu);
 					       torture_type, cpu);
 				n_offline_successes++;
 				n_offline_successes++;
+				delta = jiffies - starttime;
+				sum_offline += delta;
+				if (min_offline < 0) {
+					min_offline = delta;
+					max_offline = delta;
+				}
+				if (min_offline > delta)
+					min_offline = delta;
+				if (max_offline < delta)
+					max_offline = delta;
 			}
 			}
 		} else if (cpu_is_hotpluggable(cpu)) {
 		} else if (cpu_is_hotpluggable(cpu)) {
 			if (verbose)
 			if (verbose)
 				printk(KERN_ALERT "%s" TORTURE_FLAG
 				printk(KERN_ALERT "%s" TORTURE_FLAG
 				       "rcu_torture_onoff task: onlining %d\n",
 				       "rcu_torture_onoff task: onlining %d\n",
 				       torture_type, cpu);
 				       torture_type, cpu);
+			starttime = jiffies;
 			n_online_attempts++;
 			n_online_attempts++;
 			if (cpu_up(cpu) == 0) {
 			if (cpu_up(cpu) == 0) {
 				if (verbose)
 				if (verbose)
@@ -1530,6 +1552,16 @@ rcu_torture_onoff(void *arg)
 					       "rcu_torture_onoff task: onlined %d\n",
 					       "rcu_torture_onoff task: onlined %d\n",
 					       torture_type, cpu);
 					       torture_type, cpu);
 				n_online_successes++;
 				n_online_successes++;
+				delta = jiffies - starttime;
+				sum_online += delta;
+				if (min_online < 0) {
+					min_online = delta;
+					max_online = delta;
+				}
+				if (min_online > delta)
+					min_online = delta;
+				if (max_online < delta)
+					max_online = delta;
 			}
 			}
 		}
 		}
 		schedule_timeout_interruptible(onoff_interval * HZ);
 		schedule_timeout_interruptible(onoff_interval * HZ);