Steven Rostedt (VMware) | bcea3f9 | 2018-08-16 11:23:53 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 2 | /* |
Wenji Huang | 73d8b8b | 2009-02-17 01:10:02 -0500 | [diff] [blame] | 3 | * trace irqs off critical timings |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> |
| 6 | * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com> |
| 7 | * |
| 8 | * From code in the latency_tracer, that is: |
| 9 | * |
| 10 | * Copyright (C) 2004-2006 Ingo Molnar |
Nadia Yvette Chambers | 6d49e35 | 2012-12-06 10:39:54 +0100 | [diff] [blame] | 11 | * Copyright (C) 2004 Nadia Yvette Chambers |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 12 | */ |
| 13 | #include <linux/kallsyms.h> |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 14 | #include <linux/uaccess.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/ftrace.h> |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 17 | #include <linux/kprobes.h> |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 18 | |
| 19 | #include "trace.h" |
| 20 | |
Joel Fernandes | d591581 | 2017-10-10 15:51:37 -0700 | [diff] [blame] | 21 | #include <trace/events/preemptirq.h> |
| 22 | |
Joel Fernandes | aaecaa0 | 2017-10-05 17:54:31 -0700 | [diff] [blame] | 23 | #if defined(CONFIG_IRQSOFF_TRACER) || defined(CONFIG_PREEMPT_TRACER) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 24 | static struct trace_array *irqsoff_trace __read_mostly; |
| 25 | static int tracer_enabled __read_mostly; |
| 26 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 27 | static DEFINE_PER_CPU(int, tracing_cpu); |
| 28 | |
Thomas Gleixner | 5389f6f | 2009-07-25 17:13:33 +0200 | [diff] [blame] | 29 | static DEFINE_RAW_SPINLOCK(max_trace_lock); |
Steven Rostedt | 89b2f97 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 30 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 31 | enum { |
| 32 | TRACER_IRQS_OFF = (1 << 1), |
| 33 | TRACER_PREEMPT_OFF = (1 << 2), |
| 34 | }; |
| 35 | |
| 36 | static int trace_type __read_mostly; |
| 37 | |
Steven Rostedt (Red Hat) | 613f04a | 2013-03-14 15:03:53 -0400 | [diff] [blame] | 38 | static int save_flags; |
Steven Rostedt | e9d25fe | 2009-03-04 22:15:30 -0500 | [diff] [blame] | 39 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 40 | static void stop_irqsoff_tracer(struct trace_array *tr, int graph); |
| 41 | static int start_irqsoff_tracer(struct trace_array *tr, int graph); |
| 42 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 43 | #ifdef CONFIG_PREEMPT_TRACER |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 44 | static inline int |
Steven Rostedt (VMware) | f27107f | 2018-08-07 17:03:12 -0400 | [diff] [blame] | 45 | preempt_trace(int pc) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 46 | { |
Steven Rostedt (VMware) | f27107f | 2018-08-07 17:03:12 -0400 | [diff] [blame] | 47 | return ((trace_type & TRACER_PREEMPT_OFF) && pc); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 48 | } |
| 49 | #else |
Steven Rostedt (VMware) | f27107f | 2018-08-07 17:03:12 -0400 | [diff] [blame] | 50 | # define preempt_trace(pc) (0) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | #ifdef CONFIG_IRQSOFF_TRACER |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 54 | static inline int |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 55 | irq_trace(void) |
| 56 | { |
| 57 | return ((trace_type & TRACER_IRQS_OFF) && |
| 58 | irqs_disabled()); |
| 59 | } |
| 60 | #else |
| 61 | # define irq_trace() (0) |
| 62 | #endif |
| 63 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 64 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
Steven Rostedt (Red Hat) | 0390558 | 2015-09-28 15:37:49 -0400 | [diff] [blame] | 65 | static int irqsoff_display_graph(struct trace_array *tr, int set); |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 66 | # define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH) |
Steven Rostedt (Red Hat) | 0390558 | 2015-09-28 15:37:49 -0400 | [diff] [blame] | 67 | #else |
| 68 | static inline int irqsoff_display_graph(struct trace_array *tr, int set) |
| 69 | { |
| 70 | return -EINVAL; |
| 71 | } |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 72 | # define is_graph(tr) false |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 73 | #endif |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 74 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 75 | /* |
| 76 | * Sequence count - we record it when starting a measurement and |
| 77 | * skip the latency if the sequence has changed - some other section |
| 78 | * did a maximum and could disturb our measurement with serial console |
| 79 | * printouts, etc. Truly coinciding maximum latencies should be rare |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 80 | * and what happens together happens separately as well, so this doesn't |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 81 | * decrease the validity of the maximum found: |
| 82 | */ |
| 83 | static __cacheline_aligned_in_smp unsigned long max_sequence; |
| 84 | |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 85 | #ifdef CONFIG_FUNCTION_TRACER |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 86 | /* |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 87 | * Prologue for the preempt and irqs off function tracers. |
| 88 | * |
| 89 | * Returns 1 if it is OK to continue, and data->disabled is |
| 90 | * incremented. |
| 91 | * 0 if the trace is to be ignored, and data->disabled |
| 92 | * is kept the same. |
| 93 | * |
| 94 | * Note, this function is also used outside this ifdef but |
| 95 | * inside the #ifdef of the function graph tracer below. |
| 96 | * This is OK, since the function graph tracer is |
| 97 | * dependent on the function tracer. |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 98 | */ |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 99 | static int func_prolog_dec(struct trace_array *tr, |
| 100 | struct trace_array_cpu **data, |
| 101 | unsigned long *flags) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 102 | { |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 103 | long disabled; |
| 104 | int cpu; |
| 105 | |
Steven Rostedt | 361943a | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 106 | /* |
| 107 | * Does not matter if we preempt. We test the flags |
| 108 | * afterward, to see if irqs are disabled or not. |
| 109 | * If we preempt and get a false positive, the flags |
| 110 | * test will fail. |
| 111 | */ |
| 112 | cpu = raw_smp_processor_id(); |
| 113 | if (likely(!per_cpu(tracing_cpu, cpu))) |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 114 | return 0; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 115 | |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 116 | local_save_flags(*flags); |
Steven Rostedt (Red Hat) | cb86e05 | 2016-03-18 12:27:43 -0400 | [diff] [blame] | 117 | /* |
| 118 | * Slight chance to get a false positive on tracing_cpu, |
| 119 | * although I'm starting to think there isn't a chance. |
| 120 | * Leave this for now just to be paranoid. |
| 121 | */ |
| 122 | if (!irqs_disabled_flags(*flags) && !preempt_count()) |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 123 | return 0; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 124 | |
Steven Rostedt (VMware) | 1c5eb44 | 2020-01-09 18:53:48 -0500 | [diff] [blame] | 125 | *data = per_cpu_ptr(tr->array_buffer.data, cpu); |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 126 | disabled = atomic_inc_return(&(*data)->disabled); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 127 | |
| 128 | if (likely(disabled == 1)) |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 129 | return 1; |
| 130 | |
| 131 | atomic_dec(&(*data)->disabled); |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * irqsoff uses its own tracer function to keep the overhead down: |
| 138 | */ |
| 139 | static void |
Steven Rostedt | 2f5f6ad | 2011-08-08 16:57:47 -0400 | [diff] [blame] | 140 | irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip, |
Steven Rostedt (VMware) | d19ad07 | 2020-10-28 17:42:17 -0400 | [diff] [blame] | 141 | struct ftrace_ops *op, struct ftrace_regs *fregs) |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 142 | { |
| 143 | struct trace_array *tr = irqsoff_trace; |
| 144 | struct trace_array_cpu *data; |
| 145 | unsigned long flags; |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 146 | unsigned int trace_ctx; |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 147 | |
| 148 | if (!func_prolog_dec(tr, &data, &flags)) |
| 149 | return; |
| 150 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 151 | trace_ctx = tracing_gen_ctx_flags(flags); |
| 152 | |
| 153 | trace_function(tr, ip, parent_ip, trace_ctx); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 154 | |
| 155 | atomic_dec(&data->disabled); |
| 156 | } |
Steven Rostedt | 606576c | 2008-10-06 19:06:12 -0400 | [diff] [blame] | 157 | #endif /* CONFIG_FUNCTION_TRACER */ |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 158 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 159 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
Steven Rostedt (Red Hat) | 0390558 | 2015-09-28 15:37:49 -0400 | [diff] [blame] | 160 | static int irqsoff_display_graph(struct trace_array *tr, int set) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 161 | { |
| 162 | int cpu; |
| 163 | |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 164 | if (!(is_graph(tr) ^ set)) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 165 | return 0; |
| 166 | |
| 167 | stop_irqsoff_tracer(irqsoff_trace, !set); |
| 168 | |
| 169 | for_each_possible_cpu(cpu) |
| 170 | per_cpu(tracing_cpu, cpu) = 0; |
| 171 | |
Steven Rostedt (Red Hat) | 6d9b3fa | 2014-01-14 11:28:38 -0500 | [diff] [blame] | 172 | tr->max_latency = 0; |
Steven Rostedt (VMware) | 1c5eb44 | 2020-01-09 18:53:48 -0500 | [diff] [blame] | 173 | tracing_reset_online_cpus(&irqsoff_trace->array_buffer); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 174 | |
| 175 | return start_irqsoff_tracer(irqsoff_trace, set); |
| 176 | } |
| 177 | |
| 178 | static int irqsoff_graph_entry(struct ftrace_graph_ent *trace) |
| 179 | { |
| 180 | struct trace_array *tr = irqsoff_trace; |
| 181 | struct trace_array_cpu *data; |
| 182 | unsigned long flags; |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 183 | unsigned int trace_ctx; |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 184 | int ret; |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 185 | |
Steven Rostedt (Red Hat) | 1a41442 | 2016-12-08 19:28:28 -0500 | [diff] [blame] | 186 | if (ftrace_graph_ignore_func(trace)) |
| 187 | return 0; |
| 188 | /* |
| 189 | * Do not trace a function if it's filtered by set_graph_notrace. |
| 190 | * Make the index of ret stack negative to indicate that it should |
| 191 | * ignore further functions. But it needs its own ret stack entry |
| 192 | * to recover the original index in order to continue tracing after |
| 193 | * returning from the function. |
| 194 | */ |
| 195 | if (ftrace_graph_notrace_addr(trace->func)) |
| 196 | return 1; |
| 197 | |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 198 | if (!func_prolog_dec(tr, &data, &flags)) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 199 | return 0; |
| 200 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 201 | trace_ctx = tracing_gen_ctx_flags(flags); |
| 202 | ret = __trace_graph_entry(tr, trace, trace_ctx); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 203 | atomic_dec(&data->disabled); |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 204 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 205 | return ret; |
| 206 | } |
| 207 | |
| 208 | static void irqsoff_graph_return(struct ftrace_graph_ret *trace) |
| 209 | { |
| 210 | struct trace_array *tr = irqsoff_trace; |
| 211 | struct trace_array_cpu *data; |
| 212 | unsigned long flags; |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 213 | unsigned int trace_ctx; |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 214 | |
Steven Rostedt (VMware) | 5cf99a0f | 2018-11-29 08:50:27 -0500 | [diff] [blame] | 215 | ftrace_graph_addr_finish(trace); |
| 216 | |
Steven Rostedt | 5e6d2b9 | 2010-10-05 19:41:43 -0400 | [diff] [blame] | 217 | if (!func_prolog_dec(tr, &data, &flags)) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 218 | return; |
| 219 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 220 | trace_ctx = tracing_gen_ctx_flags(flags); |
| 221 | __trace_graph_return(tr, trace, trace_ctx); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 222 | atomic_dec(&data->disabled); |
| 223 | } |
| 224 | |
Steven Rostedt (VMware) | 688f708 | 2018-11-15 14:06:47 -0500 | [diff] [blame] | 225 | static struct fgraph_ops fgraph_ops = { |
| 226 | .entryfunc = &irqsoff_graph_entry, |
| 227 | .retfunc = &irqsoff_graph_return, |
| 228 | }; |
| 229 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 230 | static void irqsoff_trace_open(struct trace_iterator *iter) |
| 231 | { |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 232 | if (is_graph(iter->tr)) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 233 | graph_trace_open(iter); |
| 234 | |
| 235 | } |
| 236 | |
| 237 | static void irqsoff_trace_close(struct trace_iterator *iter) |
| 238 | { |
| 239 | if (iter->private) |
| 240 | graph_trace_close(iter); |
| 241 | } |
| 242 | |
| 243 | #define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \ |
Jiri Olsa | 321e68b | 2011-06-03 16:58:47 +0200 | [diff] [blame] | 244 | TRACE_GRAPH_PRINT_PROC | \ |
Changbin Du | 9acd8de | 2019-01-01 23:46:10 +0800 | [diff] [blame] | 245 | TRACE_GRAPH_PRINT_REL_TIME | \ |
Jiri Olsa | 321e68b | 2011-06-03 16:58:47 +0200 | [diff] [blame] | 246 | TRACE_GRAPH_PRINT_DURATION) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 247 | |
| 248 | static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) |
| 249 | { |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 250 | /* |
| 251 | * In graph mode call the graph tracer output function, |
| 252 | * otherwise go with the TRACE_FN event handler |
| 253 | */ |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 254 | if (is_graph(iter->tr)) |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 255 | return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 256 | |
| 257 | return TRACE_TYPE_UNHANDLED; |
| 258 | } |
| 259 | |
| 260 | static void irqsoff_print_header(struct seq_file *s) |
| 261 | { |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 262 | struct trace_array *tr = irqsoff_trace; |
| 263 | |
| 264 | if (is_graph(tr)) |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 265 | print_graph_headers_flags(s, GRAPH_TRACER_FLAGS); |
| 266 | else |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 267 | trace_default_header(s); |
| 268 | } |
| 269 | |
| 270 | static void |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 271 | __trace_function(struct trace_array *tr, |
| 272 | unsigned long ip, unsigned long parent_ip, |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 273 | unsigned int trace_ctx) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 274 | { |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 275 | if (is_graph(tr)) |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 276 | trace_graph_function(tr, ip, parent_ip, trace_ctx); |
Jiri Olsa | 0a77262 | 2010-09-23 14:00:52 +0200 | [diff] [blame] | 277 | else |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 278 | trace_function(tr, ip, parent_ip, trace_ctx); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | #else |
| 282 | #define __trace_function trace_function |
| 283 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 284 | static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) |
| 285 | { |
| 286 | return TRACE_TYPE_UNHANDLED; |
| 287 | } |
| 288 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 289 | static void irqsoff_trace_open(struct trace_iterator *iter) { } |
| 290 | static void irqsoff_trace_close(struct trace_iterator *iter) { } |
Jiri Olsa | 7e9a49e | 2011-11-07 16:08:49 +0100 | [diff] [blame] | 291 | |
| 292 | #ifdef CONFIG_FUNCTION_TRACER |
| 293 | static void irqsoff_print_header(struct seq_file *s) |
| 294 | { |
| 295 | trace_default_header(s); |
| 296 | } |
| 297 | #else |
| 298 | static void irqsoff_print_header(struct seq_file *s) |
| 299 | { |
| 300 | trace_latency_header(s); |
| 301 | } |
| 302 | #endif /* CONFIG_FUNCTION_TRACER */ |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 303 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
| 304 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 305 | /* |
| 306 | * Should this new latency be reported/recorded? |
| 307 | */ |
Thomas Gleixner | a5a1d1c | 2016-12-21 20:32:01 +0100 | [diff] [blame] | 308 | static bool report_latency(struct trace_array *tr, u64 delta) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 309 | { |
| 310 | if (tracing_thresh) { |
| 311 | if (delta < tracing_thresh) |
Yaowei Bai | 7985182 | 2015-09-29 22:43:30 +0800 | [diff] [blame] | 312 | return false; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 313 | } else { |
Steven Rostedt (Red Hat) | 6d9b3fa | 2014-01-14 11:28:38 -0500 | [diff] [blame] | 314 | if (delta <= tr->max_latency) |
Yaowei Bai | 7985182 | 2015-09-29 22:43:30 +0800 | [diff] [blame] | 315 | return false; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 316 | } |
Yaowei Bai | 7985182 | 2015-09-29 22:43:30 +0800 | [diff] [blame] | 317 | return true; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 318 | } |
| 319 | |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 320 | static void |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 321 | check_critical_timing(struct trace_array *tr, |
| 322 | struct trace_array_cpu *data, |
| 323 | unsigned long parent_ip, |
| 324 | int cpu) |
| 325 | { |
Thomas Gleixner | a5a1d1c | 2016-12-21 20:32:01 +0100 | [diff] [blame] | 326 | u64 T0, T1, delta; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 327 | unsigned long flags; |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 328 | unsigned int trace_ctx; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 329 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 330 | T0 = data->preempt_timestamp; |
Ingo Molnar | 750ed1a | 2008-05-12 21:20:46 +0200 | [diff] [blame] | 331 | T1 = ftrace_now(cpu); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 332 | delta = T1-T0; |
| 333 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 334 | trace_ctx = tracing_gen_ctx(); |
Steven Rostedt | 6450c1d | 2008-10-02 19:23:04 -0400 | [diff] [blame] | 335 | |
Steven Rostedt (Red Hat) | 6d9b3fa | 2014-01-14 11:28:38 -0500 | [diff] [blame] | 336 | if (!report_latency(tr, delta)) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 337 | goto out; |
| 338 | |
Thomas Gleixner | 5389f6f | 2009-07-25 17:13:33 +0200 | [diff] [blame] | 339 | raw_spin_lock_irqsave(&max_trace_lock, flags); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 340 | |
Steven Rostedt | 89b2f97 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 341 | /* check if we are still the max latency */ |
Steven Rostedt (Red Hat) | 6d9b3fa | 2014-01-14 11:28:38 -0500 | [diff] [blame] | 342 | if (!report_latency(tr, delta)) |
Steven Rostedt | 89b2f97 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 343 | goto out_unlock; |
| 344 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 345 | __trace_function(tr, CALLER_ADDR0, parent_ip, trace_ctx); |
Steven Rostedt | cc51a0f | 2009-12-11 11:54:51 -0500 | [diff] [blame] | 346 | /* Skip 5 functions to get to the irq/preempt enable function */ |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 347 | __trace_stack(tr, trace_ctx, 5); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 348 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 349 | if (data->critical_sequence != max_sequence) |
Steven Rostedt | 89b2f97 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 350 | goto out_unlock; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 351 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 352 | data->critical_end = parent_ip; |
| 353 | |
Carsten Emde | b5130b1 | 2009-09-13 01:43:07 +0200 | [diff] [blame] | 354 | if (likely(!is_tracing_stopped())) { |
Steven Rostedt (Red Hat) | 6d9b3fa | 2014-01-14 11:28:38 -0500 | [diff] [blame] | 355 | tr->max_latency = delta; |
Carsten Emde | b5130b1 | 2009-09-13 01:43:07 +0200 | [diff] [blame] | 356 | update_max_tr_single(tr, current, cpu); |
| 357 | } |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 358 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 359 | max_sequence++; |
| 360 | |
Steven Rostedt | 89b2f97 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 361 | out_unlock: |
Thomas Gleixner | 5389f6f | 2009-07-25 17:13:33 +0200 | [diff] [blame] | 362 | raw_spin_unlock_irqrestore(&max_trace_lock, flags); |
Steven Rostedt | 89b2f97 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 363 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 364 | out: |
| 365 | data->critical_sequence = max_sequence; |
Ingo Molnar | 750ed1a | 2008-05-12 21:20:46 +0200 | [diff] [blame] | 366 | data->preempt_timestamp = ftrace_now(cpu); |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 367 | __trace_function(tr, CALLER_ADDR0, parent_ip, trace_ctx); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 368 | } |
| 369 | |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 370 | static nokprobe_inline void |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 371 | start_critical_timing(unsigned long ip, unsigned long parent_ip) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 372 | { |
| 373 | int cpu; |
| 374 | struct trace_array *tr = irqsoff_trace; |
| 375 | struct trace_array_cpu *data; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 376 | |
Steven Rostedt (Red Hat) | 10246fa | 2013-07-01 15:58:24 -0400 | [diff] [blame] | 377 | if (!tracer_enabled || !tracing_is_enabled()) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 378 | return; |
| 379 | |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 380 | cpu = raw_smp_processor_id(); |
| 381 | |
| 382 | if (per_cpu(tracing_cpu, cpu)) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 383 | return; |
| 384 | |
Steven Rostedt (VMware) | 1c5eb44 | 2020-01-09 18:53:48 -0500 | [diff] [blame] | 385 | data = per_cpu_ptr(tr->array_buffer.data, cpu); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 386 | |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 387 | if (unlikely(!data) || atomic_read(&data->disabled)) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 388 | return; |
| 389 | |
| 390 | atomic_inc(&data->disabled); |
| 391 | |
| 392 | data->critical_sequence = max_sequence; |
Ingo Molnar | 750ed1a | 2008-05-12 21:20:46 +0200 | [diff] [blame] | 393 | data->preempt_timestamp = ftrace_now(cpu); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 394 | data->critical_start = parent_ip ? : ip; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 395 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 396 | __trace_function(tr, ip, parent_ip, tracing_gen_ctx()); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 397 | |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 398 | per_cpu(tracing_cpu, cpu) = 1; |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 399 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 400 | atomic_dec(&data->disabled); |
| 401 | } |
| 402 | |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 403 | static nokprobe_inline void |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 404 | stop_critical_timing(unsigned long ip, unsigned long parent_ip) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 405 | { |
| 406 | int cpu; |
| 407 | struct trace_array *tr = irqsoff_trace; |
| 408 | struct trace_array_cpu *data; |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 409 | unsigned int trace_ctx; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 410 | |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 411 | cpu = raw_smp_processor_id(); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 412 | /* Always clear the tracing cpu on stopping the trace */ |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 413 | if (unlikely(per_cpu(tracing_cpu, cpu))) |
| 414 | per_cpu(tracing_cpu, cpu) = 0; |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 415 | else |
| 416 | return; |
| 417 | |
Steven Rostedt (Red Hat) | 10246fa | 2013-07-01 15:58:24 -0400 | [diff] [blame] | 418 | if (!tracer_enabled || !tracing_is_enabled()) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 419 | return; |
| 420 | |
Steven Rostedt (VMware) | 1c5eb44 | 2020-01-09 18:53:48 -0500 | [diff] [blame] | 421 | data = per_cpu_ptr(tr->array_buffer.data, cpu); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 422 | |
Steven Rostedt | 3928a8a | 2008-09-29 23:02:41 -0400 | [diff] [blame] | 423 | if (unlikely(!data) || |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 424 | !data->critical_start || atomic_read(&data->disabled)) |
| 425 | return; |
| 426 | |
| 427 | atomic_inc(&data->disabled); |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 428 | |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 429 | trace_ctx = tracing_gen_ctx(); |
| 430 | __trace_function(tr, ip, parent_ip, trace_ctx); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 431 | check_critical_timing(tr, data, parent_ip ? : ip, cpu); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 432 | data->critical_start = 0; |
| 433 | atomic_dec(&data->disabled); |
| 434 | } |
| 435 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 436 | /* start and stop critical timings used to for stoppage (in idle) */ |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 437 | void start_critical_timings(void) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 438 | { |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 439 | if (preempt_trace(preempt_count()) || irq_trace()) |
| 440 | start_critical_timing(CALLER_ADDR0, CALLER_ADDR1); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 441 | } |
Ingo Molnar | 1fe3710 | 2008-07-26 15:09:47 +0200 | [diff] [blame] | 442 | EXPORT_SYMBOL_GPL(start_critical_timings); |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 443 | NOKPROBE_SYMBOL(start_critical_timings); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 444 | |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 445 | void stop_critical_timings(void) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 446 | { |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 447 | if (preempt_trace(preempt_count()) || irq_trace()) |
| 448 | stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 449 | } |
Ingo Molnar | 1fe3710 | 2008-07-26 15:09:47 +0200 | [diff] [blame] | 450 | EXPORT_SYMBOL_GPL(stop_critical_timings); |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 451 | NOKPROBE_SYMBOL(stop_critical_timings); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 452 | |
Steven Rostedt (Red Hat) | 8179e8a | 2015-09-29 10:24:56 -0400 | [diff] [blame] | 453 | #ifdef CONFIG_FUNCTION_TRACER |
| 454 | static bool function_enabled; |
| 455 | |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 456 | static int register_irqsoff_function(struct trace_array *tr, int graph, int set) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 457 | { |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 458 | int ret; |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 459 | |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 460 | /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */ |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 461 | if (function_enabled || (!set && !(tr->trace_flags & TRACE_ITER_FUNCTION))) |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 462 | return 0; |
| 463 | |
| 464 | if (graph) |
Steven Rostedt (VMware) | 688f708 | 2018-11-15 14:06:47 -0500 | [diff] [blame] | 465 | ret = register_ftrace_graph(&fgraph_ops); |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 466 | else |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 467 | ret = register_ftrace_function(tr->ops); |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 468 | |
| 469 | if (!ret) |
| 470 | function_enabled = true; |
| 471 | |
| 472 | return ret; |
| 473 | } |
| 474 | |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 475 | static void unregister_irqsoff_function(struct trace_array *tr, int graph) |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 476 | { |
| 477 | if (!function_enabled) |
| 478 | return; |
| 479 | |
| 480 | if (graph) |
Steven Rostedt (VMware) | 688f708 | 2018-11-15 14:06:47 -0500 | [diff] [blame] | 481 | unregister_ftrace_graph(&fgraph_ops); |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 482 | else |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 483 | unregister_ftrace_function(tr->ops); |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 484 | |
| 485 | function_enabled = false; |
| 486 | } |
| 487 | |
Steven Rostedt (Red Hat) | 8179e8a | 2015-09-29 10:24:56 -0400 | [diff] [blame] | 488 | static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set) |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 489 | { |
Steven Rostedt (Red Hat) | 8179e8a | 2015-09-29 10:24:56 -0400 | [diff] [blame] | 490 | if (!(mask & TRACE_ITER_FUNCTION)) |
| 491 | return 0; |
| 492 | |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 493 | if (set) |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 494 | register_irqsoff_function(tr, is_graph(tr), 1); |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 495 | else |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 496 | unregister_irqsoff_function(tr, is_graph(tr)); |
Steven Rostedt (Red Hat) | 8179e8a | 2015-09-29 10:24:56 -0400 | [diff] [blame] | 497 | return 1; |
| 498 | } |
| 499 | #else |
| 500 | static int register_irqsoff_function(struct trace_array *tr, int graph, int set) |
| 501 | { |
Steven Rostedt (Red Hat) | 0390558 | 2015-09-28 15:37:49 -0400 | [diff] [blame] | 502 | return 0; |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 503 | } |
Steven Rostedt (Red Hat) | 8179e8a | 2015-09-29 10:24:56 -0400 | [diff] [blame] | 504 | static void unregister_irqsoff_function(struct trace_array *tr, int graph) { } |
| 505 | static inline int irqsoff_function_set(struct trace_array *tr, u32 mask, int set) |
| 506 | { |
| 507 | return 0; |
| 508 | } |
| 509 | #endif /* CONFIG_FUNCTION_TRACER */ |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 510 | |
Steven Rostedt (Red Hat) | bf6065b | 2014-01-10 17:51:01 -0500 | [diff] [blame] | 511 | static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set) |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 512 | { |
Steven Rostedt (Red Hat) | bf6065b | 2014-01-10 17:51:01 -0500 | [diff] [blame] | 513 | struct tracer *tracer = tr->current_trace; |
| 514 | |
Steven Rostedt (Red Hat) | 8179e8a | 2015-09-29 10:24:56 -0400 | [diff] [blame] | 515 | if (irqsoff_function_set(tr, mask, set)) |
| 516 | return 0; |
Steven Rostedt (Red Hat) | 0390558 | 2015-09-28 15:37:49 -0400 | [diff] [blame] | 517 | |
Steven Rostedt (Red Hat) | 729358d | 2015-09-29 10:15:10 -0400 | [diff] [blame] | 518 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
Steven Rostedt (Red Hat) | 0390558 | 2015-09-28 15:37:49 -0400 | [diff] [blame] | 519 | if (mask & TRACE_ITER_DISPLAY_GRAPH) |
| 520 | return irqsoff_display_graph(tr, set); |
Steven Rostedt (Red Hat) | 729358d | 2015-09-29 10:15:10 -0400 | [diff] [blame] | 521 | #endif |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 522 | |
| 523 | return trace_keep_overwrite(tracer, mask, set); |
| 524 | } |
| 525 | |
| 526 | static int start_irqsoff_tracer(struct trace_array *tr, int graph) |
| 527 | { |
| 528 | int ret; |
| 529 | |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 530 | ret = register_irqsoff_function(tr, graph, 0); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 531 | |
| 532 | if (!ret && tracing_is_enabled()) |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 533 | tracer_enabled = 1; |
Steven Rostedt | 94523e8 | 2009-01-22 11:18:06 -0500 | [diff] [blame] | 534 | else |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 535 | tracer_enabled = 0; |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 536 | |
| 537 | return ret; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 538 | } |
| 539 | |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 540 | static void stop_irqsoff_tracer(struct trace_array *tr, int graph) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 541 | { |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 542 | tracer_enabled = 0; |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 543 | |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 544 | unregister_irqsoff_function(tr, graph); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 545 | } |
| 546 | |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 547 | static bool irqsoff_busy; |
| 548 | |
| 549 | static int __irqsoff_tracer_init(struct trace_array *tr) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 550 | { |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 551 | if (irqsoff_busy) |
| 552 | return -EBUSY; |
| 553 | |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 554 | save_flags = tr->trace_flags; |
Steven Rostedt (Red Hat) | 613f04a | 2013-03-14 15:03:53 -0400 | [diff] [blame] | 555 | |
| 556 | /* non overwrite screws up the latency tracers */ |
Steven Rostedt | 2b6080f | 2012-05-11 13:29:49 -0400 | [diff] [blame] | 557 | set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1); |
| 558 | set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1); |
Viktor Rosendahl | da7f84c | 2021-01-19 17:43:43 +0100 | [diff] [blame] | 559 | /* without pause, we will produce garbage if another latency occurs */ |
| 560 | set_tracer_flag(tr, TRACE_ITER_PAUSE_ON_TRACE, 1); |
Steven Rostedt | e9d25fe | 2009-03-04 22:15:30 -0500 | [diff] [blame] | 561 | |
Steven Rostedt (Red Hat) | 6d9b3fa | 2014-01-14 11:28:38 -0500 | [diff] [blame] | 562 | tr->max_latency = 0; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 563 | irqsoff_trace = tr; |
Steven Rostedt | c5f888c | 2008-05-12 21:20:55 +0200 | [diff] [blame] | 564 | /* make sure that the tracer is visible */ |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 565 | smp_wmb(); |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 566 | |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 567 | ftrace_init_array_ops(tr, irqsoff_tracer_call); |
| 568 | |
| 569 | /* Only toplevel instance supports graph tracing */ |
| 570 | if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL && |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 571 | is_graph(tr)))) |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 572 | printk(KERN_ERR "failed to start irqsoff tracer\n"); |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 573 | |
| 574 | irqsoff_busy = true; |
| 575 | return 0; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 576 | } |
| 577 | |
Joel Fernandes (Google) | 2b27ece | 2018-06-28 11:21:45 -0700 | [diff] [blame] | 578 | static void __irqsoff_tracer_reset(struct trace_array *tr) |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 579 | { |
Steven Rostedt (Red Hat) | 613f04a | 2013-03-14 15:03:53 -0400 | [diff] [blame] | 580 | int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT; |
| 581 | int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE; |
Viktor Rosendahl | da7f84c | 2021-01-19 17:43:43 +0100 | [diff] [blame] | 582 | int pause_flag = save_flags & TRACE_ITER_PAUSE_ON_TRACE; |
Steven Rostedt (Red Hat) | 613f04a | 2013-03-14 15:03:53 -0400 | [diff] [blame] | 583 | |
Steven Rostedt (Red Hat) | 983f938 | 2015-09-30 09:42:05 -0400 | [diff] [blame] | 584 | stop_irqsoff_tracer(tr, is_graph(tr)); |
Steven Rostedt | e9d25fe | 2009-03-04 22:15:30 -0500 | [diff] [blame] | 585 | |
Steven Rostedt | 2b6080f | 2012-05-11 13:29:49 -0400 | [diff] [blame] | 586 | set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag); |
| 587 | set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag); |
Viktor Rosendahl | da7f84c | 2021-01-19 17:43:43 +0100 | [diff] [blame] | 588 | set_tracer_flag(tr, TRACE_ITER_PAUSE_ON_TRACE, pause_flag); |
Steven Rostedt (Red Hat) | 4104d32 | 2014-01-10 17:01:58 -0500 | [diff] [blame] | 589 | ftrace_reset_array_ops(tr); |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 590 | |
| 591 | irqsoff_busy = false; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 592 | } |
| 593 | |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 594 | static void irqsoff_tracer_start(struct trace_array *tr) |
| 595 | { |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 596 | tracer_enabled = 1; |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | static void irqsoff_tracer_stop(struct trace_array *tr) |
| 600 | { |
| 601 | tracer_enabled = 0; |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 602 | } |
| 603 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 604 | #ifdef CONFIG_IRQSOFF_TRACER |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 605 | /* |
| 606 | * We are only interested in hardirq on/off events: |
| 607 | */ |
Steven Rostedt (VMware) | 3f1756d | 2018-08-08 21:28:05 -0400 | [diff] [blame] | 608 | void tracer_hardirqs_on(unsigned long a0, unsigned long a1) |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 609 | { |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 610 | if (!preempt_trace(preempt_count()) && irq_trace()) |
| 611 | stop_critical_timing(a0, a1); |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 612 | } |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 613 | NOKPROBE_SYMBOL(tracer_hardirqs_on); |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 614 | |
Steven Rostedt (VMware) | 3f1756d | 2018-08-08 21:28:05 -0400 | [diff] [blame] | 615 | void tracer_hardirqs_off(unsigned long a0, unsigned long a1) |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 616 | { |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 617 | if (!preempt_trace(preempt_count()) && irq_trace()) |
| 618 | start_critical_timing(a0, a1); |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 619 | } |
Masami Hiramatsu | eeeb080 | 2019-02-13 01:13:40 +0900 | [diff] [blame] | 620 | NOKPROBE_SYMBOL(tracer_hardirqs_off); |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 621 | |
Frederic Weisbecker | 1c80025 | 2008-11-16 05:57:26 +0100 | [diff] [blame] | 622 | static int irqsoff_tracer_init(struct trace_array *tr) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 623 | { |
| 624 | trace_type = TRACER_IRQS_OFF; |
| 625 | |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 626 | return __irqsoff_tracer_init(tr); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 627 | } |
Joel Fernandes (Google) | 2b27ece | 2018-06-28 11:21:45 -0700 | [diff] [blame] | 628 | |
| 629 | static void irqsoff_tracer_reset(struct trace_array *tr) |
| 630 | { |
| 631 | __irqsoff_tracer_reset(tr); |
| 632 | } |
| 633 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 634 | static struct tracer irqsoff_tracer __read_mostly = |
| 635 | { |
| 636 | .name = "irqsoff", |
| 637 | .init = irqsoff_tracer_init, |
| 638 | .reset = irqsoff_tracer_reset, |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 639 | .start = irqsoff_tracer_start, |
| 640 | .stop = irqsoff_tracer_stop, |
Hiraku Toyooka | f43c738 | 2012-10-02 17:27:10 +0900 | [diff] [blame] | 641 | .print_max = true, |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 642 | .print_header = irqsoff_print_header, |
| 643 | .print_line = irqsoff_print_line, |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 644 | .flag_changed = irqsoff_flag_changed, |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 645 | #ifdef CONFIG_FTRACE_SELFTEST |
| 646 | .selftest = trace_selftest_startup_irqsoff, |
| 647 | #endif |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 648 | .open = irqsoff_trace_open, |
| 649 | .close = irqsoff_trace_close, |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 650 | .allow_instances = true, |
Hiraku Toyooka | f43c738 | 2012-10-02 17:27:10 +0900 | [diff] [blame] | 651 | .use_max_tr = true, |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 652 | }; |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 653 | #endif /* CONFIG_IRQSOFF_TRACER */ |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 654 | |
| 655 | #ifdef CONFIG_PREEMPT_TRACER |
Steven Rostedt (VMware) | 3f1756d | 2018-08-08 21:28:05 -0400 | [diff] [blame] | 656 | void tracer_preempt_on(unsigned long a0, unsigned long a1) |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 657 | { |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 658 | if (preempt_trace(preempt_count()) && !irq_trace()) |
| 659 | stop_critical_timing(a0, a1); |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Steven Rostedt (VMware) | 3f1756d | 2018-08-08 21:28:05 -0400 | [diff] [blame] | 662 | void tracer_preempt_off(unsigned long a0, unsigned long a1) |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 663 | { |
Sebastian Andrzej Siewior | 36590c50 | 2021-01-25 20:45:08 +0100 | [diff] [blame] | 664 | if (preempt_trace(preempt_count()) && !irq_trace()) |
| 665 | start_critical_timing(a0, a1); |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 666 | } |
| 667 | |
Frederic Weisbecker | 1c80025 | 2008-11-16 05:57:26 +0100 | [diff] [blame] | 668 | static int preemptoff_tracer_init(struct trace_array *tr) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 669 | { |
| 670 | trace_type = TRACER_PREEMPT_OFF; |
| 671 | |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 672 | return __irqsoff_tracer_init(tr); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 673 | } |
| 674 | |
Joel Fernandes (Google) | 2b27ece | 2018-06-28 11:21:45 -0700 | [diff] [blame] | 675 | static void preemptoff_tracer_reset(struct trace_array *tr) |
| 676 | { |
| 677 | __irqsoff_tracer_reset(tr); |
| 678 | } |
| 679 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 680 | static struct tracer preemptoff_tracer __read_mostly = |
| 681 | { |
| 682 | .name = "preemptoff", |
| 683 | .init = preemptoff_tracer_init, |
Joel Fernandes (Google) | 2b27ece | 2018-06-28 11:21:45 -0700 | [diff] [blame] | 684 | .reset = preemptoff_tracer_reset, |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 685 | .start = irqsoff_tracer_start, |
| 686 | .stop = irqsoff_tracer_stop, |
Hiraku Toyooka | f43c738 | 2012-10-02 17:27:10 +0900 | [diff] [blame] | 687 | .print_max = true, |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 688 | .print_header = irqsoff_print_header, |
| 689 | .print_line = irqsoff_print_line, |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 690 | .flag_changed = irqsoff_flag_changed, |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 691 | #ifdef CONFIG_FTRACE_SELFTEST |
| 692 | .selftest = trace_selftest_startup_preemptoff, |
| 693 | #endif |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 694 | .open = irqsoff_trace_open, |
| 695 | .close = irqsoff_trace_close, |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 696 | .allow_instances = true, |
Hiraku Toyooka | f43c738 | 2012-10-02 17:27:10 +0900 | [diff] [blame] | 697 | .use_max_tr = true, |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 698 | }; |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 699 | #endif /* CONFIG_PREEMPT_TRACER */ |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 700 | |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 701 | #if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 702 | |
Frederic Weisbecker | 1c80025 | 2008-11-16 05:57:26 +0100 | [diff] [blame] | 703 | static int preemptirqsoff_tracer_init(struct trace_array *tr) |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 704 | { |
| 705 | trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF; |
| 706 | |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 707 | return __irqsoff_tracer_init(tr); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 708 | } |
| 709 | |
Joel Fernandes (Google) | 2b27ece | 2018-06-28 11:21:45 -0700 | [diff] [blame] | 710 | static void preemptirqsoff_tracer_reset(struct trace_array *tr) |
| 711 | { |
| 712 | __irqsoff_tracer_reset(tr); |
| 713 | } |
| 714 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 715 | static struct tracer preemptirqsoff_tracer __read_mostly = |
| 716 | { |
| 717 | .name = "preemptirqsoff", |
| 718 | .init = preemptirqsoff_tracer_init, |
Joel Fernandes (Google) | 2b27ece | 2018-06-28 11:21:45 -0700 | [diff] [blame] | 719 | .reset = preemptirqsoff_tracer_reset, |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 720 | .start = irqsoff_tracer_start, |
| 721 | .stop = irqsoff_tracer_stop, |
Hiraku Toyooka | f43c738 | 2012-10-02 17:27:10 +0900 | [diff] [blame] | 722 | .print_max = true, |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 723 | .print_header = irqsoff_print_header, |
| 724 | .print_line = irqsoff_print_line, |
Steven Rostedt (Red Hat) | 328df47 | 2013-03-14 12:10:40 -0400 | [diff] [blame] | 725 | .flag_changed = irqsoff_flag_changed, |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 726 | #ifdef CONFIG_FTRACE_SELFTEST |
| 727 | .selftest = trace_selftest_startup_preemptirqsoff, |
| 728 | #endif |
Jiri Olsa | 62b915f | 2010-04-02 19:01:22 +0200 | [diff] [blame] | 729 | .open = irqsoff_trace_open, |
| 730 | .close = irqsoff_trace_close, |
Steven Rostedt (Red Hat) | 02f2f76 | 2014-01-14 09:32:58 -0500 | [diff] [blame] | 731 | .allow_instances = true, |
Hiraku Toyooka | f43c738 | 2012-10-02 17:27:10 +0900 | [diff] [blame] | 732 | .use_max_tr = true, |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 733 | }; |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 734 | #endif |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 735 | |
| 736 | __init static int init_irqsoff_tracer(void) |
| 737 | { |
Joel Fernandes (Google) | c3bc8fd | 2018-07-30 15:24:23 -0700 | [diff] [blame] | 738 | #ifdef CONFIG_IRQSOFF_TRACER |
| 739 | register_tracer(&irqsoff_tracer); |
| 740 | #endif |
| 741 | #ifdef CONFIG_PREEMPT_TRACER |
| 742 | register_tracer(&preemptoff_tracer); |
| 743 | #endif |
| 744 | #if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER) |
| 745 | register_tracer(&preemptirqsoff_tracer); |
| 746 | #endif |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 747 | |
| 748 | return 0; |
| 749 | } |
Steven Rostedt | 6f41567 | 2012-10-05 12:13:07 -0400 | [diff] [blame] | 750 | core_initcall(init_irqsoff_tracer); |
Joel Fernandes | aaecaa0 | 2017-10-05 17:54:31 -0700 | [diff] [blame] | 751 | #endif /* IRQSOFF_TRACER || PREEMPTOFF_TRACER */ |