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 | ||
6258c4fb IM |
46 | #include "rcutree.h" |
47 | ||
64db4cff PM |
48 | static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp) |
49 | { | |
50 | if (!rdp->beenonline) | |
51 | return; | |
52 | seq_printf(m, "%3d%cc=%ld g=%ld pq=%d pqc=%ld qp=%d rpfq=%ld rp=%x", | |
53 | rdp->cpu, | |
54 | cpu_is_offline(rdp->cpu) ? '!' : ' ', | |
55 | rdp->completed, rdp->gpnum, | |
56 | rdp->passed_quiesc, rdp->passed_quiesc_completed, | |
57 | rdp->qs_pending, | |
58 | rdp->n_rcu_pending_force_qs - rdp->n_rcu_pending, | |
59 | (int)(rdp->n_rcu_pending & 0xffff)); | |
60 | #ifdef CONFIG_NO_HZ | |
61 | seq_printf(m, " dt=%d/%d dn=%d df=%lu", | |
62 | rdp->dynticks->dynticks, | |
63 | rdp->dynticks->dynticks_nesting, | |
64 | rdp->dynticks->dynticks_nmi, | |
65 | rdp->dynticks_fqs); | |
66 | #endif /* #ifdef CONFIG_NO_HZ */ | |
67 | seq_printf(m, " of=%lu ri=%lu", rdp->offline_fqs, rdp->resched_ipi); | |
68 | seq_printf(m, " ql=%ld b=%ld\n", rdp->qlen, rdp->blimit); | |
69 | } | |
70 | ||
71 | #define PRINT_RCU_DATA(name, func, m) \ | |
72 | do { \ | |
73 | int _p_r_d_i; \ | |
74 | \ | |
75 | for_each_possible_cpu(_p_r_d_i) \ | |
76 | func(m, &per_cpu(name, _p_r_d_i)); \ | |
77 | } while (0) | |
78 | ||
79 | static int show_rcudata(struct seq_file *m, void *unused) | |
80 | { | |
81 | seq_puts(m, "rcu:\n"); | |
82 | PRINT_RCU_DATA(rcu_data, print_one_rcu_data, m); | |
83 | seq_puts(m, "rcu_bh:\n"); | |
84 | PRINT_RCU_DATA(rcu_bh_data, print_one_rcu_data, m); | |
85 | return 0; | |
86 | } | |
87 | ||
88 | static int rcudata_open(struct inode *inode, struct file *file) | |
89 | { | |
90 | return single_open(file, show_rcudata, NULL); | |
91 | } | |
92 | ||
93 | static struct file_operations rcudata_fops = { | |
94 | .owner = THIS_MODULE, | |
95 | .open = rcudata_open, | |
96 | .read = seq_read, | |
97 | .llseek = seq_lseek, | |
98 | .release = single_release, | |
99 | }; | |
100 | ||
101 | static void print_one_rcu_data_csv(struct seq_file *m, struct rcu_data *rdp) | |
102 | { | |
103 | if (!rdp->beenonline) | |
104 | return; | |
105 | seq_printf(m, "%d,%s,%ld,%ld,%d,%ld,%d,%ld,%ld", | |
106 | rdp->cpu, | |
107 | cpu_is_offline(rdp->cpu) ? "\"Y\"" : "\"N\"", | |
108 | rdp->completed, rdp->gpnum, | |
109 | rdp->passed_quiesc, rdp->passed_quiesc_completed, | |
110 | rdp->qs_pending, | |
111 | rdp->n_rcu_pending_force_qs - rdp->n_rcu_pending, | |
112 | rdp->n_rcu_pending); | |
113 | #ifdef CONFIG_NO_HZ | |
114 | seq_printf(m, ",%d,%d,%d,%lu", | |
115 | rdp->dynticks->dynticks, | |
116 | rdp->dynticks->dynticks_nesting, | |
117 | rdp->dynticks->dynticks_nmi, | |
118 | rdp->dynticks_fqs); | |
119 | #endif /* #ifdef CONFIG_NO_HZ */ | |
120 | seq_printf(m, ",%lu,%lu", rdp->offline_fqs, rdp->resched_ipi); | |
121 | seq_printf(m, ",%ld,%ld\n", rdp->qlen, rdp->blimit); | |
122 | } | |
123 | ||
124 | static int show_rcudata_csv(struct seq_file *m, void *unused) | |
125 | { | |
126 | seq_puts(m, "\"CPU\",\"Online?\",\"c\",\"g\",\"pq\",\"pqc\",\"pq\",\"rpfq\",\"rp\","); | |
127 | #ifdef CONFIG_NO_HZ | |
128 | seq_puts(m, "\"dt\",\"dt nesting\",\"dn\",\"df\","); | |
129 | #endif /* #ifdef CONFIG_NO_HZ */ | |
130 | seq_puts(m, "\"of\",\"ri\",\"ql\",\"b\"\n"); | |
131 | seq_puts(m, "\"rcu:\"\n"); | |
132 | PRINT_RCU_DATA(rcu_data, print_one_rcu_data_csv, m); | |
133 | seq_puts(m, "\"rcu_bh:\"\n"); | |
134 | PRINT_RCU_DATA(rcu_bh_data, print_one_rcu_data_csv, m); | |
135 | return 0; | |
136 | } | |
137 | ||
138 | static int rcudata_csv_open(struct inode *inode, struct file *file) | |
139 | { | |
140 | return single_open(file, show_rcudata_csv, NULL); | |
141 | } | |
142 | ||
143 | static struct file_operations rcudata_csv_fops = { | |
144 | .owner = THIS_MODULE, | |
145 | .open = rcudata_csv_open, | |
146 | .read = seq_read, | |
147 | .llseek = seq_lseek, | |
148 | .release = single_release, | |
149 | }; | |
150 | ||
151 | static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp) | |
152 | { | |
153 | int level = 0; | |
154 | struct rcu_node *rnp; | |
155 | ||
156 | seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x " | |
157 | "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu\n", | |
158 | rsp->completed, rsp->gpnum, rsp->signaled, | |
159 | (long)(rsp->jiffies_force_qs - jiffies), | |
160 | (int)(jiffies & 0xffff), | |
161 | rsp->n_force_qs, rsp->n_force_qs_ngp, | |
162 | rsp->n_force_qs - rsp->n_force_qs_ngp, | |
163 | rsp->n_force_qs_lh); | |
164 | for (rnp = &rsp->node[0]; rnp - &rsp->node[0] < NUM_RCU_NODES; rnp++) { | |
165 | if (rnp->level != level) { | |
166 | seq_puts(m, "\n"); | |
167 | level = rnp->level; | |
168 | } | |
169 | seq_printf(m, "%lx/%lx %d:%d ^%d ", | |
170 | rnp->qsmask, rnp->qsmaskinit, | |
171 | rnp->grplo, rnp->grphi, rnp->grpnum); | |
172 | } | |
173 | seq_puts(m, "\n"); | |
174 | } | |
175 | ||
176 | static int show_rcuhier(struct seq_file *m, void *unused) | |
177 | { | |
178 | seq_puts(m, "rcu:\n"); | |
179 | print_one_rcu_state(m, &rcu_state); | |
180 | seq_puts(m, "rcu_bh:\n"); | |
181 | print_one_rcu_state(m, &rcu_bh_state); | |
182 | return 0; | |
183 | } | |
184 | ||
185 | static int rcuhier_open(struct inode *inode, struct file *file) | |
186 | { | |
187 | return single_open(file, show_rcuhier, NULL); | |
188 | } | |
189 | ||
190 | static struct file_operations rcuhier_fops = { | |
191 | .owner = THIS_MODULE, | |
192 | .open = rcuhier_open, | |
193 | .read = seq_read, | |
194 | .llseek = seq_lseek, | |
195 | .release = single_release, | |
196 | }; | |
197 | ||
198 | static int show_rcugp(struct seq_file *m, void *unused) | |
199 | { | |
200 | seq_printf(m, "rcu: completed=%ld gpnum=%ld\n", | |
201 | rcu_state.completed, rcu_state.gpnum); | |
202 | seq_printf(m, "rcu_bh: completed=%ld gpnum=%ld\n", | |
203 | rcu_bh_state.completed, rcu_bh_state.gpnum); | |
204 | return 0; | |
205 | } | |
206 | ||
207 | static int rcugp_open(struct inode *inode, struct file *file) | |
208 | { | |
209 | return single_open(file, show_rcugp, NULL); | |
210 | } | |
211 | ||
212 | static struct file_operations rcugp_fops = { | |
213 | .owner = THIS_MODULE, | |
214 | .open = rcugp_open, | |
215 | .read = seq_read, | |
216 | .llseek = seq_lseek, | |
217 | .release = single_release, | |
218 | }; | |
219 | ||
220 | static struct dentry *rcudir, *datadir, *datadir_csv, *hierdir, *gpdir; | |
221 | static int __init rcuclassic_trace_init(void) | |
222 | { | |
223 | rcudir = debugfs_create_dir("rcu", NULL); | |
224 | if (!rcudir) | |
225 | goto out; | |
226 | ||
227 | datadir = debugfs_create_file("rcudata", 0444, rcudir, | |
228 | NULL, &rcudata_fops); | |
229 | if (!datadir) | |
230 | goto free_out; | |
231 | ||
232 | datadir_csv = debugfs_create_file("rcudata.csv", 0444, rcudir, | |
233 | NULL, &rcudata_csv_fops); | |
234 | if (!datadir_csv) | |
235 | goto free_out; | |
236 | ||
237 | gpdir = debugfs_create_file("rcugp", 0444, rcudir, NULL, &rcugp_fops); | |
238 | if (!gpdir) | |
239 | goto free_out; | |
240 | ||
241 | hierdir = debugfs_create_file("rcuhier", 0444, rcudir, | |
242 | NULL, &rcuhier_fops); | |
243 | if (!hierdir) | |
244 | goto free_out; | |
245 | return 0; | |
246 | free_out: | |
247 | if (datadir) | |
248 | debugfs_remove(datadir); | |
249 | if (datadir_csv) | |
250 | debugfs_remove(datadir_csv); | |
251 | if (gpdir) | |
252 | debugfs_remove(gpdir); | |
253 | debugfs_remove(rcudir); | |
254 | out: | |
255 | return 1; | |
256 | } | |
257 | ||
258 | static void __exit rcuclassic_trace_cleanup(void) | |
259 | { | |
260 | debugfs_remove(datadir); | |
261 | debugfs_remove(datadir_csv); | |
262 | debugfs_remove(gpdir); | |
263 | debugfs_remove(hierdir); | |
264 | debugfs_remove(rcudir); | |
265 | } | |
266 | ||
267 | ||
268 | module_init(rcuclassic_trace_init); | |
269 | module_exit(rcuclassic_trace_cleanup); | |
270 | ||
271 | MODULE_AUTHOR("Paul E. McKenney"); | |
272 | MODULE_DESCRIPTION("Read-Copy Update tracing for hierarchical implementation"); | |
273 | MODULE_LICENSE("GPL"); |