Commit | Line | Data |
---|---|---|
64db4cff PM |
1 | /* |
2 | * Read-Copy Update tracing for classic implementation | |
3 | * | |
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 | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | * | |
18 | * Copyright IBM Corporation, 2008 | |
19 | * | |
20 | * Papers: http://www.rdrop.com/users/paulmck/RCU | |
21 | * | |
22 | * For detailed explanation of Read-Copy Update mechanism see - | |
23 | * Documentation/RCU | |
24 | * | |
25 | */ | |
26 | #include <linux/types.h> | |
27 | #include <linux/kernel.h> | |
28 | #include <linux/init.h> | |
29 | #include <linux/spinlock.h> | |
30 | #include <linux/smp.h> | |
31 | #include <linux/rcupdate.h> | |
32 | #include <linux/interrupt.h> | |
33 | #include <linux/sched.h> | |
34 | #include <asm/atomic.h> | |
35 | #include <linux/bitops.h> | |
36 | #include <linux/module.h> | |
37 | #include <linux/completion.h> | |
38 | #include <linux/moduleparam.h> | |
39 | #include <linux/percpu.h> | |
40 | #include <linux/notifier.h> | |
41 | #include <linux/cpu.h> | |
42 | #include <linux/mutex.h> | |
43 | #include <linux/debugfs.h> | |
44 | #include <linux/seq_file.h> | |
45 | ||
9f77da9f | 46 | #define RCU_TREE_NONCORE |
6258c4fb IM |
47 | #include "rcutree.h" |
48 | ||
64db4cff PM |
49 | static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp) |
50 | { | |
51 | if (!rdp->beenonline) | |
52 | return; | |
ef631b0c | 53 | seq_printf(m, "%3d%cc=%ld g=%ld pq=%d pqc=%ld qp=%d", |
64db4cff PM |
54 | rdp->cpu, |
55 | cpu_is_offline(rdp->cpu) ? '!' : ' ', | |
56 | rdp->completed, rdp->gpnum, | |
57 | rdp->passed_quiesc, rdp->passed_quiesc_completed, | |
ef631b0c | 58 | rdp->qs_pending); |
64db4cff PM |
59 | #ifdef CONFIG_NO_HZ |
60 | seq_printf(m, " dt=%d/%d dn=%d df=%lu", | |
61 | rdp->dynticks->dynticks, | |
62 | rdp->dynticks->dynticks_nesting, | |
63 | rdp->dynticks->dynticks_nmi, | |
64 | rdp->dynticks_fqs); | |
65 | #endif /* #ifdef CONFIG_NO_HZ */ | |
66 | seq_printf(m, " of=%lu ri=%lu", rdp->offline_fqs, rdp->resched_ipi); | |
67 | seq_printf(m, " ql=%ld b=%ld\n", rdp->qlen, rdp->blimit); | |
68 | } | |
69 | ||
70 | #define PRINT_RCU_DATA(name, func, m) \ | |
71 | do { \ | |
72 | int _p_r_d_i; \ | |
73 | \ | |
74 | for_each_possible_cpu(_p_r_d_i) \ | |
75 | func(m, &per_cpu(name, _p_r_d_i)); \ | |
76 | } while (0) | |
77 | ||
78 | static int show_rcudata(struct seq_file *m, void *unused) | |
79 | { | |
d6714c22 PM |
80 | seq_puts(m, "rcu_sched:\n"); |
81 | PRINT_RCU_DATA(rcu_sched_data, print_one_rcu_data, m); | |
64db4cff PM |
82 | seq_puts(m, "rcu_bh:\n"); |
83 | PRINT_RCU_DATA(rcu_bh_data, print_one_rcu_data, m); | |
84 | return 0; | |
85 | } | |
86 | ||
87 | static int rcudata_open(struct inode *inode, struct file *file) | |
88 | { | |
89 | return single_open(file, show_rcudata, NULL); | |
90 | } | |
91 | ||
92 | static struct file_operations rcudata_fops = { | |
93 | .owner = THIS_MODULE, | |
94 | .open = rcudata_open, | |
95 | .read = seq_read, | |
96 | .llseek = seq_lseek, | |
97 | .release = single_release, | |
98 | }; | |
99 | ||
100 | static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp) | |
101 | { | |
102 | if (!rdp->beenonline) | |
103 | return; | |
ef631b0c | 104 | seq_printf(m, "%d,%s,%ld,%ld,%d,%ld,%d", |
64db4cff | 105 | rdp->cpu, |
5699ed8f | 106 | cpu_is_offline(rdp->cpu) ? "\"N\"" : "\"Y\"", |
64db4cff PM |
107 | rdp->completed, rdp->gpnum, |
108 | rdp->passed_quiesc, rdp->passed_quiesc_completed, | |
ef631b0c | 109 | rdp->qs_pending); |
64db4cff PM |
110 | #ifdef CONFIG_NO_HZ |
111 | seq_printf(m, ",%d,%d,%d,%lu", | |
112 | rdp->dynticks->dynticks, | |
113 | rdp->dynticks->dynticks_nesting, | |
114 | rdp->dynticks->dynticks_nmi, | |
115 | rdp->dynticks_fqs); | |
116 | #endif /* #ifdef CONFIG_NO_HZ */ | |
117 | seq_printf(m, ",%lu,%lu", rdp->offline_fqs, rdp->resched_ipi); | |
118 | seq_printf(m, ",%ld,%ld\n", rdp->qlen, rdp->blimit); | |
119 | } | |
120 | ||
121 | static int show_rcudata_csv(struct seq_file *m, void *unused) | |
122 | { | |
ef631b0c | 123 | seq_puts(m, "\"CPU\",\"Online?\",\"c\",\"g\",\"pq\",\"pqc\",\"pq\","); |
64db4cff PM |
124 | #ifdef CONFIG_NO_HZ |
125 | seq_puts(m, "\"dt\",\"dt nesting\",\"dn\",\"df\","); | |
126 | #endif /* #ifdef CONFIG_NO_HZ */ | |
127 | seq_puts(m, "\"of\",\"ri\",\"ql\",\"b\"\n"); | |
d6714c22 PM |
128 | seq_puts(m, "\"rcu_sched:\"\n"); |
129 | PRINT_RCU_DATA(rcu_sched_data, print_one_rcu_data_csv, m); | |
64db4cff PM |
130 | seq_puts(m, "\"rcu_bh:\"\n"); |
131 | PRINT_RCU_DATA(rcu_bh_data, print_one_rcu_data_csv, m); | |
132 | return 0; | |
133 | } | |
134 | ||
135 | static int rcudata_csv_open(struct inode *inode, struct file *file) | |
136 | { | |
137 | return single_open(file, show_rcudata_csv, NULL); | |
138 | } | |
139 | ||
140 | static struct file_operations rcudata_csv_fops = { | |
141 | .owner = THIS_MODULE, | |
142 | .open = rcudata_csv_open, | |
143 | .read = seq_read, | |
144 | .llseek = seq_lseek, | |
145 | .release = single_release, | |
146 | }; | |
147 | ||
148 | static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp) | |
149 | { | |
150 | int level = 0; | |
151 | struct rcu_node *rnp; | |
152 | ||
153 | seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x " | |
154 | "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu\n", | |
155 | rsp->completed, rsp->gpnum, rsp->signaled, | |
156 | (long)(rsp->jiffies_force_qs - jiffies), | |
157 | (int)(jiffies & 0xffff), | |
158 | rsp->n_force_qs, rsp->n_force_qs_ngp, | |
159 | rsp->n_force_qs - rsp->n_force_qs_ngp, | |
160 | rsp->n_force_qs_lh); | |
161 | for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < NUM_RCU_NODES; rnp++) { | |
162 | if (rnp->level != level) { | |
163 | seq_puts(m, "\n"); | |
164 | level = rnp->level; | |
165 | } | |
166 | seq_printf(m, "%lx/%lx %d:%d ^%d ", | |
167 | rnp->qsmask, rnp->qsmaskinit, | |
168 | rnp->grplo, rnp->grphi, rnp->grpnum); | |
169 | } | |
170 | seq_puts(m, "\n"); | |
171 | } | |
172 | ||
173 | static int show_rcuhier(struct seq_file *m, void *unused) | |
174 | { | |
d6714c22 PM |
175 | seq_puts(m, "rcu_sched:\n"); |
176 | print_one_rcu_state(m, &rcu_sched_state); | |
64db4cff PM |
177 | seq_puts(m, "rcu_bh:\n"); |
178 | print_one_rcu_state(m, &rcu_bh_state); | |
179 | return 0; | |
180 | } | |
181 | ||
182 | static int rcuhier_open(struct inode *inode, struct file *file) | |
183 | { | |
184 | return single_open(file, show_rcuhier, NULL); | |
185 | } | |
186 | ||
187 | static struct file_operations rcuhier_fops = { | |
188 | .owner = THIS_MODULE, | |
189 | .open = rcuhier_open, | |
190 | .read = seq_read, | |
191 | .llseek = seq_lseek, | |
192 | .release = single_release, | |
193 | }; | |
194 | ||
195 | static int show_rcugp(struct seq_file *m, void *unused) | |
196 | { | |
d6714c22 PM |
197 | seq_printf(m, "rcu_sched: completed=%ld gpnum=%ld\n", |
198 | rcu_sched_state.completed, rcu_sched_state.gpnum); | |
64db4cff PM |
199 | seq_printf(m, "rcu_bh: completed=%ld gpnum=%ld\n", |
200 | rcu_bh_state.completed, rcu_bh_state.gpnum); | |
201 | return 0; | |
202 | } | |
203 | ||
204 | static int rcugp_open(struct inode *inode, struct file *file) | |
205 | { | |
206 | return single_open(file, show_rcugp, NULL); | |
207 | } | |
208 | ||
209 | static struct file_operations rcugp_fops = { | |
210 | .owner = THIS_MODULE, | |
211 | .open = rcugp_open, | |
212 | .read = seq_read, | |
213 | .llseek = seq_lseek, | |
214 | .release = single_release, | |
215 | }; | |
216 | ||
7ba5c840 PM |
217 | static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp) |
218 | { | |
219 | seq_printf(m, "%3d%cnp=%ld " | |
220 | "qsp=%ld cbr=%ld cng=%ld gpc=%ld gps=%ld nf=%ld nn=%ld\n", | |
221 | rdp->cpu, | |
222 | cpu_is_offline(rdp->cpu) ? '!' : ' ', | |
223 | rdp->n_rcu_pending, | |
224 | rdp->n_rp_qs_pending, | |
225 | rdp->n_rp_cb_ready, | |
226 | rdp->n_rp_cpu_needs_gp, | |
227 | rdp->n_rp_gp_completed, | |
228 | rdp->n_rp_gp_started, | |
229 | rdp->n_rp_need_fqs, | |
230 | rdp->n_rp_need_nothing); | |
231 | } | |
232 | ||
233 | static void print_rcu_pendings(struct seq_file *m, struct rcu_state *rsp) | |
234 | { | |
235 | int cpu; | |
236 | struct rcu_data *rdp; | |
237 | ||
238 | for_each_possible_cpu(cpu) { | |
239 | rdp = rsp->rda[cpu]; | |
240 | if (rdp->beenonline) | |
241 | print_one_rcu_pending(m, rdp); | |
242 | } | |
243 | } | |
244 | ||
245 | static int show_rcu_pending(struct seq_file *m, void *unused) | |
246 | { | |
d6714c22 PM |
247 | seq_puts(m, "rcu_sched:\n"); |
248 | print_rcu_pendings(m, &rcu_sched_state); | |
7ba5c840 PM |
249 | seq_puts(m, "rcu_bh:\n"); |
250 | print_rcu_pendings(m, &rcu_bh_state); | |
251 | return 0; | |
252 | } | |
253 | ||
254 | static int rcu_pending_open(struct inode *inode, struct file *file) | |
255 | { | |
256 | return single_open(file, show_rcu_pending, NULL); | |
257 | } | |
258 | ||
259 | static struct file_operations rcu_pending_fops = { | |
260 | .owner = THIS_MODULE, | |
261 | .open = rcu_pending_open, | |
262 | .read = seq_read, | |
263 | .llseek = seq_lseek, | |
264 | .release = single_release, | |
265 | }; | |
266 | ||
267 | static struct dentry *rcudir; | |
7ba5c840 | 268 | |
64db4cff PM |
269 | static int __init rcuclassic_trace_init(void) |
270 | { | |
22f00b69 PM |
271 | struct dentry *retval; |
272 | ||
64db4cff PM |
273 | rcudir = debugfs_create_dir("rcu", NULL); |
274 | if (!rcudir) | |
22f00b69 | 275 | goto free_out; |
64db4cff | 276 | |
22f00b69 | 277 | retval = debugfs_create_file("rcudata", 0444, rcudir, |
64db4cff | 278 | NULL, &rcudata_fops); |
22f00b69 | 279 | if (!retval) |
64db4cff PM |
280 | goto free_out; |
281 | ||
22f00b69 | 282 | retval = debugfs_create_file("rcudata.csv", 0444, rcudir, |
64db4cff | 283 | NULL, &rcudata_csv_fops); |
22f00b69 | 284 | if (!retval) |
64db4cff PM |
285 | goto free_out; |
286 | ||
22f00b69 PM |
287 | retval = debugfs_create_file("rcugp", 0444, rcudir, NULL, &rcugp_fops); |
288 | if (!retval) | |
64db4cff PM |
289 | goto free_out; |
290 | ||
22f00b69 | 291 | retval = debugfs_create_file("rcuhier", 0444, rcudir, |
64db4cff | 292 | NULL, &rcuhier_fops); |
22f00b69 | 293 | if (!retval) |
64db4cff | 294 | goto free_out; |
7ba5c840 | 295 | |
22f00b69 | 296 | retval = debugfs_create_file("rcu_pending", 0444, rcudir, |
7ba5c840 | 297 | NULL, &rcu_pending_fops); |
22f00b69 | 298 | if (!retval) |
7ba5c840 | 299 | goto free_out; |
64db4cff PM |
300 | return 0; |
301 | free_out: | |
22f00b69 | 302 | debugfs_remove_recursive(rcudir); |
64db4cff PM |
303 | return 1; |
304 | } | |
305 | ||
306 | static void __exit rcuclassic_trace_cleanup(void) | |
307 | { | |
22f00b69 | 308 | debugfs_remove_recursive(rcudir); |
64db4cff PM |
309 | } |
310 | ||
311 | ||
312 | module_init(rcuclassic_trace_init); | |
313 | module_exit(rcuclassic_trace_cleanup); | |
314 | ||
315 | MODULE_AUTHOR("Paul E. McKenney"); | |
316 | MODULE_DESCRIPTION("Read-Copy Update tracing for hierarchical implementation"); | |
317 | MODULE_LICENSE("GPL"); |