1 // SPDX-License-Identifier: GPL-2.0 << 2 /* 1 /* 3 * trace irqs off critical timings 2 * trace irqs off critical timings 4 * 3 * 5 * Copyright (C) 2007-2008 Steven Rostedt <sro 4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> 6 * Copyright (C) 2008 Ingo Molnar <mingo@redha 5 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com> 7 * 6 * 8 * From code in the latency_tracer, that is: 7 * From code in the latency_tracer, that is: 9 * 8 * 10 * Copyright (C) 2004-2006 Ingo Molnar 9 * Copyright (C) 2004-2006 Ingo Molnar 11 * Copyright (C) 2004 Nadia Yvette Chambers 10 * Copyright (C) 2004 Nadia Yvette Chambers 12 */ 11 */ 13 #include <linux/kallsyms.h> 12 #include <linux/kallsyms.h> 14 #include <linux/uaccess.h> 13 #include <linux/uaccess.h> 15 #include <linux/module.h> 14 #include <linux/module.h> 16 #include <linux/ftrace.h> 15 #include <linux/ftrace.h> 17 #include <linux/kprobes.h> << 18 16 19 #include "trace.h" 17 #include "trace.h" 20 18 >> 19 #define CREATE_TRACE_POINTS 21 #include <trace/events/preemptirq.h> 20 #include <trace/events/preemptirq.h> 22 21 23 #if defined(CONFIG_IRQSOFF_TRACER) || defined( 22 #if defined(CONFIG_IRQSOFF_TRACER) || defined(CONFIG_PREEMPT_TRACER) 24 static struct trace_array *irqso 23 static struct trace_array *irqsoff_trace __read_mostly; 25 static int tracer 24 static int tracer_enabled __read_mostly; 26 25 27 static DEFINE_PER_CPU(int, tracing_cpu); 26 static DEFINE_PER_CPU(int, tracing_cpu); 28 27 29 static DEFINE_RAW_SPINLOCK(max_trace_lock); 28 static DEFINE_RAW_SPINLOCK(max_trace_lock); 30 29 31 enum { 30 enum { 32 TRACER_IRQS_OFF = (1 << 1), 31 TRACER_IRQS_OFF = (1 << 1), 33 TRACER_PREEMPT_OFF = (1 << 2), 32 TRACER_PREEMPT_OFF = (1 << 2), 34 }; 33 }; 35 34 36 static int trace_type __read_mostly; 35 static int trace_type __read_mostly; 37 36 38 static int save_flags; 37 static int save_flags; 39 38 40 static void stop_irqsoff_tracer(struct trace_a 39 static void stop_irqsoff_tracer(struct trace_array *tr, int graph); 41 static int start_irqsoff_tracer(struct trace_a 40 static int start_irqsoff_tracer(struct trace_array *tr, int graph); 42 41 43 #ifdef CONFIG_PREEMPT_TRACER 42 #ifdef CONFIG_PREEMPT_TRACER 44 static inline int 43 static inline int 45 preempt_trace(int pc) !! 44 preempt_trace(void) 46 { 45 { 47 return ((trace_type & TRACER_PREEMPT_O !! 46 return ((trace_type & TRACER_PREEMPT_OFF) && preempt_count()); 48 } 47 } 49 #else 48 #else 50 # define preempt_trace(pc) (0) !! 49 # define preempt_trace() (0) 51 #endif 50 #endif 52 51 53 #ifdef CONFIG_IRQSOFF_TRACER 52 #ifdef CONFIG_IRQSOFF_TRACER 54 static inline int 53 static inline int 55 irq_trace(void) 54 irq_trace(void) 56 { 55 { 57 return ((trace_type & TRACER_IRQS_OFF) 56 return ((trace_type & TRACER_IRQS_OFF) && 58 irqs_disabled()); 57 irqs_disabled()); 59 } 58 } 60 #else 59 #else 61 # define irq_trace() (0) 60 # define irq_trace() (0) 62 #endif 61 #endif 63 62 64 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 63 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 65 static int irqsoff_display_graph(struct trace_ 64 static int irqsoff_display_graph(struct trace_array *tr, int set); 66 # define is_graph(tr) ((tr)->trace_flags & TRA 65 # define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH) 67 #else 66 #else 68 static inline int irqsoff_display_graph(struct 67 static inline int irqsoff_display_graph(struct trace_array *tr, int set) 69 { 68 { 70 return -EINVAL; 69 return -EINVAL; 71 } 70 } 72 # define is_graph(tr) false 71 # define is_graph(tr) false 73 #endif 72 #endif 74 73 75 /* 74 /* 76 * Sequence count - we record it when starting 75 * Sequence count - we record it when starting a measurement and 77 * skip the latency if the sequence has change 76 * skip the latency if the sequence has changed - some other section 78 * did a maximum and could disturb our measure 77 * did a maximum and could disturb our measurement with serial console 79 * printouts, etc. Truly coinciding maximum la 78 * printouts, etc. Truly coinciding maximum latencies should be rare 80 * and what happens together happens separatel 79 * and what happens together happens separately as well, so this doesn't 81 * decrease the validity of the maximum found: 80 * decrease the validity of the maximum found: 82 */ 81 */ 83 static __cacheline_aligned_in_smp unsign 82 static __cacheline_aligned_in_smp unsigned long max_sequence; 84 83 85 #ifdef CONFIG_FUNCTION_TRACER 84 #ifdef CONFIG_FUNCTION_TRACER 86 /* 85 /* 87 * Prologue for the preempt and irqs off funct 86 * Prologue for the preempt and irqs off function tracers. 88 * 87 * 89 * Returns 1 if it is OK to continue, and data 88 * Returns 1 if it is OK to continue, and data->disabled is 90 * incremented. 89 * incremented. 91 * 0 if the trace is to be ignored, an 90 * 0 if the trace is to be ignored, and data->disabled 92 * is kept the same. 91 * is kept the same. 93 * 92 * 94 * Note, this function is also used outside th 93 * Note, this function is also used outside this ifdef but 95 * inside the #ifdef of the function graph tr 94 * inside the #ifdef of the function graph tracer below. 96 * This is OK, since the function graph trace 95 * This is OK, since the function graph tracer is 97 * dependent on the function tracer. 96 * dependent on the function tracer. 98 */ 97 */ 99 static int func_prolog_dec(struct trace_array 98 static int func_prolog_dec(struct trace_array *tr, 100 struct trace_array_ 99 struct trace_array_cpu **data, 101 unsigned long *flag 100 unsigned long *flags) 102 { 101 { 103 long disabled; 102 long disabled; 104 int cpu; 103 int cpu; 105 104 106 /* 105 /* 107 * Does not matter if we preempt. We t 106 * Does not matter if we preempt. We test the flags 108 * afterward, to see if irqs are disab 107 * afterward, to see if irqs are disabled or not. 109 * If we preempt and get a false posit 108 * If we preempt and get a false positive, the flags 110 * test will fail. 109 * test will fail. 111 */ 110 */ 112 cpu = raw_smp_processor_id(); 111 cpu = raw_smp_processor_id(); 113 if (likely(!per_cpu(tracing_cpu, cpu)) 112 if (likely(!per_cpu(tracing_cpu, cpu))) 114 return 0; 113 return 0; 115 114 116 local_save_flags(*flags); 115 local_save_flags(*flags); 117 /* 116 /* 118 * Slight chance to get a false positi 117 * Slight chance to get a false positive on tracing_cpu, 119 * although I'm starting to think ther 118 * although I'm starting to think there isn't a chance. 120 * Leave this for now just to be paran 119 * Leave this for now just to be paranoid. 121 */ 120 */ 122 if (!irqs_disabled_flags(*flags) && !p 121 if (!irqs_disabled_flags(*flags) && !preempt_count()) 123 return 0; 122 return 0; 124 123 125 *data = per_cpu_ptr(tr->array_buffer.d !! 124 *data = per_cpu_ptr(tr->trace_buffer.data, cpu); 126 disabled = atomic_inc_return(&(*data)- 125 disabled = atomic_inc_return(&(*data)->disabled); 127 126 128 if (likely(disabled == 1)) 127 if (likely(disabled == 1)) 129 return 1; 128 return 1; 130 129 131 atomic_dec(&(*data)->disabled); 130 atomic_dec(&(*data)->disabled); 132 131 133 return 0; 132 return 0; 134 } 133 } 135 134 136 /* 135 /* 137 * irqsoff uses its own tracer function to kee 136 * irqsoff uses its own tracer function to keep the overhead down: 138 */ 137 */ 139 static void 138 static void 140 irqsoff_tracer_call(unsigned long ip, unsigned 139 irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip, 141 struct ftrace_ops *op, str !! 140 struct ftrace_ops *op, struct pt_regs *pt_regs) 142 { 141 { 143 struct trace_array *tr = irqsoff_trace 142 struct trace_array *tr = irqsoff_trace; 144 struct trace_array_cpu *data; 143 struct trace_array_cpu *data; 145 unsigned long flags; 144 unsigned long flags; 146 unsigned int trace_ctx; << 147 145 148 if (!func_prolog_dec(tr, &data, &flags 146 if (!func_prolog_dec(tr, &data, &flags)) 149 return; 147 return; 150 148 151 trace_ctx = tracing_gen_ctx_flags(flag !! 149 trace_function(tr, ip, parent_ip, flags, preempt_count()); 152 << 153 trace_function(tr, ip, parent_ip, trac << 154 150 155 atomic_dec(&data->disabled); 151 atomic_dec(&data->disabled); 156 } 152 } 157 #endif /* CONFIG_FUNCTION_TRACER */ 153 #endif /* CONFIG_FUNCTION_TRACER */ 158 154 159 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 155 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 160 static int irqsoff_display_graph(struct trace_ 156 static int irqsoff_display_graph(struct trace_array *tr, int set) 161 { 157 { 162 int cpu; 158 int cpu; 163 159 164 if (!(is_graph(tr) ^ set)) 160 if (!(is_graph(tr) ^ set)) 165 return 0; 161 return 0; 166 162 167 stop_irqsoff_tracer(irqsoff_trace, !se 163 stop_irqsoff_tracer(irqsoff_trace, !set); 168 164 169 for_each_possible_cpu(cpu) 165 for_each_possible_cpu(cpu) 170 per_cpu(tracing_cpu, cpu) = 0; 166 per_cpu(tracing_cpu, cpu) = 0; 171 167 172 tr->max_latency = 0; 168 tr->max_latency = 0; 173 tracing_reset_online_cpus(&irqsoff_tra !! 169 tracing_reset_online_cpus(&irqsoff_trace->trace_buffer); 174 170 175 return start_irqsoff_tracer(irqsoff_tr 171 return start_irqsoff_tracer(irqsoff_trace, set); 176 } 172 } 177 173 178 static int irqsoff_graph_entry(struct ftrace_g !! 174 static int irqsoff_graph_entry(struct ftrace_graph_ent *trace) 179 struct fgraph_o << 180 { 175 { 181 struct trace_array *tr = irqsoff_trace 176 struct trace_array *tr = irqsoff_trace; 182 struct trace_array_cpu *data; 177 struct trace_array_cpu *data; 183 unsigned long flags; 178 unsigned long flags; 184 unsigned int trace_ctx; << 185 int ret; 179 int ret; >> 180 int pc; 186 181 187 if (ftrace_graph_ignore_func(gops, tra !! 182 if (ftrace_graph_ignore_func(trace)) 188 return 0; 183 return 0; 189 /* 184 /* 190 * Do not trace a function if it's fil 185 * Do not trace a function if it's filtered by set_graph_notrace. 191 * Make the index of ret stack negativ 186 * Make the index of ret stack negative to indicate that it should 192 * ignore further functions. But it n 187 * ignore further functions. But it needs its own ret stack entry 193 * to recover the original index in or 188 * to recover the original index in order to continue tracing after 194 * returning from the function. 189 * returning from the function. 195 */ 190 */ 196 if (ftrace_graph_notrace_addr(trace->f 191 if (ftrace_graph_notrace_addr(trace->func)) 197 return 1; 192 return 1; 198 193 199 if (!func_prolog_dec(tr, &data, &flags 194 if (!func_prolog_dec(tr, &data, &flags)) 200 return 0; 195 return 0; 201 196 202 trace_ctx = tracing_gen_ctx_flags(flag !! 197 pc = preempt_count(); 203 ret = __trace_graph_entry(tr, trace, t !! 198 ret = __trace_graph_entry(tr, trace, flags, pc); 204 atomic_dec(&data->disabled); 199 atomic_dec(&data->disabled); 205 200 206 return ret; 201 return ret; 207 } 202 } 208 203 209 static void irqsoff_graph_return(struct ftrace !! 204 static void irqsoff_graph_return(struct ftrace_graph_ret *trace) 210 struct fgraph << 211 { 205 { 212 struct trace_array *tr = irqsoff_trace 206 struct trace_array *tr = irqsoff_trace; 213 struct trace_array_cpu *data; 207 struct trace_array_cpu *data; 214 unsigned long flags; 208 unsigned long flags; 215 unsigned int trace_ctx; !! 209 int pc; 216 << 217 ftrace_graph_addr_finish(gops, trace); << 218 210 219 if (!func_prolog_dec(tr, &data, &flags 211 if (!func_prolog_dec(tr, &data, &flags)) 220 return; 212 return; 221 213 222 trace_ctx = tracing_gen_ctx_flags(flag !! 214 pc = preempt_count(); 223 __trace_graph_return(tr, trace, trace_ !! 215 __trace_graph_return(tr, trace, flags, pc); 224 atomic_dec(&data->disabled); 216 atomic_dec(&data->disabled); 225 } 217 } 226 218 227 static struct fgraph_ops fgraph_ops = { << 228 .entryfunc = &irqsoff_gra << 229 .retfunc = &irqsoff_gra << 230 }; << 231 << 232 static void irqsoff_trace_open(struct trace_it 219 static void irqsoff_trace_open(struct trace_iterator *iter) 233 { 220 { 234 if (is_graph(iter->tr)) 221 if (is_graph(iter->tr)) 235 graph_trace_open(iter); 222 graph_trace_open(iter); 236 else !! 223 237 iter->private = NULL; << 238 } 224 } 239 225 240 static void irqsoff_trace_close(struct trace_i 226 static void irqsoff_trace_close(struct trace_iterator *iter) 241 { 227 { 242 if (iter->private) 228 if (iter->private) 243 graph_trace_close(iter); 229 graph_trace_close(iter); 244 } 230 } 245 231 246 #define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_ 232 #define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \ 247 TRACE_GRAPH_PRINT_ 233 TRACE_GRAPH_PRINT_PROC | \ 248 TRACE_GRAPH_PRINT_ !! 234 TRACE_GRAPH_PRINT_ABS_TIME | \ 249 TRACE_GRAPH_PRINT_ 235 TRACE_GRAPH_PRINT_DURATION) 250 236 251 static enum print_line_t irqsoff_print_line(st 237 static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) 252 { 238 { 253 /* 239 /* 254 * In graph mode call the graph tracer 240 * In graph mode call the graph tracer output function, 255 * otherwise go with the TRACE_FN even 241 * otherwise go with the TRACE_FN event handler 256 */ 242 */ 257 if (is_graph(iter->tr)) 243 if (is_graph(iter->tr)) 258 return print_graph_function_fl 244 return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS); 259 245 260 return TRACE_TYPE_UNHANDLED; 246 return TRACE_TYPE_UNHANDLED; 261 } 247 } 262 248 263 static void irqsoff_print_header(struct seq_fi 249 static void irqsoff_print_header(struct seq_file *s) 264 { 250 { 265 struct trace_array *tr = irqsoff_trace 251 struct trace_array *tr = irqsoff_trace; 266 252 267 if (is_graph(tr)) 253 if (is_graph(tr)) 268 print_graph_headers_flags(s, G 254 print_graph_headers_flags(s, GRAPH_TRACER_FLAGS); 269 else 255 else 270 trace_default_header(s); 256 trace_default_header(s); 271 } 257 } 272 258 273 static void 259 static void 274 __trace_function(struct trace_array *tr, 260 __trace_function(struct trace_array *tr, 275 unsigned long ip, unsigned lo 261 unsigned long ip, unsigned long parent_ip, 276 unsigned int trace_ctx) !! 262 unsigned long flags, int pc) 277 { 263 { 278 if (is_graph(tr)) 264 if (is_graph(tr)) 279 trace_graph_function(tr, ip, p !! 265 trace_graph_function(tr, ip, parent_ip, flags, pc); 280 else 266 else 281 trace_function(tr, ip, parent_ !! 267 trace_function(tr, ip, parent_ip, flags, pc); 282 } 268 } 283 269 284 #else 270 #else 285 #define __trace_function trace_function 271 #define __trace_function trace_function 286 272 >> 273 #ifdef CONFIG_FUNCTION_TRACER >> 274 static int irqsoff_graph_entry(struct ftrace_graph_ent *trace) >> 275 { >> 276 return -1; >> 277 } >> 278 #endif >> 279 287 static enum print_line_t irqsoff_print_line(st 280 static enum print_line_t irqsoff_print_line(struct trace_iterator *iter) 288 { 281 { 289 return TRACE_TYPE_UNHANDLED; 282 return TRACE_TYPE_UNHANDLED; 290 } 283 } 291 284 292 static void irqsoff_trace_open(struct trace_it 285 static void irqsoff_trace_open(struct trace_iterator *iter) { } 293 static void irqsoff_trace_close(struct trace_i 286 static void irqsoff_trace_close(struct trace_iterator *iter) { } 294 287 295 #ifdef CONFIG_FUNCTION_TRACER 288 #ifdef CONFIG_FUNCTION_TRACER >> 289 static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { } 296 static void irqsoff_print_header(struct seq_fi 290 static void irqsoff_print_header(struct seq_file *s) 297 { 291 { 298 trace_default_header(s); 292 trace_default_header(s); 299 } 293 } 300 #else 294 #else 301 static void irqsoff_print_header(struct seq_fi 295 static void irqsoff_print_header(struct seq_file *s) 302 { 296 { 303 trace_latency_header(s); 297 trace_latency_header(s); 304 } 298 } 305 #endif /* CONFIG_FUNCTION_TRACER */ 299 #endif /* CONFIG_FUNCTION_TRACER */ 306 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 300 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 307 301 308 /* 302 /* 309 * Should this new latency be reported/recorde 303 * Should this new latency be reported/recorded? 310 */ 304 */ 311 static bool report_latency(struct trace_array 305 static bool report_latency(struct trace_array *tr, u64 delta) 312 { 306 { 313 if (tracing_thresh) { 307 if (tracing_thresh) { 314 if (delta < tracing_thresh) 308 if (delta < tracing_thresh) 315 return false; 309 return false; 316 } else { 310 } else { 317 if (delta <= tr->max_latency) 311 if (delta <= tr->max_latency) 318 return false; 312 return false; 319 } 313 } 320 return true; 314 return true; 321 } 315 } 322 316 323 static void 317 static void 324 check_critical_timing(struct trace_array *tr, 318 check_critical_timing(struct trace_array *tr, 325 struct trace_array_cpu * 319 struct trace_array_cpu *data, 326 unsigned long parent_ip, 320 unsigned long parent_ip, 327 int cpu) 321 int cpu) 328 { 322 { 329 u64 T0, T1, delta; 323 u64 T0, T1, delta; 330 unsigned long flags; 324 unsigned long flags; 331 unsigned int trace_ctx; !! 325 int pc; 332 326 333 T0 = data->preempt_timestamp; 327 T0 = data->preempt_timestamp; 334 T1 = ftrace_now(cpu); 328 T1 = ftrace_now(cpu); 335 delta = T1-T0; 329 delta = T1-T0; 336 330 337 trace_ctx = tracing_gen_ctx(); !! 331 local_save_flags(flags); >> 332 >> 333 pc = preempt_count(); 338 334 339 if (!report_latency(tr, delta)) 335 if (!report_latency(tr, delta)) 340 goto out; 336 goto out; 341 337 342 raw_spin_lock_irqsave(&max_trace_lock, 338 raw_spin_lock_irqsave(&max_trace_lock, flags); 343 339 344 /* check if we are still the max laten 340 /* check if we are still the max latency */ 345 if (!report_latency(tr, delta)) 341 if (!report_latency(tr, delta)) 346 goto out_unlock; 342 goto out_unlock; 347 343 348 __trace_function(tr, CALLER_ADDR0, par !! 344 __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc); 349 /* Skip 5 functions to get to the irq/ 345 /* Skip 5 functions to get to the irq/preempt enable function */ 350 __trace_stack(tr, trace_ctx, 5); !! 346 __trace_stack(tr, flags, 5, pc); 351 347 352 if (data->critical_sequence != max_seq 348 if (data->critical_sequence != max_sequence) 353 goto out_unlock; 349 goto out_unlock; 354 350 355 data->critical_end = parent_ip; 351 data->critical_end = parent_ip; 356 352 357 if (likely(!is_tracing_stopped())) { 353 if (likely(!is_tracing_stopped())) { 358 tr->max_latency = delta; 354 tr->max_latency = delta; 359 update_max_tr_single(tr, curre 355 update_max_tr_single(tr, current, cpu); 360 } 356 } 361 357 362 max_sequence++; 358 max_sequence++; 363 359 364 out_unlock: 360 out_unlock: 365 raw_spin_unlock_irqrestore(&max_trace_ 361 raw_spin_unlock_irqrestore(&max_trace_lock, flags); 366 362 367 out: 363 out: 368 data->critical_sequence = max_sequence 364 data->critical_sequence = max_sequence; 369 data->preempt_timestamp = ftrace_now(c 365 data->preempt_timestamp = ftrace_now(cpu); 370 __trace_function(tr, CALLER_ADDR0, par !! 366 __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc); 371 } 367 } 372 368 373 static nokprobe_inline void !! 369 static inline void 374 start_critical_timing(unsigned long ip, unsign 370 start_critical_timing(unsigned long ip, unsigned long parent_ip) 375 { 371 { 376 int cpu; 372 int cpu; 377 struct trace_array *tr = irqsoff_trace 373 struct trace_array *tr = irqsoff_trace; 378 struct trace_array_cpu *data; 374 struct trace_array_cpu *data; >> 375 unsigned long flags; 379 376 380 if (!tracer_enabled || !tracing_is_ena 377 if (!tracer_enabled || !tracing_is_enabled()) 381 return; 378 return; 382 379 383 cpu = raw_smp_processor_id(); 380 cpu = raw_smp_processor_id(); 384 381 385 if (per_cpu(tracing_cpu, cpu)) 382 if (per_cpu(tracing_cpu, cpu)) 386 return; 383 return; 387 384 388 data = per_cpu_ptr(tr->array_buffer.da !! 385 data = per_cpu_ptr(tr->trace_buffer.data, cpu); 389 386 390 if (unlikely(!data) || atomic_read(&da 387 if (unlikely(!data) || atomic_read(&data->disabled)) 391 return; 388 return; 392 389 393 atomic_inc(&data->disabled); 390 atomic_inc(&data->disabled); 394 391 395 data->critical_sequence = max_sequence 392 data->critical_sequence = max_sequence; 396 data->preempt_timestamp = ftrace_now(c 393 data->preempt_timestamp = ftrace_now(cpu); 397 data->critical_start = parent_ip ? : i 394 data->critical_start = parent_ip ? : ip; 398 395 399 __trace_function(tr, ip, parent_ip, tr !! 396 local_save_flags(flags); >> 397 >> 398 __trace_function(tr, ip, parent_ip, flags, preempt_count()); 400 399 401 per_cpu(tracing_cpu, cpu) = 1; 400 per_cpu(tracing_cpu, cpu) = 1; 402 401 403 atomic_dec(&data->disabled); 402 atomic_dec(&data->disabled); 404 } 403 } 405 404 406 static nokprobe_inline void !! 405 static inline void 407 stop_critical_timing(unsigned long ip, unsigne 406 stop_critical_timing(unsigned long ip, unsigned long parent_ip) 408 { 407 { 409 int cpu; 408 int cpu; 410 struct trace_array *tr = irqsoff_trace 409 struct trace_array *tr = irqsoff_trace; 411 struct trace_array_cpu *data; 410 struct trace_array_cpu *data; 412 unsigned int trace_ctx; !! 411 unsigned long flags; 413 412 414 cpu = raw_smp_processor_id(); 413 cpu = raw_smp_processor_id(); 415 /* Always clear the tracing cpu on sto 414 /* Always clear the tracing cpu on stopping the trace */ 416 if (unlikely(per_cpu(tracing_cpu, cpu) 415 if (unlikely(per_cpu(tracing_cpu, cpu))) 417 per_cpu(tracing_cpu, cpu) = 0; 416 per_cpu(tracing_cpu, cpu) = 0; 418 else 417 else 419 return; 418 return; 420 419 421 if (!tracer_enabled || !tracing_is_ena 420 if (!tracer_enabled || !tracing_is_enabled()) 422 return; 421 return; 423 422 424 data = per_cpu_ptr(tr->array_buffer.da !! 423 data = per_cpu_ptr(tr->trace_buffer.data, cpu); 425 424 426 if (unlikely(!data) || 425 if (unlikely(!data) || 427 !data->critical_start || atomic_re 426 !data->critical_start || atomic_read(&data->disabled)) 428 return; 427 return; 429 428 430 atomic_inc(&data->disabled); 429 atomic_inc(&data->disabled); 431 430 432 trace_ctx = tracing_gen_ctx(); !! 431 local_save_flags(flags); 433 __trace_function(tr, ip, parent_ip, tr !! 432 __trace_function(tr, ip, parent_ip, flags, preempt_count()); 434 check_critical_timing(tr, data, parent 433 check_critical_timing(tr, data, parent_ip ? : ip, cpu); 435 data->critical_start = 0; 434 data->critical_start = 0; 436 atomic_dec(&data->disabled); 435 atomic_dec(&data->disabled); 437 } 436 } 438 437 439 /* start and stop critical timings used to for 438 /* start and stop critical timings used to for stoppage (in idle) */ 440 void start_critical_timings(void) 439 void start_critical_timings(void) 441 { 440 { 442 if (preempt_trace(preempt_count()) || !! 441 if (preempt_trace() || irq_trace()) 443 start_critical_timing(CALLER_A 442 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1); 444 } 443 } 445 EXPORT_SYMBOL_GPL(start_critical_timings); 444 EXPORT_SYMBOL_GPL(start_critical_timings); 446 NOKPROBE_SYMBOL(start_critical_timings); << 447 445 448 void stop_critical_timings(void) 446 void stop_critical_timings(void) 449 { 447 { 450 if (preempt_trace(preempt_count()) || !! 448 if (preempt_trace() || irq_trace()) 451 stop_critical_timing(CALLER_AD 449 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1); 452 } 450 } 453 EXPORT_SYMBOL_GPL(stop_critical_timings); 451 EXPORT_SYMBOL_GPL(stop_critical_timings); 454 NOKPROBE_SYMBOL(stop_critical_timings); !! 452 >> 453 #ifdef CONFIG_IRQSOFF_TRACER >> 454 #ifdef CONFIG_PROVE_LOCKING >> 455 void time_hardirqs_on(unsigned long a0, unsigned long a1) >> 456 { >> 457 if (!preempt_trace() && irq_trace()) >> 458 stop_critical_timing(a0, a1); >> 459 } >> 460 >> 461 void time_hardirqs_off(unsigned long a0, unsigned long a1) >> 462 { >> 463 if (!preempt_trace() && irq_trace()) >> 464 start_critical_timing(a0, a1); >> 465 } >> 466 >> 467 #else /* !CONFIG_PROVE_LOCKING */ >> 468 >> 469 /* >> 470 * We are only interested in hardirq on/off events: >> 471 */ >> 472 static inline void tracer_hardirqs_on(void) >> 473 { >> 474 if (!preempt_trace() && irq_trace()) >> 475 stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1); >> 476 } >> 477 >> 478 static inline void tracer_hardirqs_off(void) >> 479 { >> 480 if (!preempt_trace() && irq_trace()) >> 481 start_critical_timing(CALLER_ADDR0, CALLER_ADDR1); >> 482 } >> 483 >> 484 static inline void tracer_hardirqs_on_caller(unsigned long caller_addr) >> 485 { >> 486 if (!preempt_trace() && irq_trace()) >> 487 stop_critical_timing(CALLER_ADDR0, caller_addr); >> 488 } >> 489 >> 490 static inline void tracer_hardirqs_off_caller(unsigned long caller_addr) >> 491 { >> 492 if (!preempt_trace() && irq_trace()) >> 493 start_critical_timing(CALLER_ADDR0, caller_addr); >> 494 } >> 495 >> 496 #endif /* CONFIG_PROVE_LOCKING */ >> 497 #endif /* CONFIG_IRQSOFF_TRACER */ >> 498 >> 499 #ifdef CONFIG_PREEMPT_TRACER >> 500 static inline void tracer_preempt_on(unsigned long a0, unsigned long a1) >> 501 { >> 502 if (preempt_trace() && !irq_trace()) >> 503 stop_critical_timing(a0, a1); >> 504 } >> 505 >> 506 static inline void tracer_preempt_off(unsigned long a0, unsigned long a1) >> 507 { >> 508 if (preempt_trace() && !irq_trace()) >> 509 start_critical_timing(a0, a1); >> 510 } >> 511 #endif /* CONFIG_PREEMPT_TRACER */ 455 512 456 #ifdef CONFIG_FUNCTION_TRACER 513 #ifdef CONFIG_FUNCTION_TRACER 457 static bool function_enabled; 514 static bool function_enabled; 458 515 459 static int register_irqsoff_function(struct tr 516 static int register_irqsoff_function(struct trace_array *tr, int graph, int set) 460 { 517 { 461 int ret; 518 int ret; 462 519 463 /* 'set' is set if TRACE_ITER_FUNCTION 520 /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */ 464 if (function_enabled || (!set && !(tr- 521 if (function_enabled || (!set && !(tr->trace_flags & TRACE_ITER_FUNCTION))) 465 return 0; 522 return 0; 466 523 467 if (graph) 524 if (graph) 468 ret = register_ftrace_graph(&f !! 525 ret = register_ftrace_graph(&irqsoff_graph_return, >> 526 &irqsoff_graph_entry); 469 else 527 else 470 ret = register_ftrace_function 528 ret = register_ftrace_function(tr->ops); 471 529 472 if (!ret) 530 if (!ret) 473 function_enabled = true; 531 function_enabled = true; 474 532 475 return ret; 533 return ret; 476 } 534 } 477 535 478 static void unregister_irqsoff_function(struct 536 static void unregister_irqsoff_function(struct trace_array *tr, int graph) 479 { 537 { 480 if (!function_enabled) 538 if (!function_enabled) 481 return; 539 return; 482 540 483 if (graph) 541 if (graph) 484 unregister_ftrace_graph(&fgrap !! 542 unregister_ftrace_graph(); 485 else 543 else 486 unregister_ftrace_function(tr- 544 unregister_ftrace_function(tr->ops); 487 545 488 function_enabled = false; 546 function_enabled = false; 489 } 547 } 490 548 491 static int irqsoff_function_set(struct trace_a 549 static int irqsoff_function_set(struct trace_array *tr, u32 mask, int set) 492 { 550 { 493 if (!(mask & TRACE_ITER_FUNCTION)) 551 if (!(mask & TRACE_ITER_FUNCTION)) 494 return 0; 552 return 0; 495 553 496 if (set) 554 if (set) 497 register_irqsoff_function(tr, 555 register_irqsoff_function(tr, is_graph(tr), 1); 498 else 556 else 499 unregister_irqsoff_function(tr 557 unregister_irqsoff_function(tr, is_graph(tr)); 500 return 1; 558 return 1; 501 } 559 } 502 #else 560 #else 503 static int register_irqsoff_function(struct tr 561 static int register_irqsoff_function(struct trace_array *tr, int graph, int set) 504 { 562 { 505 return 0; 563 return 0; 506 } 564 } 507 static void unregister_irqsoff_function(struct 565 static void unregister_irqsoff_function(struct trace_array *tr, int graph) { } 508 static inline int irqsoff_function_set(struct 566 static inline int irqsoff_function_set(struct trace_array *tr, u32 mask, int set) 509 { 567 { 510 return 0; 568 return 0; 511 } 569 } 512 #endif /* CONFIG_FUNCTION_TRACER */ 570 #endif /* CONFIG_FUNCTION_TRACER */ 513 571 514 static int irqsoff_flag_changed(struct trace_a 572 static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set) 515 { 573 { 516 struct tracer *tracer = tr->current_tr 574 struct tracer *tracer = tr->current_trace; 517 575 518 if (irqsoff_function_set(tr, mask, set 576 if (irqsoff_function_set(tr, mask, set)) 519 return 0; 577 return 0; 520 578 521 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 579 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 522 if (mask & TRACE_ITER_DISPLAY_GRAPH) 580 if (mask & TRACE_ITER_DISPLAY_GRAPH) 523 return irqsoff_display_graph(t 581 return irqsoff_display_graph(tr, set); 524 #endif 582 #endif 525 583 526 return trace_keep_overwrite(tracer, ma 584 return trace_keep_overwrite(tracer, mask, set); 527 } 585 } 528 586 529 static int start_irqsoff_tracer(struct trace_a 587 static int start_irqsoff_tracer(struct trace_array *tr, int graph) 530 { 588 { 531 int ret; 589 int ret; 532 590 533 ret = register_irqsoff_function(tr, gr 591 ret = register_irqsoff_function(tr, graph, 0); 534 592 535 if (!ret && tracing_is_enabled()) 593 if (!ret && tracing_is_enabled()) 536 tracer_enabled = 1; 594 tracer_enabled = 1; 537 else 595 else 538 tracer_enabled = 0; 596 tracer_enabled = 0; 539 597 540 return ret; 598 return ret; 541 } 599 } 542 600 543 static void stop_irqsoff_tracer(struct trace_a 601 static void stop_irqsoff_tracer(struct trace_array *tr, int graph) 544 { 602 { 545 tracer_enabled = 0; 603 tracer_enabled = 0; 546 604 547 unregister_irqsoff_function(tr, graph) 605 unregister_irqsoff_function(tr, graph); 548 } 606 } 549 607 550 static bool irqsoff_busy; 608 static bool irqsoff_busy; 551 609 552 static int __irqsoff_tracer_init(struct trace_ 610 static int __irqsoff_tracer_init(struct trace_array *tr) 553 { 611 { 554 if (irqsoff_busy) 612 if (irqsoff_busy) 555 return -EBUSY; 613 return -EBUSY; 556 614 557 save_flags = tr->trace_flags; 615 save_flags = tr->trace_flags; 558 616 559 /* non overwrite screws up the latency 617 /* non overwrite screws up the latency tracers */ 560 set_tracer_flag(tr, TRACE_ITER_OVERWRI 618 set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1); 561 set_tracer_flag(tr, TRACE_ITER_LATENCY 619 set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1); 562 /* without pause, we will produce garb << 563 set_tracer_flag(tr, TRACE_ITER_PAUSE_O << 564 620 565 tr->max_latency = 0; 621 tr->max_latency = 0; 566 irqsoff_trace = tr; 622 irqsoff_trace = tr; 567 /* make sure that the tracer is visibl 623 /* make sure that the tracer is visible */ 568 smp_wmb(); 624 smp_wmb(); 569 625 570 ftrace_init_array_ops(tr, irqsoff_trac 626 ftrace_init_array_ops(tr, irqsoff_tracer_call); 571 627 572 /* Only toplevel instance supports gra 628 /* Only toplevel instance supports graph tracing */ 573 if (start_irqsoff_tracer(tr, (tr->flag 629 if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL && 574 is_graph 630 is_graph(tr)))) 575 printk(KERN_ERR "failed to sta 631 printk(KERN_ERR "failed to start irqsoff tracer\n"); 576 632 577 irqsoff_busy = true; 633 irqsoff_busy = true; 578 return 0; 634 return 0; 579 } 635 } 580 636 581 static void __irqsoff_tracer_reset(struct trac !! 637 static void irqsoff_tracer_reset(struct trace_array *tr) 582 { 638 { 583 int lat_flag = save_flags & TRACE_ITER 639 int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT; 584 int overwrite_flag = save_flags & TRAC 640 int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE; 585 int pause_flag = save_flags & TRACE_IT << 586 641 587 stop_irqsoff_tracer(tr, is_graph(tr)); 642 stop_irqsoff_tracer(tr, is_graph(tr)); 588 643 589 set_tracer_flag(tr, TRACE_ITER_LATENCY 644 set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag); 590 set_tracer_flag(tr, TRACE_ITER_OVERWRI 645 set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag); 591 set_tracer_flag(tr, TRACE_ITER_PAUSE_O << 592 ftrace_reset_array_ops(tr); 646 ftrace_reset_array_ops(tr); 593 647 594 irqsoff_busy = false; 648 irqsoff_busy = false; 595 } 649 } 596 650 597 static void irqsoff_tracer_start(struct trace_ 651 static void irqsoff_tracer_start(struct trace_array *tr) 598 { 652 { 599 tracer_enabled = 1; 653 tracer_enabled = 1; 600 } 654 } 601 655 602 static void irqsoff_tracer_stop(struct trace_a 656 static void irqsoff_tracer_stop(struct trace_array *tr) 603 { 657 { 604 tracer_enabled = 0; 658 tracer_enabled = 0; 605 } 659 } 606 660 607 #ifdef CONFIG_IRQSOFF_TRACER 661 #ifdef CONFIG_IRQSOFF_TRACER 608 /* << 609 * We are only interested in hardirq on/off ev << 610 */ << 611 void tracer_hardirqs_on(unsigned long a0, unsi << 612 { << 613 if (!preempt_trace(preempt_count()) && << 614 stop_critical_timing(a0, a1); << 615 } << 616 NOKPROBE_SYMBOL(tracer_hardirqs_on); << 617 << 618 void tracer_hardirqs_off(unsigned long a0, uns << 619 { << 620 if (!preempt_trace(preempt_count()) && << 621 start_critical_timing(a0, a1); << 622 } << 623 NOKPROBE_SYMBOL(tracer_hardirqs_off); << 624 << 625 static int irqsoff_tracer_init(struct trace_ar 662 static int irqsoff_tracer_init(struct trace_array *tr) 626 { 663 { 627 trace_type = TRACER_IRQS_OFF; 664 trace_type = TRACER_IRQS_OFF; 628 665 629 return __irqsoff_tracer_init(tr); 666 return __irqsoff_tracer_init(tr); 630 } 667 } 631 << 632 static void irqsoff_tracer_reset(struct trace_ << 633 { << 634 __irqsoff_tracer_reset(tr); << 635 } << 636 << 637 static struct tracer irqsoff_tracer __read_mos 668 static struct tracer irqsoff_tracer __read_mostly = 638 { 669 { 639 .name = "irqsoff", 670 .name = "irqsoff", 640 .init = irqsoff_tracer_init, 671 .init = irqsoff_tracer_init, 641 .reset = irqsoff_tracer_reset 672 .reset = irqsoff_tracer_reset, 642 .start = irqsoff_tracer_start 673 .start = irqsoff_tracer_start, 643 .stop = irqsoff_tracer_stop, 674 .stop = irqsoff_tracer_stop, 644 .print_max = true, 675 .print_max = true, 645 .print_header = irqsoff_print_header 676 .print_header = irqsoff_print_header, 646 .print_line = irqsoff_print_line, 677 .print_line = irqsoff_print_line, 647 .flag_changed = irqsoff_flag_changed 678 .flag_changed = irqsoff_flag_changed, 648 #ifdef CONFIG_FTRACE_SELFTEST 679 #ifdef CONFIG_FTRACE_SELFTEST 649 .selftest = trace_selftest_startup_ 680 .selftest = trace_selftest_startup_irqsoff, 650 #endif 681 #endif 651 .open = irqsoff_trace_open, 682 .open = irqsoff_trace_open, 652 .close = irqsoff_trace_close, 683 .close = irqsoff_trace_close, 653 .allow_instances = true, 684 .allow_instances = true, 654 .use_max_tr = true, 685 .use_max_tr = true, 655 }; 686 }; 656 #endif /* CONFIG_IRQSOFF_TRACER */ !! 687 # define register_irqsoff(trace) register_tracer(&trace) >> 688 #else >> 689 # define register_irqsoff(trace) do { } while (0) >> 690 #endif 657 691 658 #ifdef CONFIG_PREEMPT_TRACER 692 #ifdef CONFIG_PREEMPT_TRACER 659 void tracer_preempt_on(unsigned long a0, unsig << 660 { << 661 if (preempt_trace(preempt_count()) && << 662 stop_critical_timing(a0, a1); << 663 } << 664 << 665 void tracer_preempt_off(unsigned long a0, unsi << 666 { << 667 if (preempt_trace(preempt_count()) && << 668 start_critical_timing(a0, a1); << 669 } << 670 << 671 static int preemptoff_tracer_init(struct trace 693 static int preemptoff_tracer_init(struct trace_array *tr) 672 { 694 { 673 trace_type = TRACER_PREEMPT_OFF; 695 trace_type = TRACER_PREEMPT_OFF; 674 696 675 return __irqsoff_tracer_init(tr); 697 return __irqsoff_tracer_init(tr); 676 } 698 } 677 699 678 static void preemptoff_tracer_reset(struct tra << 679 { << 680 __irqsoff_tracer_reset(tr); << 681 } << 682 << 683 static struct tracer preemptoff_tracer __read_ 700 static struct tracer preemptoff_tracer __read_mostly = 684 { 701 { 685 .name = "preemptoff", 702 .name = "preemptoff", 686 .init = preemptoff_tracer_in 703 .init = preemptoff_tracer_init, 687 .reset = preemptoff_tracer_re !! 704 .reset = irqsoff_tracer_reset, 688 .start = irqsoff_tracer_start 705 .start = irqsoff_tracer_start, 689 .stop = irqsoff_tracer_stop, 706 .stop = irqsoff_tracer_stop, 690 .print_max = true, 707 .print_max = true, 691 .print_header = irqsoff_print_header 708 .print_header = irqsoff_print_header, 692 .print_line = irqsoff_print_line, 709 .print_line = irqsoff_print_line, 693 .flag_changed = irqsoff_flag_changed 710 .flag_changed = irqsoff_flag_changed, 694 #ifdef CONFIG_FTRACE_SELFTEST 711 #ifdef CONFIG_FTRACE_SELFTEST 695 .selftest = trace_selftest_startup_ 712 .selftest = trace_selftest_startup_preemptoff, 696 #endif 713 #endif 697 .open = irqsoff_trace_open, 714 .open = irqsoff_trace_open, 698 .close = irqsoff_trace_close, 715 .close = irqsoff_trace_close, 699 .allow_instances = true, 716 .allow_instances = true, 700 .use_max_tr = true, 717 .use_max_tr = true, 701 }; 718 }; 702 #endif /* CONFIG_PREEMPT_TRACER */ !! 719 # define register_preemptoff(trace) register_tracer(&trace) >> 720 #else >> 721 # define register_preemptoff(trace) do { } while (0) >> 722 #endif 703 723 704 #if defined(CONFIG_IRQSOFF_TRACER) && defined( !! 724 #if defined(CONFIG_IRQSOFF_TRACER) && \ >> 725 defined(CONFIG_PREEMPT_TRACER) 705 726 706 static int preemptirqsoff_tracer_init(struct t 727 static int preemptirqsoff_tracer_init(struct trace_array *tr) 707 { 728 { 708 trace_type = TRACER_IRQS_OFF | TRACER_ 729 trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF; 709 730 710 return __irqsoff_tracer_init(tr); 731 return __irqsoff_tracer_init(tr); 711 } 732 } 712 733 713 static void preemptirqsoff_tracer_reset(struct << 714 { << 715 __irqsoff_tracer_reset(tr); << 716 } << 717 << 718 static struct tracer preemptirqsoff_tracer __r 734 static struct tracer preemptirqsoff_tracer __read_mostly = 719 { 735 { 720 .name = "preemptirqsoff", 736 .name = "preemptirqsoff", 721 .init = preemptirqsoff_trace 737 .init = preemptirqsoff_tracer_init, 722 .reset = preemptirqsoff_trace !! 738 .reset = irqsoff_tracer_reset, 723 .start = irqsoff_tracer_start 739 .start = irqsoff_tracer_start, 724 .stop = irqsoff_tracer_stop, 740 .stop = irqsoff_tracer_stop, 725 .print_max = true, 741 .print_max = true, 726 .print_header = irqsoff_print_header 742 .print_header = irqsoff_print_header, 727 .print_line = irqsoff_print_line, 743 .print_line = irqsoff_print_line, 728 .flag_changed = irqsoff_flag_changed 744 .flag_changed = irqsoff_flag_changed, 729 #ifdef CONFIG_FTRACE_SELFTEST 745 #ifdef CONFIG_FTRACE_SELFTEST 730 .selftest = trace_selftest_startup_ 746 .selftest = trace_selftest_startup_preemptirqsoff, 731 #endif 747 #endif 732 .open = irqsoff_trace_open, 748 .open = irqsoff_trace_open, 733 .close = irqsoff_trace_close, 749 .close = irqsoff_trace_close, 734 .allow_instances = true, 750 .allow_instances = true, 735 .use_max_tr = true, 751 .use_max_tr = true, 736 }; 752 }; >> 753 >> 754 # define register_preemptirqsoff(trace) register_tracer(&trace) >> 755 #else >> 756 # define register_preemptirqsoff(trace) do { } while (0) 737 #endif 757 #endif 738 758 739 __init static int init_irqsoff_tracer(void) 759 __init static int init_irqsoff_tracer(void) 740 { 760 { 741 #ifdef CONFIG_IRQSOFF_TRACER !! 761 register_irqsoff(irqsoff_tracer); 742 register_tracer(&irqsoff_tracer); !! 762 register_preemptoff(preemptoff_tracer); 743 #endif !! 763 register_preemptirqsoff(preemptirqsoff_tracer); 744 #ifdef CONFIG_PREEMPT_TRACER << 745 register_tracer(&preemptoff_tracer); << 746 #endif << 747 #if defined(CONFIG_IRQSOFF_TRACER) && defined( << 748 register_tracer(&preemptirqsoff_tracer << 749 #endif << 750 764 751 return 0; 765 return 0; 752 } 766 } 753 core_initcall(init_irqsoff_tracer); 767 core_initcall(init_irqsoff_tracer); 754 #endif /* IRQSOFF_TRACER || PREEMPTOFF_TRACER 768 #endif /* IRQSOFF_TRACER || PREEMPTOFF_TRACER */ >> 769 >> 770 #ifndef CONFIG_IRQSOFF_TRACER >> 771 static inline void tracer_hardirqs_on(void) { } >> 772 static inline void tracer_hardirqs_off(void) { } >> 773 static inline void tracer_hardirqs_on_caller(unsigned long caller_addr) { } >> 774 static inline void tracer_hardirqs_off_caller(unsigned long caller_addr) { } >> 775 #endif >> 776 >> 777 #ifndef CONFIG_PREEMPT_TRACER >> 778 static inline void tracer_preempt_on(unsigned long a0, unsigned long a1) { } >> 779 static inline void tracer_preempt_off(unsigned long a0, unsigned long a1) { } >> 780 #endif >> 781 >> 782 #if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PROVE_LOCKING) >> 783 /* Per-cpu variable to prevent redundant calls when IRQs already off */ >> 784 static DEFINE_PER_CPU(int, tracing_irq_cpu); >> 785 >> 786 void trace_hardirqs_on(void) >> 787 { >> 788 if (!this_cpu_read(tracing_irq_cpu)) >> 789 return; >> 790 >> 791 trace_irq_enable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); >> 792 tracer_hardirqs_on(); >> 793 >> 794 this_cpu_write(tracing_irq_cpu, 0); >> 795 } >> 796 EXPORT_SYMBOL(trace_hardirqs_on); >> 797 >> 798 void trace_hardirqs_off(void) >> 799 { >> 800 if (this_cpu_read(tracing_irq_cpu)) >> 801 return; >> 802 >> 803 this_cpu_write(tracing_irq_cpu, 1); >> 804 >> 805 trace_irq_disable_rcuidle(CALLER_ADDR0, CALLER_ADDR1); >> 806 tracer_hardirqs_off(); >> 807 } >> 808 EXPORT_SYMBOL(trace_hardirqs_off); >> 809 >> 810 __visible void trace_hardirqs_on_caller(unsigned long caller_addr) >> 811 { >> 812 if (!this_cpu_read(tracing_irq_cpu)) >> 813 return; >> 814 >> 815 trace_irq_enable_rcuidle(CALLER_ADDR0, caller_addr); >> 816 tracer_hardirqs_on_caller(caller_addr); >> 817 >> 818 this_cpu_write(tracing_irq_cpu, 0); >> 819 } >> 820 EXPORT_SYMBOL(trace_hardirqs_on_caller); >> 821 >> 822 __visible void trace_hardirqs_off_caller(unsigned long caller_addr) >> 823 { >> 824 if (this_cpu_read(tracing_irq_cpu)) >> 825 return; >> 826 >> 827 this_cpu_write(tracing_irq_cpu, 1); >> 828 >> 829 trace_irq_disable_rcuidle(CALLER_ADDR0, caller_addr); >> 830 tracer_hardirqs_off_caller(caller_addr); >> 831 } >> 832 EXPORT_SYMBOL(trace_hardirqs_off_caller); >> 833 >> 834 /* >> 835 * Stubs: >> 836 */ >> 837 >> 838 void trace_softirqs_on(unsigned long ip) >> 839 { >> 840 } >> 841 >> 842 void trace_softirqs_off(unsigned long ip) >> 843 { >> 844 } >> 845 >> 846 inline void print_irqtrace_events(struct task_struct *curr) >> 847 { >> 848 } >> 849 #endif >> 850 >> 851 #if defined(CONFIG_PREEMPT_TRACER) || \ >> 852 (defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_PREEMPTIRQ_EVENTS)) >> 853 void trace_preempt_on(unsigned long a0, unsigned long a1) >> 854 { >> 855 trace_preempt_enable_rcuidle(a0, a1); >> 856 tracer_preempt_on(a0, a1); >> 857 } >> 858 >> 859 void trace_preempt_off(unsigned long a0, unsigned long a1) >> 860 { >> 861 trace_preempt_disable_rcuidle(a0, a1); >> 862 tracer_preempt_off(a0, a1); >> 863 } >> 864 #endif 755 865
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.