rcu: Optimize the 'rcu_pending' for RCU trace
authorMichael Wang <wangyun@linux.vnet.ibm.com>
Thu, 20 Sep 2012 00:51:06 +0000 (08:51 +0800)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 8 Nov 2012 19:50:17 +0000 (11:50 -0800)
This patch implements the new 'rcu_pending' interface under each rsp
directory, by using the 'CPU units sequence reading', thus avoiding loss
of tracing data.

Signed-off-by: Michael Wang <wangyun@linux.vnet.ibm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/rcutree_trace.c

index e387a64..8b24867 100644 (file)
@@ -467,6 +467,8 @@ static const struct file_operations rcugp_fops = {
 
 static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
 {
+       if (!rdp->beenonline)
+               return;
        seq_printf(m, "%3d%cnp=%ld ",
                   rdp->cpu,
                   cpu_is_offline(rdp->cpu) ? '!' : ' ',
@@ -485,16 +487,12 @@ static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
 static int show_rcu_pending(struct seq_file *m, void *unused)
 {
        int cpu;
-       struct rcu_data *rdp;
        struct rcu_state *rsp;
 
        for_each_rcu_flavor(rsp) {
                seq_printf(m, "%s:\n", rsp->name);
-               for_each_possible_cpu(cpu) {
-                       rdp = per_cpu_ptr(rsp->rda, cpu);
-                       if (rdp->beenonline)
-                               print_one_rcu_pending(m, rdp);
-               }
+               for_each_possible_cpu(cpu)
+                       print_one_rcu_pending(m, per_cpu_ptr(rsp->rda, cpu));
        }
        return 0;
 }
@@ -512,6 +510,32 @@ static const struct file_operations rcu_pending_fops = {
        .release = single_release,
 };
 
+static int new_show_rcu_pending(struct seq_file *m, void *v)
+{
+       print_one_rcu_pending(m, (struct rcu_data *)v);
+       return 0;
+}
+
+static const struct seq_operations new_rcu_pending_op = {
+       .start = r_start,
+       .next  = r_next,
+       .stop  = r_stop,
+       .show  = new_show_rcu_pending,
+};
+
+static int new_rcu_pending_open(struct inode *inode, struct file *file)
+{
+       return r_open(inode, file, &new_rcu_pending_op);
+}
+
+static const struct file_operations new_rcu_pending_fops = {
+       .owner = THIS_MODULE,
+       .open = new_rcu_pending_open,
+       .read = seq_read,
+       .llseek = no_llseek,
+       .release = seq_release,
+};
+
 static int show_rcutorture(struct seq_file *m, void *unused)
 {
        seq_printf(m, "rcutorture test sequence: %lu %s\n",
@@ -561,6 +585,11 @@ static int __init rcutree_trace_init(void)
                                        rspdir, rsp, &new_rcudata_csv_fops);
                        if (!retval)
                                goto free_out;
+
+                       retval = debugfs_create_file("rcu_pending", 0444,
+                                       rspdir, rsp, &new_rcu_pending_fops);
+                       if (!retval)
+                               goto free_out;
        }
 
        retval = debugfs_create_file("rcubarrier", 0444, rcudir,