blob: b1f28972872cb1fe3edd4a835ad3cbb5d692886a [file] [log] [blame]
Paul E. McKenney64db4cf2008-12-18 21:55:32 +01001/*
Paul Gortmaker47dbc902015-09-27 19:14:57 -04002 * Read-Copy Update tracing for hierarchical implementation.
Paul E. McKenney64db4cf2008-12-18 21:55:32 +01003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
Paul E. McKenney87de1cf2013-12-03 10:02:52 -080015 * along with this program; if not, you can access it online at
16 * http://www.gnu.org/licenses/gpl-2.0.html.
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010017 *
18 * Copyright IBM Corporation, 2008
Paul Gortmaker47dbc902015-09-27 19:14:57 -040019 * Author: Paul E. McKenney
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010020 *
21 * Papers: http://www.rdrop.com/users/paulmck/RCU
22 *
23 * For detailed explanation of Read-Copy Update mechanism see -
Paul E. McKenneya71fca52009-09-18 10:28:19 -070024 * Documentation/RCU
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010025 *
26 */
27#include <linux/types.h>
28#include <linux/kernel.h>
29#include <linux/init.h>
30#include <linux/spinlock.h>
31#include <linux/smp.h>
32#include <linux/rcupdate.h>
33#include <linux/interrupt.h>
34#include <linux/sched.h>
Arun Sharma600634972011-07-26 16:09:06 -070035#include <linux/atomic.h>
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010036#include <linux/bitops.h>
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010037#include <linux/completion.h>
Paul E. McKenney64db4cf2008-12-18 21:55:32 +010038#include <linux/percpu.h>
39#include <linux/notifier.h>
40#include <linux/cpu.h>
41#include <linux/mutex.h>
42#include <linux/debugfs.h>
43#include <linux/seq_file.h>
44
Paul E. McKenney9f77da92009-08-22 13:56:45 -070045#define RCU_TREE_NONCORE
Paul E. McKenney4102ada2013-10-08 20:23:47 -070046#include "tree.h"
Ingo Molnar6258c4f2009-03-25 16:42:24 +010047
Paul E. McKenney5cd37192014-12-13 20:32:04 -080048DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr);
49
Michael Wang374b9282012-09-20 08:51:03 +080050static int r_open(struct inode *inode, struct file *file,
51 const struct seq_operations *op)
52{
53 int ret = seq_open(file, op);
54 if (!ret) {
55 struct seq_file *m = (struct seq_file *)file->private_data;
56 m->private = inode->i_private;
57 }
58 return ret;
59}
60
61static void *r_start(struct seq_file *m, loff_t *pos)
62{
63 struct rcu_state *rsp = (struct rcu_state *)m->private;
64 *pos = cpumask_next(*pos - 1, cpu_possible_mask);
65 if ((*pos) < nr_cpu_ids)
66 return per_cpu_ptr(rsp->rda, *pos);
67 return NULL;
68}
69
70static void *r_next(struct seq_file *m, void *v, loff_t *pos)
71{
72 (*pos)++;
73 return r_start(m, pos);
74}
75
76static void r_stop(struct seq_file *m, void *v)
77{
78}
79
Michael Wang6ee08862012-10-11 14:26:42 -070080static int show_rcubarrier(struct seq_file *m, void *v)
Michael Wangc25e5572012-10-08 16:59:16 +080081{
82 struct rcu_state *rsp = (struct rcu_state *)m->private;
Paul E. McKenney4f525a52015-06-26 11:20:00 -070083 seq_printf(m, "bcc: %d bseq: %lu\n",
Michael Wangc25e5572012-10-08 16:59:16 +080084 atomic_read(&rsp->barrier_cpu_count),
Paul E. McKenney4f525a52015-06-26 11:20:00 -070085 rsp->barrier_sequence);
Michael Wangc25e5572012-10-08 16:59:16 +080086 return 0;
87}
88
Michael Wang6ee08862012-10-11 14:26:42 -070089static int rcubarrier_open(struct inode *inode, struct file *file)
Michael Wangc25e5572012-10-08 16:59:16 +080090{
Michael Wang6ee08862012-10-11 14:26:42 -070091 return single_open(file, show_rcubarrier, inode->i_private);
Michael Wangc25e5572012-10-08 16:59:16 +080092}
93
Michael Wang6ee08862012-10-11 14:26:42 -070094static const struct file_operations rcubarrier_fops = {
Michael Wangc25e5572012-10-08 16:59:16 +080095 .owner = THIS_MODULE,
Michael Wang6ee08862012-10-11 14:26:42 -070096 .open = rcubarrier_open,
Michael Wangc25e5572012-10-08 16:59:16 +080097 .read = seq_read,
98 .llseek = no_llseek,
Al Viro7ee2b9e2013-05-05 00:16:35 -040099 .release = single_release,
Michael Wangc25e5572012-10-08 16:59:16 +0800100};
101
Paul E. McKenneya46e0892011-06-15 15:47:09 -0700102#ifdef CONFIG_RCU_BOOST
103
Paul E. McKenneyd71df902011-03-29 17:48:28 -0700104static char convert_kthread_status(unsigned int kthread_status)
105{
106 if (kthread_status > RCU_KTHREAD_MAX)
107 return '?';
Paul E. McKenney15ba0ba2011-04-06 16:01:16 -0700108 return "SRWOY"[kthread_status];
Paul E. McKenneyd71df902011-03-29 17:48:28 -0700109}
110
Paul E. McKenneya46e0892011-06-15 15:47:09 -0700111#endif /* #ifdef CONFIG_RCU_BOOST */
112
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100113static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
114{
Paul E. McKenney3fbfbf72012-08-19 21:35:53 -0700115 long ql, qll;
116
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100117 if (!rdp->beenonline)
118 return;
Paul E. McKenney0d43eb32015-08-06 14:17:29 -0700119 seq_printf(m, "%3d%cc=%ld g=%ld cnq=%d/%d:%d",
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100120 rdp->cpu,
121 cpu_is_offline(rdp->cpu) ? '!' : ' ',
Paul E. McKenney42c35332012-09-28 10:49:58 -0700122 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
Paul E. McKenney5b74c452015-08-06 15:16:57 -0700123 rdp->cpu_no_qs.b.norm,
Paul E. McKenney5cd37192014-12-13 20:32:04 -0800124 rdp->rcu_qs_ctr_snap == per_cpu(rcu_qs_ctr, rdp->cpu),
Paul E. McKenney97c668b2015-08-06 11:31:51 -0700125 rdp->core_needs_qs);
Paul E. McKenney9b2e4f12011-09-30 12:10:22 -0700126 seq_printf(m, " dt=%d/%llx/%d df=%lu",
Paul E. McKenney23b5c8f2010-09-07 10:38:22 -0700127 atomic_read(&rdp->dynticks->dynticks),
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100128 rdp->dynticks->dynticks_nesting,
Paul E. McKenney23b5c8f2010-09-07 10:38:22 -0700129 rdp->dynticks->dynticks_nmi_nesting,
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100130 rdp->dynticks_fqs);
Paul E. McKenney2036d942012-01-30 17:02:47 -0800131 seq_printf(m, " of=%lu", rdp->offline_fqs);
Paul E. McKenney3fbfbf72012-08-19 21:35:53 -0700132 rcu_nocb_q_lengths(rdp, &ql, &qll);
133 qll += rdp->qlen_lazy;
134 ql += rdp->qlen;
Paul E. McKenney486e2592012-01-06 14:11:30 -0800135 seq_printf(m, " ql=%ld/%ld qs=%c%c%c%c",
Paul E. McKenney3fbfbf72012-08-19 21:35:53 -0700136 qll, ql,
Paul E. McKenney0ac3d132011-03-28 15:47:07 -0700137 ".N"[rdp->nxttail[RCU_NEXT_READY_TAIL] !=
138 rdp->nxttail[RCU_NEXT_TAIL]],
139 ".R"[rdp->nxttail[RCU_WAIT_TAIL] !=
140 rdp->nxttail[RCU_NEXT_READY_TAIL]],
141 ".W"[rdp->nxttail[RCU_DONE_TAIL] !=
142 rdp->nxttail[RCU_WAIT_TAIL]],
Paul E. McKenneya46e0892011-06-15 15:47:09 -0700143 ".D"[&rdp->nxtlist != rdp->nxttail[RCU_DONE_TAIL]]);
144#ifdef CONFIG_RCU_BOOST
Paul E. McKenney62ab7072012-07-16 10:42:38 +0000145 seq_printf(m, " kt=%d/%c ktl=%x",
Paul E. McKenneyd71df902011-03-29 17:48:28 -0700146 per_cpu(rcu_cpu_has_work, rdp->cpu),
147 convert_kthread_status(per_cpu(rcu_cpu_kthread_status,
148 rdp->cpu)),
Paul E. McKenneya46e0892011-06-15 15:47:09 -0700149 per_cpu(rcu_cpu_kthread_loops, rdp->cpu) & 0xffff);
150#endif /* #ifdef CONFIG_RCU_BOOST */
151 seq_printf(m, " b=%ld", rdp->blimit);
Paul E. McKenneyc635a4e12012-10-29 07:29:20 -0700152 seq_printf(m, " ci=%lu nci=%lu co=%lu ca=%lu\n",
153 rdp->n_cbs_invoked, rdp->n_nocbs_invoked,
154 rdp->n_cbs_orphaned, rdp->n_cbs_adopted);
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100155}
156
Michael Wangc011c412012-09-20 08:51:07 +0800157static int show_rcudata(struct seq_file *m, void *v)
Michael Wang878eda72012-09-20 08:51:04 +0800158{
159 print_one_rcu_data(m, (struct rcu_data *)v);
160 return 0;
161}
162
Michael Wangc011c412012-09-20 08:51:07 +0800163static const struct seq_operations rcudate_op = {
Michael Wang878eda72012-09-20 08:51:04 +0800164 .start = r_start,
165 .next = r_next,
166 .stop = r_stop,
Michael Wangc011c412012-09-20 08:51:07 +0800167 .show = show_rcudata,
Michael Wang878eda72012-09-20 08:51:04 +0800168};
169
Michael Wangc011c412012-09-20 08:51:07 +0800170static int rcudata_open(struct inode *inode, struct file *file)
Michael Wang878eda72012-09-20 08:51:04 +0800171{
Michael Wangc011c412012-09-20 08:51:07 +0800172 return r_open(inode, file, &rcudate_op);
Michael Wang878eda72012-09-20 08:51:04 +0800173}
174
Michael Wangc011c412012-09-20 08:51:07 +0800175static const struct file_operations rcudata_fops = {
Michael Wang878eda72012-09-20 08:51:04 +0800176 .owner = THIS_MODULE,
Michael Wangc011c412012-09-20 08:51:07 +0800177 .open = rcudata_open,
Michael Wang878eda72012-09-20 08:51:04 +0800178 .read = seq_read,
179 .llseek = no_llseek,
180 .release = seq_release,
181};
182
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700183static int show_rcuexp(struct seq_file *m, void *v)
184{
Paul E. McKenneydf5bd512015-10-01 10:26:24 -0700185 int cpu;
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700186 struct rcu_state *rsp = (struct rcu_state *)m->private;
Paul E. McKenneydf5bd512015-10-01 10:26:24 -0700187 struct rcu_data *rdp;
Paul E. McKenney8b355e32016-06-29 13:46:25 -0700188 unsigned long s0 = 0, s1 = 0, s2 = 0, s3 = 0;
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700189
Paul E. McKenneydf5bd512015-10-01 10:26:24 -0700190 for_each_possible_cpu(cpu) {
191 rdp = per_cpu_ptr(rsp->rda, cpu);
Paul E. McKenney8b355e32016-06-29 13:46:25 -0700192 s0 += atomic_long_read(&rdp->exp_workdone0);
Paul E. McKenneyd40a4f02016-03-08 14:43:44 -0800193 s1 += atomic_long_read(&rdp->exp_workdone1);
194 s2 += atomic_long_read(&rdp->exp_workdone2);
195 s3 += atomic_long_read(&rdp->exp_workdone3);
Paul E. McKenneydf5bd512015-10-01 10:26:24 -0700196 }
Paul E. McKenney8b355e32016-06-29 13:46:25 -0700197 seq_printf(m, "s=%lu wd0=%lu wd1=%lu wd2=%lu wd3=%lu n=%lu enq=%d sc=%lu\n",
198 rsp->expedited_sequence, s0, s1, s2, s3,
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700199 atomic_long_read(&rsp->expedited_normal),
Peter Zijlstra3a6d7c62015-06-25 11:27:10 -0700200 atomic_read(&rsp->expedited_need_qs),
Paul E. McKenneyd6ada2c2015-06-24 10:46:30 -0700201 rsp->expedited_sequence / 2);
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700202 return 0;
203}
204
205static int rcuexp_open(struct inode *inode, struct file *file)
206{
207 return single_open(file, show_rcuexp, inode->i_private);
208}
209
210static const struct file_operations rcuexp_fops = {
211 .owner = THIS_MODULE,
212 .open = rcuexp_open,
213 .read = seq_read,
214 .llseek = no_llseek,
Al Viro7ee2b9e2013-05-05 00:16:35 -0400215 .release = single_release,
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700216};
217
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800218#ifdef CONFIG_RCU_BOOST
219
220static void print_one_rcu_node_boost(struct seq_file *m, struct rcu_node *rnp)
221{
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700222 seq_printf(m, "%d:%d tasks=%c%c%c%c kt=%c ntb=%lu neb=%lu nnb=%lu ",
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800223 rnp->grplo, rnp->grphi,
224 "T."[list_empty(&rnp->blkd_tasks)],
225 "N."[!rnp->gp_tasks],
226 "E."[!rnp->exp_tasks],
227 "B."[!rnp->boost_tasks],
Paul E. McKenneyd71df902011-03-29 17:48:28 -0700228 convert_kthread_status(rnp->boost_kthread_status),
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800229 rnp->n_tasks_boosted, rnp->n_exp_boosts,
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700230 rnp->n_normal_boosts);
231 seq_printf(m, "j=%04x bt=%04x\n",
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800232 (int)(jiffies & 0xffff),
233 (int)(rnp->boost_time & 0xffff));
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700234 seq_printf(m, " balk: nt=%lu egt=%lu bt=%lu nb=%lu ny=%lu nos=%lu\n",
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800235 rnp->n_balk_blkd_tasks,
236 rnp->n_balk_exp_gp_tasks,
237 rnp->n_balk_boost_tasks,
238 rnp->n_balk_notblocked,
239 rnp->n_balk_notyet,
240 rnp->n_balk_nos);
241}
242
243static int show_rcu_node_boost(struct seq_file *m, void *unused)
244{
245 struct rcu_node *rnp;
246
247 rcu_for_each_leaf_node(&rcu_preempt_state, rnp)
248 print_one_rcu_node_boost(m, rnp);
249 return 0;
250}
251
252static int rcu_node_boost_open(struct inode *inode, struct file *file)
253{
254 return single_open(file, show_rcu_node_boost, NULL);
255}
256
257static const struct file_operations rcu_node_boost_fops = {
258 .owner = THIS_MODULE,
259 .open = rcu_node_boost_open,
260 .read = seq_read,
Michael Wang29c67762012-10-08 16:59:17 +0800261 .llseek = no_llseek,
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800262 .release = single_release,
263};
264
Michael Wang6ee08862012-10-11 14:26:42 -0700265#endif /* #ifdef CONFIG_RCU_BOOST */
Paul E. McKenney0ea1f2e2011-02-22 13:42:43 -0800266
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100267static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp)
268{
Paul E. McKenney20133cf2010-02-22 17:05:01 -0800269 unsigned long gpnum;
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100270 int level = 0;
271 struct rcu_node *rnp;
272
Paul E. McKenney3397e042009-10-14 16:36:38 -0700273 gpnum = rsp->gpnum;
Michael Wang6ee08862012-10-11 14:26:42 -0700274 seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x ",
275 ulong2long(rsp->completed), ulong2long(gpnum),
Petr Mladek77f81fe2015-09-09 12:09:49 -0700276 rsp->gp_state,
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100277 (long)(rsp->jiffies_force_qs - jiffies),
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700278 (int)(jiffies & 0xffff));
279 seq_printf(m, "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld/%ld\n",
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100280 rsp->n_force_qs, rsp->n_force_qs_ngp,
281 rsp->n_force_qs - rsp->n_force_qs_ngp,
Paul E. McKenney7d0ae802015-03-03 14:57:58 -0800282 READ_ONCE(rsp->n_force_qs_lh), rsp->qlen_lazy, rsp->qlen);
Paul E. McKenneyf885b7f2012-04-23 15:52:53 -0700283 for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < rcu_num_nodes; rnp++) {
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100284 if (rnp->level != level) {
285 seq_puts(m, "\n");
286 level = rnp->level;
287 }
Paul E. McKenney0aa04b02015-01-23 21:52:37 -0800288 seq_printf(m, "%lx/%lx->%lx %c%c>%c %d:%d ^%d ",
289 rnp->qsmask, rnp->qsmaskinit, rnp->qsmaskinitnext,
Paul E. McKenney12f5f522010-11-29 21:56:39 -0800290 ".G"[rnp->gp_tasks != NULL],
291 ".E"[rnp->exp_tasks != NULL],
292 ".T"[!list_empty(&rnp->blkd_tasks)],
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100293 rnp->grplo, rnp->grphi, rnp->grpnum);
294 }
295 seq_puts(m, "\n");
296}
297
Michael Wang6ee08862012-10-11 14:26:42 -0700298static int show_rcuhier(struct seq_file *m, void *v)
Michael Wanga608d842012-10-08 16:59:19 +0800299{
300 struct rcu_state *rsp = (struct rcu_state *)m->private;
301 print_one_rcu_state(m, rsp);
302 return 0;
303}
304
Michael Wang6ee08862012-10-11 14:26:42 -0700305static int rcuhier_open(struct inode *inode, struct file *file)
Michael Wanga608d842012-10-08 16:59:19 +0800306{
Michael Wang6ee08862012-10-11 14:26:42 -0700307 return single_open(file, show_rcuhier, inode->i_private);
Michael Wanga608d842012-10-08 16:59:19 +0800308}
309
Michael Wang6ee08862012-10-11 14:26:42 -0700310static const struct file_operations rcuhier_fops = {
Michael Wanga608d842012-10-08 16:59:19 +0800311 .owner = THIS_MODULE,
Michael Wang6ee08862012-10-11 14:26:42 -0700312 .open = rcuhier_open,
Michael Wanga608d842012-10-08 16:59:19 +0800313 .read = seq_read,
314 .llseek = no_llseek,
Al Viro7ee2b9e2013-05-05 00:16:35 -0400315 .release = single_release,
Michael Wanga608d842012-10-08 16:59:19 +0800316};
317
Paul E. McKenney15ba0ba2011-04-06 16:01:16 -0700318static void show_one_rcugp(struct seq_file *m, struct rcu_state *rsp)
319{
320 unsigned long flags;
321 unsigned long completed;
322 unsigned long gpnum;
323 unsigned long gpage;
324 unsigned long gpmax;
325 struct rcu_node *rnp = &rsp->node[0];
326
Paul E. McKenney6cf10082015-10-08 15:36:54 -0700327 raw_spin_lock_irqsave_rcu_node(rnp, flags);
Paul E. McKenney7d0ae802015-03-03 14:57:58 -0800328 completed = READ_ONCE(rsp->completed);
329 gpnum = READ_ONCE(rsp->gpnum);
Paul E. McKenney42c35332012-09-28 10:49:58 -0700330 if (completed == gpnum)
Paul E. McKenney15ba0ba2011-04-06 16:01:16 -0700331 gpage = 0;
332 else
333 gpage = jiffies - rsp->gp_start;
334 gpmax = rsp->gp_max;
335 raw_spin_unlock_irqrestore(&rnp->lock, flags);
Michael Wang6ee08862012-10-11 14:26:42 -0700336 seq_printf(m, "completed=%ld gpnum=%ld age=%ld max=%ld\n",
337 ulong2long(completed), ulong2long(gpnum), gpage, gpmax);
Paul E. McKenney15ba0ba2011-04-06 16:01:16 -0700338}
339
Michael Wang6ee08862012-10-11 14:26:42 -0700340static int show_rcugp(struct seq_file *m, void *v)
Michael Wang66b38bc2012-10-08 16:59:18 +0800341{
342 struct rcu_state *rsp = (struct rcu_state *)m->private;
343 show_one_rcugp(m, rsp);
344 return 0;
345}
346
Michael Wang6ee08862012-10-11 14:26:42 -0700347static int rcugp_open(struct inode *inode, struct file *file)
Michael Wang66b38bc2012-10-08 16:59:18 +0800348{
Michael Wang6ee08862012-10-11 14:26:42 -0700349 return single_open(file, show_rcugp, inode->i_private);
Michael Wang66b38bc2012-10-08 16:59:18 +0800350}
351
Michael Wang6ee08862012-10-11 14:26:42 -0700352static const struct file_operations rcugp_fops = {
Michael Wang66b38bc2012-10-08 16:59:18 +0800353 .owner = THIS_MODULE,
Michael Wang6ee08862012-10-11 14:26:42 -0700354 .open = rcugp_open,
Michael Wang66b38bc2012-10-08 16:59:18 +0800355 .read = seq_read,
356 .llseek = no_llseek,
Al Viro7ee2b9e2013-05-05 00:16:35 -0400357 .release = single_release,
Michael Wang66b38bc2012-10-08 16:59:18 +0800358};
359
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700360static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
361{
Michael Wang51d0f162012-09-20 08:51:06 +0800362 if (!rdp->beenonline)
363 return;
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700364 seq_printf(m, "%3d%cnp=%ld ",
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700365 rdp->cpu,
366 cpu_is_offline(rdp->cpu) ? '!' : ' ',
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700367 rdp->n_rcu_pending);
368 seq_printf(m, "qsp=%ld rpq=%ld cbr=%ld cng=%ld ",
Paul E. McKenney97c668b2015-08-06 11:31:51 -0700369 rdp->n_rp_core_needs_qs,
Paul E. McKenneyd21670a2010-04-14 17:39:26 -0700370 rdp->n_rp_report_qs,
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700371 rdp->n_rp_cb_ready,
Paul E. McKenney5cf05ad2012-05-17 15:12:45 -0700372 rdp->n_rp_cpu_needs_gp);
Paul E. McKenney96d3fd02013-10-04 14:33:34 -0700373 seq_printf(m, "gpc=%ld gps=%ld nn=%ld ndw%ld\n",
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700374 rdp->n_rp_gp_completed,
375 rdp->n_rp_gp_started,
Paul E. McKenney96d3fd02013-10-04 14:33:34 -0700376 rdp->n_rp_nocb_defer_wakeup,
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700377 rdp->n_rp_need_nothing);
378}
379
Michael Wangc011c412012-09-20 08:51:07 +0800380static int show_rcu_pending(struct seq_file *m, void *v)
Michael Wang51d0f162012-09-20 08:51:06 +0800381{
382 print_one_rcu_pending(m, (struct rcu_data *)v);
383 return 0;
384}
385
Michael Wangc011c412012-09-20 08:51:07 +0800386static const struct seq_operations rcu_pending_op = {
Michael Wang51d0f162012-09-20 08:51:06 +0800387 .start = r_start,
388 .next = r_next,
389 .stop = r_stop,
Michael Wangc011c412012-09-20 08:51:07 +0800390 .show = show_rcu_pending,
Michael Wang51d0f162012-09-20 08:51:06 +0800391};
392
Michael Wangc011c412012-09-20 08:51:07 +0800393static int rcu_pending_open(struct inode *inode, struct file *file)
Michael Wang51d0f162012-09-20 08:51:06 +0800394{
Michael Wangc011c412012-09-20 08:51:07 +0800395 return r_open(inode, file, &rcu_pending_op);
Michael Wang51d0f162012-09-20 08:51:06 +0800396}
397
Michael Wangc011c412012-09-20 08:51:07 +0800398static const struct file_operations rcu_pending_fops = {
Michael Wang51d0f162012-09-20 08:51:06 +0800399 .owner = THIS_MODULE,
Michael Wangc011c412012-09-20 08:51:07 +0800400 .open = rcu_pending_open,
Michael Wang51d0f162012-09-20 08:51:06 +0800401 .read = seq_read,
402 .llseek = no_llseek,
403 .release = seq_release,
404};
405
Paul E. McKenney4a298652011-04-03 21:33:51 -0700406static int show_rcutorture(struct seq_file *m, void *unused)
407{
408 seq_printf(m, "rcutorture test sequence: %lu %s\n",
409 rcutorture_testseq >> 1,
410 (rcutorture_testseq & 0x1) ? "(test in progress)" : "");
411 seq_printf(m, "rcutorture update version number: %lu\n",
412 rcutorture_vernum);
413 return 0;
414}
415
416static int rcutorture_open(struct inode *inode, struct file *file)
417{
418 return single_open(file, show_rcutorture, NULL);
419}
420
421static const struct file_operations rcutorture_fops = {
422 .owner = THIS_MODULE,
423 .open = rcutorture_open,
424 .read = seq_read,
425 .llseek = seq_lseek,
426 .release = single_release,
427};
428
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700429static struct dentry *rcudir;
Paul E. McKenney7ba5c842009-04-13 21:31:17 -0700430
Paul E. McKenneydeb7a412010-09-30 21:33:32 -0700431static int __init rcutree_trace_init(void)
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100432{
Michael Wang573bcd402012-09-20 08:51:02 +0800433 struct rcu_state *rsp;
Paul E. McKenney22f00b62009-08-22 13:56:50 -0700434 struct dentry *retval;
Michael Wang573bcd402012-09-20 08:51:02 +0800435 struct dentry *rspdir;
Paul E. McKenney22f00b62009-08-22 13:56:50 -0700436
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100437 rcudir = debugfs_create_dir("rcu", NULL);
438 if (!rcudir)
Paul E. McKenney22f00b62009-08-22 13:56:50 -0700439 goto free_out;
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100440
Michael Wang573bcd402012-09-20 08:51:02 +0800441 for_each_rcu_flavor(rsp) {
442 rspdir = debugfs_create_dir(rsp->name, rcudir);
443 if (!rspdir)
444 goto free_out;
Michael Wang878eda72012-09-20 08:51:04 +0800445
Michael Wang6ee08862012-10-11 14:26:42 -0700446 retval = debugfs_create_file("rcudata", 0444,
447 rspdir, rsp, &rcudata_fops);
448 if (!retval)
449 goto free_out;
Michael Wangd29200e2012-09-20 08:51:05 +0800450
Paul E. McKenney7bd8f2a2012-10-11 17:14:32 -0700451 retval = debugfs_create_file("rcuexp", 0444,
452 rspdir, rsp, &rcuexp_fops);
453 if (!retval)
454 goto free_out;
455
Michael Wang6ee08862012-10-11 14:26:42 -0700456 retval = debugfs_create_file("rcu_pending", 0444,
457 rspdir, rsp, &rcu_pending_fops);
458 if (!retval)
459 goto free_out;
Michael Wangc25e5572012-10-08 16:59:16 +0800460
Michael Wang6ee08862012-10-11 14:26:42 -0700461 retval = debugfs_create_file("rcubarrier", 0444,
462 rspdir, rsp, &rcubarrier_fops);
463 if (!retval)
464 goto free_out;
Michael Wang29c67762012-10-08 16:59:17 +0800465
466#ifdef CONFIG_RCU_BOOST
Michael Wang6ee08862012-10-11 14:26:42 -0700467 if (rsp == &rcu_preempt_state) {
468 retval = debugfs_create_file("rcuboost", 0444,
469 rspdir, NULL, &rcu_node_boost_fops);
470 if (!retval)
471 goto free_out;
472 }
Michael Wang29c67762012-10-08 16:59:17 +0800473#endif
Michael Wang66b38bc2012-10-08 16:59:18 +0800474
Michael Wang6ee08862012-10-11 14:26:42 -0700475 retval = debugfs_create_file("rcugp", 0444,
476 rspdir, rsp, &rcugp_fops);
477 if (!retval)
478 goto free_out;
Michael Wang66b38bc2012-10-08 16:59:18 +0800479
Michael Wang6ee08862012-10-11 14:26:42 -0700480 retval = debugfs_create_file("rcuhier", 0444,
481 rspdir, rsp, &rcuhier_fops);
482 if (!retval)
483 goto free_out;
Michael Wang573bcd402012-09-20 08:51:02 +0800484 }
485
Paul E. McKenney4a298652011-04-03 21:33:51 -0700486 retval = debugfs_create_file("rcutorture", 0444, rcudir,
487 NULL, &rcutorture_fops);
488 if (!retval)
489 goto free_out;
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100490 return 0;
491free_out:
Paul E. McKenney22f00b62009-08-22 13:56:50 -0700492 debugfs_remove_recursive(rcudir);
Paul E. McKenney64db4cf2008-12-18 21:55:32 +0100493 return 1;
494}
Paul Gortmaker47dbc902015-09-27 19:14:57 -0400495device_initcall(rcutree_trace_init);