trace_irqsoff.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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. static struct ftrace_ops trace_ops __read_mostly =
  129. {
  130. .func = irqsoff_tracer_call,
  131. .flags = FTRACE_OPS_FL_GLOBAL | FTRACE_OPS_FL_RECURSION_SAFE,
  132. };
  133. #endif /* CONFIG_FUNCTION_TRACER */
  134. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  135. static int
  136. irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
  137. {
  138. int cpu;
  139. if (!(bit & TRACE_DISPLAY_GRAPH))
  140. return -EINVAL;
  141. if (!(is_graph() ^ set))
  142. return 0;
  143. stop_irqsoff_tracer(irqsoff_trace, !set);
  144. for_each_possible_cpu(cpu)
  145. per_cpu(tracing_cpu, cpu) = 0;
  146. tracing_max_latency = 0;
  147. tracing_reset_online_cpus(&irqsoff_trace->trace_buffer);
  148. return start_irqsoff_tracer(irqsoff_trace, set);
  149. }
  150. static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
  151. {
  152. struct trace_array *tr = irqsoff_trace;
  153. struct trace_array_cpu *data;
  154. unsigned long flags;
  155. int ret;
  156. int pc;
  157. if (!func_prolog_dec(tr, &data, &flags))
  158. return 0;
  159. pc = preempt_count();
  160. ret = __trace_graph_entry(tr, trace, flags, pc);
  161. atomic_dec(&data->disabled);
  162. return ret;
  163. }
  164. static void irqsoff_graph_return(struct ftrace_graph_ret *trace)
  165. {
  166. struct trace_array *tr = irqsoff_trace;
  167. struct trace_array_cpu *data;
  168. unsigned long flags;
  169. int pc;
  170. if (!func_prolog_dec(tr, &data, &flags))
  171. return;
  172. pc = preempt_count();
  173. __trace_graph_return(tr, trace, flags, pc);
  174. atomic_dec(&data->disabled);
  175. }
  176. static void irqsoff_trace_open(struct trace_iterator *iter)
  177. {
  178. if (is_graph())
  179. graph_trace_open(iter);
  180. }
  181. static void irqsoff_trace_close(struct trace_iterator *iter)
  182. {
  183. if (iter->private)
  184. graph_trace_close(iter);
  185. }
  186. #define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_CPU | \
  187. TRACE_GRAPH_PRINT_PROC | \
  188. TRACE_GRAPH_PRINT_ABS_TIME | \
  189. TRACE_GRAPH_PRINT_DURATION)
  190. static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
  191. {
  192. /*
  193. * In graph mode call the graph tracer output function,
  194. * otherwise go with the TRACE_FN event handler
  195. */
  196. if (is_graph())
  197. return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
  198. return TRACE_TYPE_UNHANDLED;
  199. }
  200. static void irqsoff_print_header(struct seq_file *s)
  201. {
  202. if (is_graph())
  203. print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
  204. else
  205. trace_default_header(s);
  206. }
  207. static void
  208. __trace_function(struct trace_array *tr,
  209. unsigned long ip, unsigned long parent_ip,
  210. unsigned long flags, int pc)
  211. {
  212. if (is_graph())
  213. trace_graph_function(tr, ip, parent_ip, flags, pc);
  214. else
  215. trace_function(tr, ip, parent_ip, flags, pc);
  216. }
  217. #else
  218. #define __trace_function trace_function
  219. static int
  220. irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
  221. {
  222. return -EINVAL;
  223. }
  224. static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
  225. {
  226. return -1;
  227. }
  228. static enum print_line_t irqsoff_print_line(struct trace_iterator *iter)
  229. {
  230. return TRACE_TYPE_UNHANDLED;
  231. }
  232. static void irqsoff_graph_return(struct ftrace_graph_ret *trace) { }
  233. static void irqsoff_trace_open(struct trace_iterator *iter) { }
  234. static void irqsoff_trace_close(struct trace_iterator *iter) { }
  235. #ifdef CONFIG_FUNCTION_TRACER
  236. static void irqsoff_print_header(struct seq_file *s)
  237. {
  238. trace_default_header(s);
  239. }
  240. #else
  241. static void irqsoff_print_header(struct seq_file *s)
  242. {
  243. trace_latency_header(s);
  244. }
  245. #endif /* CONFIG_FUNCTION_TRACER */
  246. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  247. /*
  248. * Should this new latency be reported/recorded?
  249. */
  250. static int report_latency(cycle_t delta)
  251. {
  252. if (tracing_thresh) {
  253. if (delta < tracing_thresh)
  254. return 0;
  255. } else {
  256. if (delta <= tracing_max_latency)
  257. return 0;
  258. }
  259. return 1;
  260. }
  261. static void
  262. check_critical_timing(struct trace_array *tr,
  263. struct trace_array_cpu *data,
  264. unsigned long parent_ip,
  265. int cpu)
  266. {
  267. cycle_t T0, T1, delta;
  268. unsigned long flags;
  269. int pc;
  270. T0 = data->preempt_timestamp;
  271. T1 = ftrace_now(cpu);
  272. delta = T1-T0;
  273. local_save_flags(flags);
  274. pc = preempt_count();
  275. if (!report_latency(delta))
  276. goto out;
  277. raw_spin_lock_irqsave(&max_trace_lock, flags);
  278. /* check if we are still the max latency */
  279. if (!report_latency(delta))
  280. goto out_unlock;
  281. __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
  282. /* Skip 5 functions to get to the irq/preempt enable function */
  283. __trace_stack(tr, flags, 5, pc);
  284. if (data->critical_sequence != max_sequence)
  285. goto out_unlock;
  286. data->critical_end = parent_ip;
  287. if (likely(!is_tracing_stopped())) {
  288. tracing_max_latency = delta;
  289. update_max_tr_single(tr, current, cpu);
  290. }
  291. max_sequence++;
  292. out_unlock:
  293. raw_spin_unlock_irqrestore(&max_trace_lock, flags);
  294. out:
  295. data->critical_sequence = max_sequence;
  296. data->preempt_timestamp = ftrace_now(cpu);
  297. __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
  298. }
  299. static inline void
  300. start_critical_timing(unsigned long ip, unsigned long parent_ip)
  301. {
  302. int cpu;
  303. struct trace_array *tr = irqsoff_trace;
  304. struct trace_array_cpu *data;
  305. unsigned long flags;
  306. if (!tracer_enabled || !tracing_is_enabled())
  307. return;
  308. cpu = raw_smp_processor_id();
  309. if (per_cpu(tracing_cpu, cpu))
  310. return;
  311. data = per_cpu_ptr(tr->trace_buffer.data, cpu);
  312. if (unlikely(!data) || atomic_read(&data->disabled))
  313. return;
  314. atomic_inc(&data->disabled);
  315. data->critical_sequence = max_sequence;
  316. data->preempt_timestamp = ftrace_now(cpu);
  317. data->critical_start = parent_ip ? : ip;
  318. local_save_flags(flags);
  319. __trace_function(tr, ip, parent_ip, flags, preempt_count());
  320. per_cpu(tracing_cpu, cpu) = 1;
  321. atomic_dec(&data->disabled);
  322. }
  323. static inline void
  324. stop_critical_timing(unsigned long ip, unsigned long parent_ip)
  325. {
  326. int cpu;
  327. struct trace_array *tr = irqsoff_trace;
  328. struct trace_array_cpu *data;
  329. unsigned long flags;
  330. cpu = raw_smp_processor_id();
  331. /* Always clear the tracing cpu on stopping the trace */
  332. if (unlikely(per_cpu(tracing_cpu, cpu)))
  333. per_cpu(tracing_cpu, cpu) = 0;
  334. else
  335. return;
  336. if (!tracer_enabled || !tracing_is_enabled())
  337. return;
  338. data = per_cpu_ptr(tr->trace_buffer.data, cpu);
  339. if (unlikely(!data) ||
  340. !data->critical_start || atomic_read(&data->disabled))
  341. return;
  342. atomic_inc(&data->disabled);
  343. local_save_flags(flags);
  344. __trace_function(tr, ip, parent_ip, flags, preempt_count());
  345. check_critical_timing(tr, data, parent_ip ? : ip, cpu);
  346. data->critical_start = 0;
  347. atomic_dec(&data->disabled);
  348. }
  349. /* start and stop critical timings used to for stoppage (in idle) */
  350. void start_critical_timings(void)
  351. {
  352. if (preempt_trace() || irq_trace())
  353. start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  354. }
  355. EXPORT_SYMBOL_GPL(start_critical_timings);
  356. void stop_critical_timings(void)
  357. {
  358. if (preempt_trace() || irq_trace())
  359. stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  360. }
  361. EXPORT_SYMBOL_GPL(stop_critical_timings);
  362. #ifdef CONFIG_IRQSOFF_TRACER
  363. #ifdef CONFIG_PROVE_LOCKING
  364. void time_hardirqs_on(unsigned long a0, unsigned long a1)
  365. {
  366. if (!preempt_trace() && irq_trace())
  367. stop_critical_timing(a0, a1);
  368. }
  369. void time_hardirqs_off(unsigned long a0, unsigned long a1)
  370. {
  371. if (!preempt_trace() && irq_trace())
  372. start_critical_timing(a0, a1);
  373. }
  374. #else /* !CONFIG_PROVE_LOCKING */
  375. /*
  376. * Stubs:
  377. */
  378. void trace_softirqs_on(unsigned long ip)
  379. {
  380. }
  381. void trace_softirqs_off(unsigned long ip)
  382. {
  383. }
  384. inline void print_irqtrace_events(struct task_struct *curr)
  385. {
  386. }
  387. /*
  388. * We are only interested in hardirq on/off events:
  389. */
  390. void trace_hardirqs_on(void)
  391. {
  392. if (!preempt_trace() && irq_trace())
  393. stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  394. }
  395. EXPORT_SYMBOL(trace_hardirqs_on);
  396. void trace_hardirqs_off(void)
  397. {
  398. if (!preempt_trace() && irq_trace())
  399. start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
  400. }
  401. EXPORT_SYMBOL(trace_hardirqs_off);
  402. __visible void trace_hardirqs_on_caller(unsigned long caller_addr)
  403. {
  404. if (!preempt_trace() && irq_trace())
  405. stop_critical_timing(CALLER_ADDR0, caller_addr);
  406. }
  407. EXPORT_SYMBOL(trace_hardirqs_on_caller);
  408. __visible void trace_hardirqs_off_caller(unsigned long caller_addr)
  409. {
  410. if (!preempt_trace() && irq_trace())
  411. start_critical_timing(CALLER_ADDR0, caller_addr);
  412. }
  413. EXPORT_SYMBOL(trace_hardirqs_off_caller);
  414. #endif /* CONFIG_PROVE_LOCKING */
  415. #endif /* CONFIG_IRQSOFF_TRACER */
  416. #ifdef CONFIG_PREEMPT_TRACER
  417. void trace_preempt_on(unsigned long a0, unsigned long a1)
  418. {
  419. if (preempt_trace() && !irq_trace())
  420. stop_critical_timing(a0, a1);
  421. }
  422. void trace_preempt_off(unsigned long a0, unsigned long a1)
  423. {
  424. if (preempt_trace() && !irq_trace())
  425. start_critical_timing(a0, a1);
  426. }
  427. #endif /* CONFIG_PREEMPT_TRACER */
  428. static int register_irqsoff_function(int graph, int set)
  429. {
  430. int ret;
  431. /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
  432. if (function_enabled || (!set && !(trace_flags & TRACE_ITER_FUNCTION)))
  433. return 0;
  434. if (graph)
  435. ret = register_ftrace_graph(&irqsoff_graph_return,
  436. &irqsoff_graph_entry);
  437. else
  438. ret = register_ftrace_function(&trace_ops);
  439. if (!ret)
  440. function_enabled = true;
  441. return ret;
  442. }
  443. static void unregister_irqsoff_function(int graph)
  444. {
  445. if (!function_enabled)
  446. return;
  447. if (graph)
  448. unregister_ftrace_graph();
  449. else
  450. unregister_ftrace_function(&trace_ops);
  451. function_enabled = false;
  452. }
  453. static void irqsoff_function_set(int set)
  454. {
  455. if (set)
  456. register_irqsoff_function(is_graph(), 1);
  457. else
  458. unregister_irqsoff_function(is_graph());
  459. }
  460. static int irqsoff_flag_changed(struct trace_array *tr, u32 mask, int set)
  461. {
  462. struct tracer *tracer = tr->current_trace;
  463. if (mask & TRACE_ITER_FUNCTION)
  464. irqsoff_function_set(set);
  465. return trace_keep_overwrite(tracer, mask, set);
  466. }
  467. static int start_irqsoff_tracer(struct trace_array *tr, int graph)
  468. {
  469. int ret;
  470. ret = register_irqsoff_function(graph, 0);
  471. if (!ret && tracing_is_enabled())
  472. tracer_enabled = 1;
  473. else
  474. tracer_enabled = 0;
  475. return ret;
  476. }
  477. static void stop_irqsoff_tracer(struct trace_array *tr, int graph)
  478. {
  479. tracer_enabled = 0;
  480. unregister_irqsoff_function(graph);
  481. }
  482. static void __irqsoff_tracer_init(struct trace_array *tr)
  483. {
  484. save_flags = trace_flags;
  485. /* non overwrite screws up the latency tracers */
  486. set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
  487. set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
  488. tracing_max_latency = 0;
  489. irqsoff_trace = tr;
  490. /* make sure that the tracer is visible */
  491. smp_wmb();
  492. tracing_reset_online_cpus(&tr->trace_buffer);
  493. if (start_irqsoff_tracer(tr, is_graph()))
  494. printk(KERN_ERR "failed to start irqsoff tracer\n");
  495. }
  496. static void irqsoff_tracer_reset(struct trace_array *tr)
  497. {
  498. int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
  499. int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
  500. stop_irqsoff_tracer(tr, is_graph());
  501. set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
  502. set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
  503. }
  504. static void irqsoff_tracer_start(struct trace_array *tr)
  505. {
  506. tracer_enabled = 1;
  507. }
  508. static void irqsoff_tracer_stop(struct trace_array *tr)
  509. {
  510. tracer_enabled = 0;
  511. }
  512. #ifdef CONFIG_IRQSOFF_TRACER
  513. static int irqsoff_tracer_init(struct trace_array *tr)
  514. {
  515. trace_type = TRACER_IRQS_OFF;
  516. __irqsoff_tracer_init(tr);
  517. return 0;
  518. }
  519. static struct tracer irqsoff_tracer __read_mostly =
  520. {
  521. .name = "irqsoff",
  522. .init = irqsoff_tracer_init,
  523. .reset = irqsoff_tracer_reset,
  524. .start = irqsoff_tracer_start,
  525. .stop = irqsoff_tracer_stop,
  526. .print_max = true,
  527. .print_header = irqsoff_print_header,
  528. .print_line = irqsoff_print_line,
  529. .flags = &tracer_flags,
  530. .set_flag = irqsoff_set_flag,
  531. .flag_changed = irqsoff_flag_changed,
  532. #ifdef CONFIG_FTRACE_SELFTEST
  533. .selftest = trace_selftest_startup_irqsoff,
  534. #endif
  535. .open = irqsoff_trace_open,
  536. .close = irqsoff_trace_close,
  537. .use_max_tr = true,
  538. };
  539. # define register_irqsoff(trace) register_tracer(&trace)
  540. #else
  541. # define register_irqsoff(trace) do { } while (0)
  542. #endif
  543. #ifdef CONFIG_PREEMPT_TRACER
  544. static int preemptoff_tracer_init(struct trace_array *tr)
  545. {
  546. trace_type = TRACER_PREEMPT_OFF;
  547. __irqsoff_tracer_init(tr);
  548. return 0;
  549. }
  550. static struct tracer preemptoff_tracer __read_mostly =
  551. {
  552. .name = "preemptoff",
  553. .init = preemptoff_tracer_init,
  554. .reset = irqsoff_tracer_reset,
  555. .start = irqsoff_tracer_start,
  556. .stop = irqsoff_tracer_stop,
  557. .print_max = true,
  558. .print_header = irqsoff_print_header,
  559. .print_line = irqsoff_print_line,
  560. .flags = &tracer_flags,
  561. .set_flag = irqsoff_set_flag,
  562. .flag_changed = irqsoff_flag_changed,
  563. #ifdef CONFIG_FTRACE_SELFTEST
  564. .selftest = trace_selftest_startup_preemptoff,
  565. #endif
  566. .open = irqsoff_trace_open,
  567. .close = irqsoff_trace_close,
  568. .use_max_tr = true,
  569. };
  570. # define register_preemptoff(trace) register_tracer(&trace)
  571. #else
  572. # define register_preemptoff(trace) do { } while (0)
  573. #endif
  574. #if defined(CONFIG_IRQSOFF_TRACER) && \
  575. defined(CONFIG_PREEMPT_TRACER)
  576. static int preemptirqsoff_tracer_init(struct trace_array *tr)
  577. {
  578. trace_type = TRACER_IRQS_OFF | TRACER_PREEMPT_OFF;
  579. __irqsoff_tracer_init(tr);
  580. return 0;
  581. }
  582. static struct tracer preemptirqsoff_tracer __read_mostly =
  583. {
  584. .name = "preemptirqsoff",
  585. .init = preemptirqsoff_tracer_init,
  586. .reset = irqsoff_tracer_reset,
  587. .start = irqsoff_tracer_start,
  588. .stop = irqsoff_tracer_stop,
  589. .print_max = true,
  590. .print_header = irqsoff_print_header,
  591. .print_line = irqsoff_print_line,
  592. .flags = &tracer_flags,
  593. .set_flag = irqsoff_set_flag,
  594. .flag_changed = irqsoff_flag_changed,
  595. #ifdef CONFIG_FTRACE_SELFTEST
  596. .selftest = trace_selftest_startup_preemptirqsoff,
  597. #endif
  598. .open = irqsoff_trace_open,
  599. .close = irqsoff_trace_close,
  600. .use_max_tr = true,
  601. };
  602. # define register_preemptirqsoff(trace) register_tracer(&trace)
  603. #else
  604. # define register_preemptirqsoff(trace) do { } while (0)
  605. #endif
  606. __init static int init_irqsoff_tracer(void)
  607. {
  608. register_irqsoff(irqsoff_tracer);
  609. register_preemptoff(preemptoff_tracer);
  610. register_preemptirqsoff(preemptirqsoff_tracer);
  611. return 0;
  612. }
  613. core_initcall(init_irqsoff_tracer);