trace_irqsoff.c 16 KB

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