trace_irqsoff.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /*
  2. * trace irqs off critical timings
  3. *
  4. * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
  5. * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
  6. *
  7. * From code in the latency_tracer, that is:
  8. *
  9. * Copyright (C) 2004-2006 Ingo Molnar
  10. * Copyright (C) 2004 Nadia Yvette Chambers
  11. */
  12. #include <linux/kallsyms.h>
  13. #include <linux/debugfs.h>
  14. #include <linux/uaccess.h>
  15. #include <linux/module.h>
  16. #include <linux/ftrace.h>
  17. #include <linux/fs.h>
  18. #include "trace.h"
  19. static struct trace_array *irqsoff_trace __read_mostly;
  20. static int tracer_enabled __read_mostly;
  21. static DEFINE_PER_CPU(int, tracing_cpu);
  22. static DEFINE_RAW_SPINLOCK(max_trace_lock);
  23. enum {
  24. TRACER_IRQS_OFF = (1 << 1),
  25. TRACER_PREEMPT_OFF = (1 << 2),
  26. };
  27. static int trace_type __read_mostly;
  28. static int save_flags;
  29. static bool function_enabled;
  30. static void stop_irqsoff_tracer(struct trace_array *tr, int graph);
  31. static int start_irqsoff_tracer(struct trace_array *tr, int graph);
  32. #ifdef CONFIG_PREEMPT_TRACER
  33. static inline int
  34. preempt_trace(void)
  35. {
  36. return ((trace_type & TRACER_PREEMPT_OFF) && preempt_count());
  37. }
  38. #else
  39. # define preempt_trace() (0)
  40. #endif
  41. #ifdef CONFIG_IRQSOFF_TRACER
  42. static inline int
  43. irq_trace(void)
  44. {
  45. return ((trace_type & TRACER_IRQS_OFF) &&
  46. irqs_disabled());
  47. }
  48. #else
  49. # define irq_trace() (0)
  50. #endif
  51. #define TRACE_DISPLAY_GRAPH 1
  52. static struct tracer_opt trace_opts[] = {
  53. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  54. /* display latency trace as call graph */
  55. { TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
  56. #endif
  57. { } /* Empty entry */
  58. };
  59. static struct tracer_flags tracer_flags = {
  60. .val = 0,
  61. .opts = trace_opts,
  62. };
  63. #define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
  64. /*
  65. * Sequence count - we record it when starting a measurement and
  66. * skip the latency if the sequence has changed - some other section
  67. * did a maximum and could disturb our measurement with serial console
  68. * printouts, etc. Truly coinciding maximum latencies should be rare
  69. * and what happens together happens separately as well, so this doesn't
  70. * decrease the validity of the maximum found:
  71. */
  72. static __cacheline_aligned_in_smp unsigned long max_sequence;
  73. #ifdef CONFIG_FUNCTION_TRACER
  74. /*
  75. * Prologue for the preempt and irqs off function tracers.
  76. *
  77. * Returns 1 if it is OK to continue, and data->disabled is
  78. * incremented.
  79. * 0 if the trace is to be ignored, and data->disabled
  80. * is kept the same.
  81. *
  82. * Note, this function is also used outside this ifdef but
  83. * inside the #ifdef of the function graph tracer below.
  84. * This is OK, since the function graph tracer is
  85. * dependent on the function tracer.
  86. */
  87. static int func_prolog_dec(struct trace_array *tr,
  88. struct trace_array_cpu **data,
  89. unsigned long *flags)
  90. {
  91. long disabled;
  92. int cpu;
  93. /*
  94. * Does not matter if we preempt. We test the flags
  95. * afterward, to see if irqs are disabled or not.
  96. * If we preempt and get a false positive, the flags
  97. * test will fail.
  98. */
  99. cpu = raw_smp_processor_id();
  100. if (likely(!per_cpu(tracing_cpu, cpu)))
  101. return 0;
  102. local_save_flags(*flags);
  103. /* slight chance to get a false positive on tracing_cpu */
  104. if (!irqs_disabled_flags(*flags))
  105. return 0;
  106. *data = per_cpu_ptr(tr->trace_buffer.data, cpu);
  107. disabled = atomic_inc_return(&(*data)->disabled);
  108. if (likely(disabled == 1))
  109. return 1;
  110. atomic_dec(&(*data)->disabled);
  111. return 0;
  112. }
  113. /*
  114. * irqsoff uses its own tracer function to keep the overhead down:
  115. */
  116. static void
  117. irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip,
  118. struct ftrace_ops *op, struct pt_regs *pt_regs)
  119. {
  120. struct trace_array *tr = irqsoff_trace;
  121. struct trace_array_cpu *data;
  122. unsigned long flags;
  123. if (!func_prolog_dec(tr, &data, &flags))
  124. return;
  125. trace_function(tr, ip, parent_ip, flags, preempt_count());
  126. atomic_dec(&data->disabled);
  127. }
  128. #endif /* CONFIG_FUNCTION_TRACER */
  129. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  130. static int
  131. irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
  132. {
  133. int cpu;
  134. if (!(bit & TRACE_DISPLAY_GRAPH))
  135. return -EINVAL;
  136. if (!(is_graph() ^ set))
  137. return 0;
  138. stop_irqsoff_tracer(irqsoff_trace, !set);
  139. for_each_possible_cpu(cpu)
  140. per_cpu(tracing_cpu, cpu) = 0;
  141. tr->max_latency = 0;
  142. tracing_reset_online_cpus(&irqsoff_trace->trace_buffer);
  143. return start_irqsoff_tracer(irqsoff_trace, set);
  144. }
  145. static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
  146. {
  147. struct trace_array *tr = irqsoff_trace;
  148. struct trace_array_cpu *data;
  149. unsigned long flags;
  150. int ret;
  151. int pc;
  152. if (!func_prolog_dec(tr, &data, &flags))
  153. return 0;
  154. pc = preempt_count();
  155. ret = __trace_graph_entry(tr, trace, flags, pc);
  156. atomic_dec(&data->disabled);
  157. return ret;
  158. }
  159. static void irqsoff_graph_return(struct ftrace_graph_ret *trace)
  160. {
  161. struct trace_array *tr = irqsoff_trace;
  162. struct trace_array_cpu *data;
  163. unsigned long flags;
  164. int pc;
  165. if (!func_prolog_dec(tr, &data, &flags))
  166. return;
  167. pc = preempt_count();
  168. __trace_graph_return(tr, trace, flags, pc);
  169. atomic_dec(&data->disabled);
  170. }
  171. static void irqsoff_trace_open(struct trace_iterator *iter)
  172. {
  173. if (is_graph())
  174. graph_trace_open(iter);
  175. }
  176. static void irqsoff_trace_close(struct trace_iterator *iter)
  177. {
  178. if (iter->private)
  179. graph_trace_close(iter);
  180. }
  181. #define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \
  182. TRACE_GRAPH_PRINT_PROC | \
  183. TRACE_GRAPH_PRINT_ABS_TIME | \
  184. TRACE_GRAPH_PRINT_DURATION)
  185. static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
  186. {
  187. /*
  188. * In graph mode call the graph tracer output function,
  189. * otherwise go with the TRACE_FN event handler
  190. */
  191. if (is_graph())
  192. return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
  193. return TRACE_TYPE_UNHANDLED;
  194. }
  195. static void irqsoff_print_header(struct seq_file *s)
  196. {
  197. if (is_graph())
  198. print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
  199. else
  200. trace_default_header(s);
  201. }
  202. static void
  203. __trace_function(struct trace_array *tr,
  204. unsigned long ip, unsigned long parent_ip,
  205. unsigned long flags, int pc)
  206. {
  207. if (is_graph())
  208. trace_graph_function(tr, ip, parent_ip, flags, pc);
  209. else
  210. trace_function(tr, ip, parent_ip, flags, pc);
  211. }
  212. #else
  213. #define __trace_function trace_function
  214. static int
  215. irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
  216. {
  217. return -EINVAL;
  218. }
  219. static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
  220. {
  221. return -1;
  222. }
  223. static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
  224. {
  225. return TRACE_TYPE_UNHANDLED;
  226. }
  227. static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { }
  228. static void irqsoff_trace_open(struct trace_iterator *iter) { }
  229. static void irqsoff_trace_close(struct trace_iterator *iter) { }
  230. #ifdef CONFIG_FUNCTION_TRACER
  231. static void irqsoff_print_header(struct seq_file *s)
  232. {
  233. trace_default_header(s);
  234. }
  235. #else
  236. static void irqsoff_print_header(struct seq_file *s)
  237. {
  238. trace_latency_header(s);
  239. }
  240. #endif /* CONFIG_FUNCTION_TRACER */
  241. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  242. /*
  243. * Should this new latency be reported/recorded?
  244. */
  245. static int report_latency(struct trace_array *tr, cycle_t delta)
  246. {
  247. if (tracing_thresh) {
  248. if (delta < tracing_thresh)
  249. return 0;
  250. } else {
  251. if (delta <= tr->max_latency)
  252. return 0;
  253. }
  254. return 1;
  255. }
  256. static void
  257. check_critical_timing(struct trace_array *tr,
  258. struct trace_array_cpu *data,
  259. unsigned long parent_ip,
  260. int cpu)
  261. {
  262. cycle_t T0, T1, delta;
  263. unsigned long flags;
  264. int pc;
  265. T0 = data->preempt_timestamp;
  266. T1 = ftrace_now(cpu);
  267. delta = T1-T0;
  268. local_save_flags(flags);
  269. pc = preempt_count();
  270. if (!report_latency(tr, delta))
  271. goto out;
  272. raw_spin_lock_irqsave(&max_trace_lock, flags);
  273. /* check if we are still the max latency */
  274. if (!report_latency(tr, delta))
  275. goto out_unlock;
  276. __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
  277. /* Skip 5 functions to get to the irq/preempt enable function */
  278. __trace_stack(tr, flags, 5, pc);
  279. if (data->critical_sequence != max_sequence)
  280. goto out_unlock;
  281. data->critical_end = parent_ip;
  282. if (likely(!is_tracing_stopped())) {
  283. tr->max_latency = delta;
  284. update_max_tr_single(tr, current, cpu);
  285. }
  286. max_sequence++;
  287. out_unlock:
  288. raw_spin_unlock_irqrestore(&max_trace_lock, flags);
  289. out:
  290. data->critical_sequence = max_sequence;
  291. data->preempt_timestamp = ftrace_now(cpu);
  292. __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
  293. }
  294. static inline void
  295. start_critical_timing(unsigned long ip, unsigned long parent_ip)
  296. {
  297. int cpu;
  298. struct trace_array *tr = irqsoff_trace;
  299. struct trace_array_cpu *data;
  300. unsigned long flags;
  301. if (!tracer_enabled || !tracing_is_enabled())
  302. return;
  303. cpu = raw_smp_processor_id();
  304. if (per_cpu(tracing_cpu, cpu))
  305. return;
  306. data = per_cpu_ptr(tr->trace_buffer.data, cpu);
  307. if (unlikely(!data) || atomic_read(&data->disabled))
  308. return;
  309. atomic_inc(&data->disabled);
  310. data->critical_sequence = max_sequence;
  311. data->preempt_timestamp = ftrace_now(cpu);
  312. data->critical_start = parent_ip ? : ip;
  313. local_save_flags(flags);
  314. __trace_function(tr, ip, parent_ip, flags, preempt_count());
  315. per_cpu(tracing_cpu, cpu) = 1;
  316. atomic_dec(&data->disabled);
  317. }
  318. static inline void
  319. stop_critical_timing(unsigned long ip, unsigned long parent_ip)
  320. {
  321. int cpu;
  322. struct trace_array *tr = irqsoff_trace;
  323. struct trace_array_cpu *data;
  324. unsigned long flags;
  325. cpu = raw_smp_processor_id();
  326. /* Always clear the tracing cpu on stopping the trace */
  327. if (unlikely(per_cpu(tracing_cpu, cpu)))
  328. per_cpu(tracing_cpu, cpu) = 0;
  329. else
  330. return;
  331. if (!tracer_enabled || !tracing_is_enabled())
  332. return;
  333. data = per_cpu_ptr(tr->trace_buffer.data, cpu);
  334. if (unlikely(!data) ||
  335. !data->critical_start || atomic_read(&data->disabled))
  336. return;
  337. atomic_inc(&data->disabled);
  338. local_save_flags(flags);
  339. __trace_function(tr, ip, parent_ip, flags, preempt_count());
  340. check_critical_timing(tr, data, parent_ip ? : ip, cpu);
  341. data->critical_start = 0;
  342. atomic_dec(&data->disabled);
  343. }
  344. /* start and stop critical timings used to for stoppage (in idle) */
  345. void start_critical_timings(void)
  346. {
  347. if (preempt_trace() || irq_trace())
  348. start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  349. }
  350. EXPORT_SYMBOL_GPL(start_critical_timings);
  351. void stop_critical_timings(void)
  352. {
  353. if (preempt_trace() || irq_trace())
  354. stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  355. }
  356. EXPORT_SYMBOL_GPL(stop_critical_timings);
  357. #ifdef CONFIG_IRQSOFF_TRACER
  358. #ifdef CONFIG_PROVE_LOCKING
  359. void time_hardirqs_on(unsigned long a0, unsigned long a1)
  360. {
  361. if (!preempt_trace() && irq_trace())
  362. stop_critical_timing(a0, a1);
  363. }
  364. void time_hardirqs_off(unsigned long a0, unsigned long a1)
  365. {
  366. if (!preempt_trace() && irq_trace())
  367. start_critical_timing(a0, a1);
  368. }
  369. #else /* !CONFIG_PROVE_LOCKING */
  370. /*
  371. * Stubs:
  372. */
  373. void trace_softirqs_on(unsigned long ip)
  374. {
  375. }
  376. void trace_softirqs_off(unsigned long ip)
  377. {
  378. }
  379. inline void print_irqtrace_events(struct task_struct *curr)
  380. {
  381. }
  382. /*
  383. * We are only interested in hardirq on/off events:
  384. */
  385. void trace_hardirqs_on(void)
  386. {
  387. if (!preempt_trace() && irq_trace())
  388. stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  389. }
  390. EXPORT_SYMBOL(trace_hardirqs_on);
  391. void trace_hardirqs_off(void)
  392. {
  393. if (!preempt_trace() && irq_trace())
  394. start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  395. }
  396. EXPORT_SYMBOL(trace_hardirqs_off);
  397. __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
  398. {
  399. if (!preempt_trace() && irq_trace())
  400. stop_critical_timing(CALLER_ADDR0, caller_addr);
  401. }
  402. EXPORT_SYMBOL(trace_hardirqs_on_caller);
  403. __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
  404. {
  405. if (!preempt_trace() && irq_trace())
  406. start_critical_timing(CALLER_ADDR0, caller_addr);
  407. }
  408. EXPORT_SYMBOL(trace_hardirqs_off_caller);
  409. #endif /* CONFIG_PROVE_LOCKING */
  410. #endif /* CONFIG_IRQSOFF_TRACER */
  411. #ifdef CONFIG_PREEMPT_TRACER
  412. void trace_preempt_on(unsigned long a0, unsigned long a1)
  413. {
  414. if (preempt_trace() && !irq_trace())
  415. stop_critical_timing(a0, a1);
  416. }
  417. void trace_preempt_off(unsigned long a0, unsigned long a1)
  418. {
  419. if (preempt_trace() && !irq_trace())
  420. start_critical_timing(a0, a1);
  421. }
  422. #endif /* CONFIG_PREEMPT_TRACER */
  423. static int register_irqsoff_function(struct trace_array *tr, int graph, int set)
  424. {
  425. int ret;
  426. /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
  427. if (function_enabled || (!set && !(trace_flags & TRACE_ITER_FUNCTION)))
  428. return 0;
  429. if (graph)
  430. ret = register_ftrace_graph(&irqsoff_graph_return,
  431. &irqsoff_graph_entry);
  432. else
  433. ret = register_ftrace_function(tr->ops);
  434. if (!ret)
  435. function_enabled = true;
  436. return ret;
  437. }
  438. static void unregister_irqsoff_function(struct trace_array *tr, int graph)
  439. {
  440. if (!function_enabled)
  441. return;
  442. if (graph)
  443. unregister_ftrace_graph();
  444. else
  445. unregister_ftrace_function(tr->ops);
  446. function_enabled = false;
  447. }
  448. static void irqsoff_function_set(struct trace_array *tr, int set)
  449. {
  450. if (set)
  451. register_irqsoff_function(tr, is_graph(), 1);
  452. else
  453. unregister_irqsoff_function(tr, is_graph());
  454. }
  455. static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
  456. {
  457. struct tracer *tracer = tr->current_trace;
  458. if (mask & TRACE_ITER_FUNCTION)
  459. irqsoff_function_set(tr, set);
  460. return trace_keep_overwrite(tracer, mask, set);
  461. }
  462. static int start_irqsoff_tracer(struct trace_array *tr, int graph)
  463. {
  464. int ret;
  465. ret = register_irqsoff_function(tr, graph, 0);
  466. if (!ret && tracing_is_enabled())
  467. tracer_enabled = 1;
  468. else
  469. tracer_enabled = 0;
  470. return ret;
  471. }
  472. static void stop_irqsoff_tracer(struct trace_array *tr, int graph)
  473. {
  474. tracer_enabled = 0;
  475. unregister_irqsoff_function(tr, graph);
  476. }
  477. static bool irqsoff_busy;
  478. static int __irqsoff_tracer_init(struct trace_array *tr)
  479. {
  480. if (irqsoff_busy)
  481. return -EBUSY;
  482. save_flags = trace_flags;
  483. /* non overwrite screws up the latency tracers */
  484. set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
  485. set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
  486. tr->max_latency = 0;
  487. irqsoff_trace = tr;
  488. /* make sure that the tracer is visible */
  489. smp_wmb();
  490. tracing_reset_online_cpus(&tr->trace_buffer);
  491. ftrace_init_array_ops(tr, irqsoff_tracer_call);
  492. /* Only toplevel instance supports graph tracing */
  493. if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL &&
  494. is_graph())))
  495. printk(KERN_ERR "failed to start irqsoff tracer\n");
  496. irqsoff_busy = true;
  497. return 0;
  498. }
  499. static void irqsoff_tracer_reset(struct trace_array *tr)
  500. {
  501. int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
  502. int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
  503. stop_irqsoff_tracer(tr, is_graph());
  504. set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
  505. set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
  506. ftrace_reset_array_ops(tr);
  507. irqsoff_busy = false;
  508. }
  509. static void irqsoff_tracer_start(struct trace_array *tr)
  510. {
  511. tracer_enabled = 1;
  512. }
  513. static void irqsoff_tracer_stop(struct trace_array *tr)
  514. {
  515. tracer_enabled = 0;
  516. }
  517. #ifdef CONFIG_IRQSOFF_TRACER
  518. static int irqsoff_tracer_init(struct trace_array *tr)
  519. {
  520. trace_type = TRACER_IRQS_OFF;
  521. return __irqsoff_tracer_init(tr);
  522. }
  523. static struct tracer irqsoff_tracer __read_mostly =
  524. {
  525. .name = "irqsoff",
  526. .init = irqsoff_tracer_init,
  527. .reset = irqsoff_tracer_reset,
  528. .start = irqsoff_tracer_start,
  529. .stop = irqsoff_tracer_stop,
  530. .print_max = true,
  531. .print_header = irqsoff_print_header,
  532. .print_line = irqsoff_print_line,
  533. .flags = &tracer_flags,
  534. .set_flag = irqsoff_set_flag,
  535. .flag_changed = irqsoff_flag_changed,
  536. #ifdef CONFIG_FTRACE_SELFTEST
  537. .selftest = trace_selftest_startup_irqsoff,
  538. #endif
  539. .open = irqsoff_trace_open,
  540. .close = irqsoff_trace_close,
  541. .allow_instances = true,
  542. .use_max_tr = true,
  543. };
  544. # define register_irqsoff(trace) register_tracer(&trace)
  545. #else
  546. # define register_irqsoff(trace) do { } while (0)
  547. #endif
  548. #ifdef CONFIG_PREEMPT_TRACER
  549. static int preemptoff_tracer_init(struct trace_array *tr)
  550. {
  551. trace_type = TRACER_PREEMPT_OFF;
  552. return __irqsoff_tracer_init(tr);
  553. }
  554. static struct tracer preemptoff_tracer __read_mostly =
  555. {
  556. .name = "preemptoff",
  557. .init = preemptoff_tracer_init,
  558. .reset = irqsoff_tracer_reset,
  559. .start = irqsoff_tracer_start,
  560. .stop = irqsoff_tracer_stop,
  561. .print_max = true,
  562. .print_header = irqsoff_print_header,
  563. .print_line = irqsoff_print_line,
  564. .flags = &tracer_flags,
  565. .set_flag = irqsoff_set_flag,
  566. .flag_changed = irqsoff_flag_changed,
  567. #ifdef CONFIG_FTRACE_SELFTEST
  568. .selftest = trace_selftest_startup_preemptoff,
  569. #endif
  570. .open = irqsoff_trace_open,
  571. .close = irqsoff_trace_close,
  572. .allow_instances = true,
  573. .use_max_tr = true,
  574. };
  575. # define register_preemptoff(trace) register_tracer(&trace)
  576. #else
  577. # define register_preemptoff(trace) do { } while (0)
  578. #endif
  579. #if defined(CONFIG_IRQSOFF_TRACER) && \
  580. defined(CONFIG_PREEMPT_TRACER)
  581. static int preemptirqsoff_tracer_init(struct trace_array *tr)
  582. {
  583. trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF;
  584. return __irqsoff_tracer_init(tr);
  585. }
  586. static struct tracer preemptirqsoff_tracer __read_mostly =
  587. {
  588. .name = "preemptirqsoff",
  589. .init = preemptirqsoff_tracer_init,
  590. .reset = irqsoff_tracer_reset,
  591. .start = irqsoff_tracer_start,
  592. .stop = irqsoff_tracer_stop,
  593. .print_max = true,
  594. .print_header = irqsoff_print_header,
  595. .print_line = irqsoff_print_line,
  596. .flags = &tracer_flags,
  597. .set_flag = irqsoff_set_flag,
  598. .flag_changed = irqsoff_flag_changed,
  599. #ifdef CONFIG_FTRACE_SELFTEST
  600. .selftest = trace_selftest_startup_preemptirqsoff,
  601. #endif
  602. .open = irqsoff_trace_open,
  603. .close = irqsoff_trace_close,
  604. .allow_instances = true,
  605. .use_max_tr = true,
  606. };
  607. # define register_preemptirqsoff(trace) register_tracer(&trace)
  608. #else
  609. # define register_preemptirqsoff(trace) do { } while (0)
  610. #endif
  611. __init static int init_irqsoff_tracer(void)
  612. {
  613. register_irqsoff(irqsoff_tracer);
  614. register_preemptoff(preemptoff_tracer);
  615. register_preemptirqsoff(preemptirqsoff_tracer);
  616. return 0;
  617. }
  618. core_initcall(init_irqsoff_tracer);