blob: 4ad967453b6fb07a08a69534c8df6eebac1e2868 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Steven Rostedt1f0d69a2008-11-12 00:14:39 -05002/*
3 * unlikely profiler
4 *
5 * Copyright (C) 2008 Steven Rostedt <srostedt@redhat.com>
6 */
7#include <linux/kallsyms.h>
8#include <linux/seq_file.h>
9#include <linux/spinlock.h>
Frederic Weisbecker65c6dc62008-11-29 04:12:46 +010010#include <linux/irqflags.h>
Steven Rostedt1f0d69a2008-11-12 00:14:39 -050011#include <linux/uaccess.h>
12#include <linux/module.h>
13#include <linux/ftrace.h>
14#include <linux/hash.h>
15#include <linux/fs.h>
16#include <asm/local.h>
Steven Rostedtf633cef2008-12-23 23:24:13 -050017
Steven Rostedt1f0d69a2008-11-12 00:14:39 -050018#include "trace.h"
Frederic Weisbecker002bb862009-01-10 11:34:13 -080019#include "trace_stat.h"
Steven Rostedtf633cef2008-12-23 23:24:13 -050020#include "trace_output.h"
Steven Rostedt1f0d69a2008-11-12 00:14:39 -050021
Steven Rostedt2ed84ee2008-11-12 15:24:24 -050022#ifdef CONFIG_BRANCH_TRACER
Steven Rostedt52f232c2008-11-12 00:14:40 -050023
Frederic Weisbecker002bb862009-01-10 11:34:13 -080024static struct tracer branch_trace;
Steven Rostedt9f029e82008-11-12 15:24:24 -050025static int branch_tracing_enabled __read_mostly;
26static DEFINE_MUTEX(branch_tracing_mutex);
Frederic Weisbeckere302cf32008-12-27 23:25:38 +010027
Steven Rostedt9f029e82008-11-12 15:24:24 -050028static struct trace_array *branch_tracer;
Steven Rostedt52f232c2008-11-12 00:14:40 -050029
30static void
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -050031probe_likely_condition(struct ftrace_likely_data *f, int val, int expect)
Steven Rostedt52f232c2008-11-12 00:14:40 -050032{
Steven Rostedt (Red Hat)2425bcb2015-05-05 11:45:27 -040033 struct trace_event_call *call = &event_branch;
Steven Rostedt9f029e82008-11-12 15:24:24 -050034 struct trace_array *tr = branch_tracer;
Steven Rostedta7603ff2012-08-06 16:24:11 -040035 struct trace_array_cpu *data;
Steven Rostedt52f232c2008-11-12 00:14:40 -050036 struct ring_buffer_event *event;
Steven Rostedt9f029e82008-11-12 15:24:24 -050037 struct trace_branch *entry;
Steven Rostedt8f6e8a32009-10-07 21:53:41 -040038 struct ring_buffer *buffer;
Arnaldo Carvalho de Melo0a987752009-02-05 16:12:56 -020039 unsigned long flags;
Steven Rostedt (Red Hat)6224beb2015-07-07 15:05:03 -040040 int pc;
Steven Rostedt52f232c2008-11-12 00:14:40 -050041 const char *p;
42
Steven Rostedt (Red Hat)6224beb2015-07-07 15:05:03 -040043 if (current->trace_recursion & TRACE_BRANCH_BIT)
44 return;
45
Steven Rostedt52f232c2008-11-12 00:14:40 -050046 /*
47 * I would love to save just the ftrace_likely_data pointer, but
48 * this code can also be used by modules. Ugly things can happen
49 * if the module is unloaded, and then we go and read the
50 * pointer. This is slower, but much safer.
51 */
52
53 if (unlikely(!tr))
54 return;
55
Steven Rostedt (Red Hat)6224beb2015-07-07 15:05:03 -040056 raw_local_irq_save(flags);
57 current->trace_recursion |= TRACE_BRANCH_BIT;
58 data = this_cpu_ptr(tr->trace_buffer.data);
59 if (atomic_read(&data->disabled))
Steven Rostedt52f232c2008-11-12 00:14:40 -050060 goto out;
61
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -020062 pc = preempt_count();
Steven Rostedt (Red Hat)153e8ed2013-03-08 10:40:07 -050063 buffer = tr->trace_buffer.buffer;
Steven Rostedt8f6e8a32009-10-07 21:53:41 -040064 event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH,
Arnaldo Carvalho de Melo51a763d2009-02-05 16:14:13 -020065 sizeof(*entry), flags, pc);
Steven Rostedt52f232c2008-11-12 00:14:40 -050066 if (!event)
67 goto out;
68
Steven Rostedt52f232c2008-11-12 00:14:40 -050069 entry = ring_buffer_event_data(event);
Steven Rostedt52f232c2008-11-12 00:14:40 -050070
71 /* Strip off the path, only save the file */
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -050072 p = f->data.file + strlen(f->data.file);
73 while (p >= f->data.file && *p != '/')
Steven Rostedt52f232c2008-11-12 00:14:40 -050074 p--;
75 p++;
76
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -050077 strncpy(entry->func, f->data.func, TRACE_FUNC_SIZE);
Steven Rostedt52f232c2008-11-12 00:14:40 -050078 strncpy(entry->file, p, TRACE_FILE_SIZE);
79 entry->func[TRACE_FUNC_SIZE] = 0;
80 entry->file[TRACE_FILE_SIZE] = 0;
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -050081 entry->constant = f->constant;
82 entry->line = f->data.line;
Steven Rostedt52f232c2008-11-12 00:14:40 -050083 entry->correct = val == expect;
84
Tom Zanussif306cc82013-10-24 08:34:17 -050085 if (!call_filter_check_discard(call, entry, buffer, event))
Steven Rostedt (Red Hat)52ffabe32016-11-23 20:28:38 -050086 trace_buffer_unlock_commit_nostack(buffer, event);
Steven Rostedt52f232c2008-11-12 00:14:40 -050087
88 out:
Steven Rostedt (Red Hat)6224beb2015-07-07 15:05:03 -040089 current->trace_recursion &= ~TRACE_BRANCH_BIT;
90 raw_local_irq_restore(flags);
Steven Rostedt52f232c2008-11-12 00:14:40 -050091}
92
93static inline
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -050094void trace_likely_condition(struct ftrace_likely_data *f, int val, int expect)
Steven Rostedt52f232c2008-11-12 00:14:40 -050095{
Steven Rostedt9f029e82008-11-12 15:24:24 -050096 if (!branch_tracing_enabled)
Steven Rostedt52f232c2008-11-12 00:14:40 -050097 return;
98
99 probe_likely_condition(f, val, expect);
100}
101
Steven Rostedt9f029e82008-11-12 15:24:24 -0500102int enable_branch_tracing(struct trace_array *tr)
Steven Rostedt52f232c2008-11-12 00:14:40 -0500103{
Steven Rostedt9f029e82008-11-12 15:24:24 -0500104 mutex_lock(&branch_tracing_mutex);
105 branch_tracer = tr;
Steven Rostedt52f232c2008-11-12 00:14:40 -0500106 /*
107 * Must be seen before enabling. The reader is a condition
108 * where we do not need a matching rmb()
109 */
110 smp_wmb();
Steven Rostedt9f029e82008-11-12 15:24:24 -0500111 branch_tracing_enabled++;
112 mutex_unlock(&branch_tracing_mutex);
Steven Rostedt52f232c2008-11-12 00:14:40 -0500113
Wenji Huangf54fc982009-02-10 01:02:46 -0500114 return 0;
Steven Rostedt52f232c2008-11-12 00:14:40 -0500115}
116
Steven Rostedt9f029e82008-11-12 15:24:24 -0500117void disable_branch_tracing(void)
Steven Rostedt52f232c2008-11-12 00:14:40 -0500118{
Steven Rostedt9f029e82008-11-12 15:24:24 -0500119 mutex_lock(&branch_tracing_mutex);
Steven Rostedt52f232c2008-11-12 00:14:40 -0500120
Steven Rostedt9f029e82008-11-12 15:24:24 -0500121 if (!branch_tracing_enabled)
Steven Rostedt52f232c2008-11-12 00:14:40 -0500122 goto out_unlock;
123
Steven Rostedt9f029e82008-11-12 15:24:24 -0500124 branch_tracing_enabled--;
Steven Rostedt52f232c2008-11-12 00:14:40 -0500125
126 out_unlock:
Steven Rostedt9f029e82008-11-12 15:24:24 -0500127 mutex_unlock(&branch_tracing_mutex);
Steven Rostedt52f232c2008-11-12 00:14:40 -0500128}
Steven Rostedt80e5ea42008-11-12 15:24:24 -0500129
Frederic Weisbecker1c800252008-11-16 05:57:26 +0100130static int branch_trace_init(struct trace_array *tr)
Steven Rostedt80e5ea42008-11-12 15:24:24 -0500131{
Dmitry Safonov30616922015-10-16 16:04:49 +0300132 return enable_branch_tracing(tr);
Steven Rostedt80e5ea42008-11-12 15:24:24 -0500133}
134
135static void branch_trace_reset(struct trace_array *tr)
136{
Dmitry Safonov30616922015-10-16 16:04:49 +0300137 disable_branch_tracing();
Steven Rostedt80e5ea42008-11-12 15:24:24 -0500138}
139
Arnaldo Carvalho de Meloae7462b2009-02-03 22:05:50 -0200140static enum print_line_t trace_branch_print(struct trace_iterator *iter,
Steven Rostedta9a57762010-04-22 18:46:14 -0400141 int flags, struct trace_event *event)
Steven Rostedtf633cef2008-12-23 23:24:13 -0500142{
143 struct trace_branch *field;
144
Arnaldo Carvalho de Melo2c9b2382009-02-02 20:30:12 -0200145 trace_assign_type(field, iter->ent);
Steven Rostedtf633cef2008-12-23 23:24:13 -0500146
Steven Rostedt (Red Hat)7d40f672014-11-12 13:19:06 -0500147 trace_seq_printf(&iter->seq, "[%s] %s:%s:%d\n",
148 field->correct ? " ok " : " MISS ",
149 field->func,
150 field->file,
151 field->line);
Steven Rostedtf633cef2008-12-23 23:24:13 -0500152
Steven Rostedt (Red Hat)7d40f672014-11-12 13:19:06 -0500153 return trace_handle_return(&iter->seq);
Steven Rostedtf633cef2008-12-23 23:24:13 -0500154}
155
Zhaolei557055b2009-04-13 16:02:34 +0800156static void branch_print_header(struct seq_file *s)
157{
158 seq_puts(s, "# TASK-PID CPU# TIMESTAMP CORRECT"
Rasmus Villemoesd79ac282014-11-08 21:42:11 +0100159 " FUNC:FILE:LINE\n"
160 "# | | | | | "
161 " |\n");
Zhaolei557055b2009-04-13 16:02:34 +0800162}
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100163
Steven Rostedta9a57762010-04-22 18:46:14 -0400164static struct trace_event_functions trace_branch_funcs = {
165 .trace = trace_branch_print,
166};
167
Steven Rostedtf633cef2008-12-23 23:24:13 -0500168static struct trace_event trace_branch_event = {
Steven Rostedtef180122009-03-10 14:10:56 -0400169 .type = TRACE_BRANCH,
Steven Rostedta9a57762010-04-22 18:46:14 -0400170 .funcs = &trace_branch_funcs,
Steven Rostedtf633cef2008-12-23 23:24:13 -0500171};
172
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800173static struct tracer branch_trace __read_mostly =
174{
175 .name = "branch",
176 .init = branch_trace_init,
177 .reset = branch_trace_reset,
178#ifdef CONFIG_FTRACE_SELFTEST
179 .selftest = trace_selftest_startup_branch,
180#endif /* CONFIG_FTRACE_SELFTEST */
Zhaolei557055b2009-04-13 16:02:34 +0800181 .print_header = branch_print_header,
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800182};
183
184__init static int init_branch_tracer(void)
185{
186 int ret;
187
Steven Rostedt (Red Hat)9023c932015-05-05 09:39:12 -0400188 ret = register_trace_event(&trace_branch_event);
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800189 if (!ret) {
190 printk(KERN_WARNING "Warning: could not register "
191 "branch events\n");
192 return 1;
193 }
194 return register_tracer(&branch_trace);
195}
Steven Rostedt6f415672012-10-05 12:13:07 -0400196core_initcall(init_branch_tracer);
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800197
Steven Rostedt52f232c2008-11-12 00:14:40 -0500198#else
199static inline
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -0500200void trace_likely_condition(struct ftrace_likely_data *f, int val, int expect)
Steven Rostedt52f232c2008-11-12 00:14:40 -0500201{
202}
Steven Rostedt2ed84ee2008-11-12 15:24:24 -0500203#endif /* CONFIG_BRANCH_TRACER */
Steven Rostedt52f232c2008-11-12 00:14:40 -0500204
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500205void ftrace_likely_update(struct ftrace_likely_data *f, int val,
Steven Rostedt (VMware)d45ae1f2017-01-17 12:29:35 -0500206 int expect, int is_constant)
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500207{
Steven Rostedt (VMware)d45ae1f2017-01-17 12:29:35 -0500208 /* A constant is always correct */
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500209 if (is_constant) {
210 f->constant++;
Steven Rostedt (VMware)d45ae1f2017-01-17 12:29:35 -0500211 val = expect;
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500212 }
Steven Rostedt52f232c2008-11-12 00:14:40 -0500213 /*
214 * I would love to have a trace point here instead, but the
215 * trace point code is so inundated with unlikely and likely
216 * conditions that the recursive nightmare that exists is too
217 * much to try to get working. At least for now.
218 */
Steven Rostedt (VMware)068f5302017-01-19 08:57:41 -0500219 trace_likely_condition(f, val, expect);
Steven Rostedt52f232c2008-11-12 00:14:40 -0500220
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500221 /* FIXME: Make this atomic! */
222 if (val == expect)
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500223 f->data.correct++;
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500224 else
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500225 f->data.incorrect++;
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500226}
227EXPORT_SYMBOL(ftrace_likely_update);
228
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100229extern unsigned long __start_annotated_branch_profile[];
230extern unsigned long __stop_annotated_branch_profile[];
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500231
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100232static int annotated_branch_stat_headers(struct seq_file *m)
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500233{
Rasmus Villemoesd79ac282014-11-08 21:42:11 +0100234 seq_puts(m, " correct incorrect % "
235 " Function "
Rasmus Villemoesfa6f0cc2014-11-08 21:42:10 +0100236 " File Line\n"
237 " ------- --------- - "
238 " -------- "
239 " ---- ----\n");
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100240 return 0;
241}
242
243static inline long get_incorrect_percent(struct ftrace_branch_data *p)
244{
245 long percent;
246
247 if (p->correct) {
248 percent = p->incorrect * 100;
249 percent /= p->correct + p->incorrect;
250 } else
251 percent = p->incorrect ? 100 : -1;
252
253 return percent;
254}
255
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500256static const char *branch_stat_process_file(struct ftrace_branch_data *p)
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100257{
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100258 const char *f;
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500259
260 /* Only print the file, not the path */
261 f = p->file + strlen(p->file);
262 while (f >= p->file && *f != '/')
263 f--;
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500264 return ++f;
265}
266
267static void branch_stat_show(struct seq_file *m,
268 struct ftrace_branch_data *p, const char *f)
269{
270 long percent;
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500271
Steven Rostedt2bcd5212008-11-21 01:30:54 -0500272 /*
273 * The miss is overlayed on correct, and hit on incorrect.
274 */
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100275 percent = get_incorrect_percent(p);
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500276
Steven Rostedtbac28bf2008-11-21 01:51:53 -0500277 if (percent < 0)
Rasmus Villemoesfa6f0cc2014-11-08 21:42:10 +0100278 seq_puts(m, " X ");
Steven Rostedtbac28bf2008-11-21 01:51:53 -0500279 else
280 seq_printf(m, "%3ld ", percent);
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500281
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500282 seq_printf(m, "%-30.30s %-20.20s %d\n", p->func, f, p->line);
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500283}
284
285static int branch_stat_show_normal(struct seq_file *m,
286 struct ftrace_branch_data *p, const char *f)
287{
288 seq_printf(m, "%8lu %8lu ", p->correct, p->incorrect);
289 branch_stat_show(m, p, f);
290 return 0;
291}
292
293static int annotate_branch_stat_show(struct seq_file *m, void *v)
294{
295 struct ftrace_likely_data *p = v;
296 const char *f;
297 int l;
298
299 f = branch_stat_process_file(&p->data);
300
301 if (!p->constant)
302 return branch_stat_show_normal(m, &p->data, f);
303
304 l = snprintf(NULL, 0, "/%lu", p->constant);
305 l = l > 8 ? 0 : 8 - l;
306
307 seq_printf(m, "%8lu/%lu %*lu ",
308 p->data.correct, p->constant, l, p->data.incorrect);
309 branch_stat_show(m, &p->data, f);
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500310 return 0;
311}
312
Steven Rostedt42548002009-03-24 13:38:36 -0400313static void *annotated_branch_stat_start(struct tracer_stat *trace)
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500314{
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100315 return __start_annotated_branch_profile;
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500316}
317
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100318static void *
319annotated_branch_stat_next(void *v, int idx)
320{
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500321 struct ftrace_likely_data *p = v;
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100322
323 ++p;
324
325 if ((void *)p >= (void *)__stop_annotated_branch_profile)
326 return NULL;
327
328 return p;
329}
330
331static int annotated_branch_stat_cmp(void *p1, void *p2)
332{
333 struct ftrace_branch_data *a = p1;
334 struct ftrace_branch_data *b = p2;
335
336 long percent_a, percent_b;
337
338 percent_a = get_incorrect_percent(a);
339 percent_b = get_incorrect_percent(b);
340
341 if (percent_a < percent_b)
342 return -1;
343 if (percent_a > percent_b)
344 return 1;
Steven Rostedtede55c92010-01-27 11:25:54 -0500345
346 if (a->incorrect < b->incorrect)
347 return -1;
348 if (a->incorrect > b->incorrect)
349 return 1;
350
351 /*
352 * Since the above shows worse (incorrect) cases
353 * first, we continue that by showing best (correct)
354 * cases last.
355 */
356 if (a->correct > b->correct)
357 return -1;
358 if (a->correct < b->correct)
359 return 1;
360
361 return 0;
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100362}
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500363
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800364static struct tracer_stat annotated_branch_stats = {
365 .name = "branch_annotated",
366 .stat_start = annotated_branch_stat_start,
367 .stat_next = annotated_branch_stat_next,
368 .stat_cmp = annotated_branch_stat_cmp,
369 .stat_headers = annotated_branch_stat_headers,
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500370 .stat_show = annotate_branch_stat_show
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800371};
372
373__init static int init_annotated_branch_stats(void)
374{
375 int ret;
376
377 ret = register_stat_tracer(&annotated_branch_stats);
378 if (!ret) {
379 printk(KERN_WARNING "Warning: could not register "
380 "annotated branches stats\n");
381 return 1;
382 }
383 return 0;
384}
385fs_initcall(init_annotated_branch_stats);
386
Steven Rostedt2bcd5212008-11-21 01:30:54 -0500387#ifdef CONFIG_PROFILE_ALL_BRANCHES
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100388
Steven Rostedt2bcd5212008-11-21 01:30:54 -0500389extern unsigned long __start_branch_profile[];
390extern unsigned long __stop_branch_profile[];
391
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100392static int all_branch_stat_headers(struct seq_file *m)
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500393{
Rasmus Villemoesd79ac282014-11-08 21:42:11 +0100394 seq_puts(m, " miss hit % "
395 " Function "
Rasmus Villemoesfa6f0cc2014-11-08 21:42:10 +0100396 " File Line\n"
397 " ------- --------- - "
398 " -------- "
399 " ---- ----\n");
Steven Rostedt1f0d69a2008-11-12 00:14:39 -0500400 return 0;
401}
402
Steven Rostedt42548002009-03-24 13:38:36 -0400403static void *all_branch_stat_start(struct tracer_stat *trace)
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100404{
405 return __start_branch_profile;
406}
407
408static void *
409all_branch_stat_next(void *v, int idx)
410{
411 struct ftrace_branch_data *p = v;
412
413 ++p;
414
415 if ((void *)p >= (void *)__stop_branch_profile)
416 return NULL;
417
418 return p;
419}
420
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500421static int all_branch_stat_show(struct seq_file *m, void *v)
422{
423 struct ftrace_branch_data *p = v;
424 const char *f;
425
426 f = branch_stat_process_file(p);
427 return branch_stat_show_normal(m, p, f);
428}
429
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800430static struct tracer_stat all_branch_stats = {
431 .name = "branch_all",
Frederic Weisbecker034939b2009-01-08 10:03:56 -0800432 .stat_start = all_branch_stat_start,
433 .stat_next = all_branch_stat_next,
434 .stat_headers = all_branch_stat_headers,
Steven Rostedt (VMware)134e6a02017-01-19 08:57:14 -0500435 .stat_show = all_branch_stat_show
Frederic Weisbecker034939b2009-01-08 10:03:56 -0800436};
Frederic Weisbecker034939b2009-01-08 10:03:56 -0800437
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800438__init static int all_annotated_branch_stats(void)
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100439{
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100440 int ret;
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800441
442 ret = register_stat_tracer(&all_branch_stats);
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100443 if (!ret) {
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800444 printk(KERN_WARNING "Warning: could not register "
445 "all branches stats\n");
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100446 return 1;
447 }
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800448 return 0;
Frederic Weisbeckere302cf32008-12-27 23:25:38 +0100449}
Frederic Weisbecker002bb862009-01-10 11:34:13 -0800450fs_initcall(all_annotated_branch_stats);
451#endif /* CONFIG_PROFILE_ALL_BRANCHES */