trace_sched_wakeup.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. /*
  2. * trace task wakeup timings
  3. *
  4. * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
  5. * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
  6. *
  7. * Based on code from the latency_tracer, that is:
  8. *
  9. * Copyright (C) 2004-2006 Ingo Molnar
  10. * Copyright (C) 2004 Nadia Yvette Chambers
  11. */
  12. #include <linux/module.h>
  13. #include <linux/fs.h>
  14. #include <linux/debugfs.h>
  15. #include <linux/kallsyms.h>
  16. #include <linux/uaccess.h>
  17. #include <linux/ftrace.h>
  18. #include <linux/sched/rt.h>
  19. #include <linux/sched/deadline.h>
  20. #include <trace/events/sched.h>
  21. #include "trace.h"
  22. static struct trace_array *wakeup_trace;
  23. static int __read_mostly tracer_enabled;
  24. static struct task_struct *wakeup_task;
  25. static int wakeup_cpu;
  26. static int wakeup_current_cpu;
  27. static unsigned wakeup_prio = -1;
  28. static int wakeup_rt;
  29. static int wakeup_dl;
  30. static int tracing_dl = 0;
  31. static arch_spinlock_t wakeup_lock =
  32. (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
  33. static void wakeup_reset(struct trace_array *tr);
  34. static void __wakeup_reset(struct trace_array *tr);
  35. static int wakeup_graph_entry(struct ftrace_graph_ent *trace);
  36. static void wakeup_graph_return(struct ftrace_graph_ret *trace);
  37. static int save_flags;
  38. static bool function_enabled;
  39. #define TRACE_DISPLAY_GRAPH 1
  40. static struct tracer_opt trace_opts[] = {
  41. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  42. /* display latency trace as call graph */
  43. { TRACER_OPT(display-graph, TRACE_DISPLAY_GRAPH) },
  44. #endif
  45. { } /* Empty entry */
  46. };
  47. static struct tracer_flags tracer_flags = {
  48. .val = 0,
  49. .opts = trace_opts,
  50. };
  51. #define is_graph() (tracer_flags.val & TRACE_DISPLAY_GRAPH)
  52. #ifdef CONFIG_FUNCTION_TRACER
  53. /*
  54. * Prologue for the wakeup function tracers.
  55. *
  56. * Returns 1 if it is OK to continue, and preemption
  57. * is disabled and data->disabled is incremented.
  58. * 0 if the trace is to be ignored, and preemption
  59. * is not disabled and data->disabled is
  60. * kept the same.
  61. *
  62. * Note, this function is also used outside this ifdef but
  63. * inside the #ifdef of the function graph tracer below.
  64. * This is OK, since the function graph tracer is
  65. * dependent on the function tracer.
  66. */
  67. static int
  68. func_prolog_preempt_disable(struct trace_array *tr,
  69. struct trace_array_cpu **data,
  70. int *pc)
  71. {
  72. long disabled;
  73. int cpu;
  74. if (likely(!wakeup_task))
  75. return 0;
  76. *pc = preempt_count();
  77. preempt_disable_notrace();
  78. cpu = raw_smp_processor_id();
  79. if (cpu != wakeup_current_cpu)
  80. goto out_enable;
  81. *data = per_cpu_ptr(tr->trace_buffer.data, cpu);
  82. disabled = atomic_inc_return(&(*data)->disabled);
  83. if (unlikely(disabled != 1))
  84. goto out;
  85. return 1;
  86. out:
  87. atomic_dec(&(*data)->disabled);
  88. out_enable:
  89. preempt_enable_notrace();
  90. return 0;
  91. }
  92. /*
  93. * wakeup uses its own tracer function to keep the overhead down:
  94. */
  95. static void
  96. wakeup_tracer_call(unsigned long ip, unsigned long parent_ip,
  97. struct ftrace_ops *op, struct pt_regs *pt_regs)
  98. {
  99. struct trace_array *tr = wakeup_trace;
  100. struct trace_array_cpu *data;
  101. unsigned long flags;
  102. int pc;
  103. if (!func_prolog_preempt_disable(tr, &data, &pc))
  104. return;
  105. local_irq_save(flags);
  106. trace_function(tr, ip, parent_ip, flags, pc);
  107. local_irq_restore(flags);
  108. atomic_dec(&data->disabled);
  109. preempt_enable_notrace();
  110. }
  111. #endif /* CONFIG_FUNCTION_TRACER */
  112. static int register_wakeup_function(struct trace_array *tr, int graph, int set)
  113. {
  114. int ret;
  115. /* 'set' is set if TRACE_ITER_FUNCTION is about to be set */
  116. if (function_enabled || (!set && !(trace_flags & TRACE_ITER_FUNCTION)))
  117. return 0;
  118. if (graph)
  119. ret = register_ftrace_graph(&wakeup_graph_return,
  120. &wakeup_graph_entry);
  121. else
  122. ret = register_ftrace_function(tr->ops);
  123. if (!ret)
  124. function_enabled = true;
  125. return ret;
  126. }
  127. static void unregister_wakeup_function(struct trace_array *tr, int graph)
  128. {
  129. if (!function_enabled)
  130. return;
  131. if (graph)
  132. unregister_ftrace_graph();
  133. else
  134. unregister_ftrace_function(tr->ops);
  135. function_enabled = false;
  136. }
  137. static void wakeup_function_set(struct trace_array *tr, int set)
  138. {
  139. if (set)
  140. register_wakeup_function(tr, is_graph(), 1);
  141. else
  142. unregister_wakeup_function(tr, is_graph());
  143. }
  144. static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)
  145. {
  146. struct tracer *tracer = tr->current_trace;
  147. if (mask & TRACE_ITER_FUNCTION)
  148. wakeup_function_set(tr, set);
  149. return trace_keep_overwrite(tracer, mask, set);
  150. }
  151. static int start_func_tracer(struct trace_array *tr, int graph)
  152. {
  153. int ret;
  154. ret = register_wakeup_function(tr, graph, 0);
  155. if (!ret && tracing_is_enabled())
  156. tracer_enabled = 1;
  157. else
  158. tracer_enabled = 0;
  159. return ret;
  160. }
  161. static void stop_func_tracer(struct trace_array *tr, int graph)
  162. {
  163. tracer_enabled = 0;
  164. unregister_wakeup_function(tr, graph);
  165. }
  166. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  167. static int
  168. wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
  169. {
  170. if (!(bit & TRACE_DISPLAY_GRAPH))
  171. return -EINVAL;
  172. if (!(is_graph() ^ set))
  173. return 0;
  174. stop_func_tracer(tr, !set);
  175. wakeup_reset(wakeup_trace);
  176. tr->max_latency = 0;
  177. return start_func_tracer(tr, set);
  178. }
  179. static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
  180. {
  181. struct trace_array *tr = wakeup_trace;
  182. struct trace_array_cpu *data;
  183. unsigned long flags;
  184. int pc, ret = 0;
  185. if (!func_prolog_preempt_disable(tr, &data, &pc))
  186. return 0;
  187. local_save_flags(flags);
  188. ret = __trace_graph_entry(tr, trace, flags, pc);
  189. atomic_dec(&data->disabled);
  190. preempt_enable_notrace();
  191. return ret;
  192. }
  193. static void wakeup_graph_return(struct ftrace_graph_ret *trace)
  194. {
  195. struct trace_array *tr = wakeup_trace;
  196. struct trace_array_cpu *data;
  197. unsigned long flags;
  198. int pc;
  199. if (!func_prolog_preempt_disable(tr, &data, &pc))
  200. return;
  201. local_save_flags(flags);
  202. __trace_graph_return(tr, trace, flags, pc);
  203. atomic_dec(&data->disabled);
  204. preempt_enable_notrace();
  205. return;
  206. }
  207. static void wakeup_trace_open(struct trace_iterator *iter)
  208. {
  209. if (is_graph())
  210. graph_trace_open(iter);
  211. }
  212. static void wakeup_trace_close(struct trace_iterator *iter)
  213. {
  214. if (iter->private)
  215. graph_trace_close(iter);
  216. }
  217. #define GRAPH_TRACER_FLAGS (TRACE_GRAPH_PRINT_PROC | \
  218. TRACE_GRAPH_PRINT_ABS_TIME | \
  219. TRACE_GRAPH_PRINT_DURATION)
  220. static enum print_line_t wakeup_print_line(struct trace_iterator *iter)
  221. {
  222. /*
  223. * In graph mode call the graph tracer output function,
  224. * otherwise go with the TRACE_FN event handler
  225. */
  226. if (is_graph())
  227. return print_graph_function_flags(iter, GRAPH_TRACER_FLAGS);
  228. return TRACE_TYPE_UNHANDLED;
  229. }
  230. static void wakeup_print_header(struct seq_file *s)
  231. {
  232. if (is_graph())
  233. print_graph_headers_flags(s, GRAPH_TRACER_FLAGS);
  234. else
  235. trace_default_header(s);
  236. }
  237. static void
  238. __trace_function(struct trace_array *tr,
  239. unsigned long ip, unsigned long parent_ip,
  240. unsigned long flags, int pc)
  241. {
  242. if (is_graph())
  243. trace_graph_function(tr, ip, parent_ip, flags, pc);
  244. else
  245. trace_function(tr, ip, parent_ip, flags, pc);
  246. }
  247. #else
  248. #define __trace_function trace_function
  249. static int
  250. wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
  251. {
  252. return -EINVAL;
  253. }
  254. static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
  255. {
  256. return -1;
  257. }
  258. static enum print_line_t wakeup_print_line(struct trace_iterator *iter)
  259. {
  260. return TRACE_TYPE_UNHANDLED;
  261. }
  262. static void wakeup_graph_return(struct ftrace_graph_ret *trace) { }
  263. static void wakeup_trace_open(struct trace_iterator *iter) { }
  264. static void wakeup_trace_close(struct trace_iterator *iter) { }
  265. #ifdef CONFIG_FUNCTION_TRACER
  266. static void wakeup_print_header(struct seq_file *s)
  267. {
  268. trace_default_header(s);
  269. }
  270. #else
  271. static void wakeup_print_header(struct seq_file *s)
  272. {
  273. trace_latency_header(s);
  274. }
  275. #endif /* CONFIG_FUNCTION_TRACER */
  276. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  277. /*
  278. * Should this new latency be reported/recorded?
  279. */
  280. static int report_latency(struct trace_array *tr, cycle_t delta)
  281. {
  282. if (tracing_thresh) {
  283. if (delta < tracing_thresh)
  284. return 0;
  285. } else {
  286. if (delta <= tr->max_latency)
  287. return 0;
  288. }
  289. return 1;
  290. }
  291. static void
  292. probe_wakeup_migrate_task(void *ignore, struct task_struct *task, int cpu)
  293. {
  294. if (task != wakeup_task)
  295. return;
  296. wakeup_current_cpu = cpu;
  297. }
  298. static void notrace
  299. probe_wakeup_sched_switch(void *ignore,
  300. struct task_struct *prev, struct task_struct *next)
  301. {
  302. struct trace_array_cpu *data;
  303. cycle_t T0, T1, delta;
  304. unsigned long flags;
  305. long disabled;
  306. int cpu;
  307. int pc;
  308. tracing_record_cmdline(prev);
  309. if (unlikely(!tracer_enabled))
  310. return;
  311. /*
  312. * When we start a new trace, we set wakeup_task to NULL
  313. * and then set tracer_enabled = 1. We want to make sure
  314. * that another CPU does not see the tracer_enabled = 1
  315. * and the wakeup_task with an older task, that might
  316. * actually be the same as next.
  317. */
  318. smp_rmb();
  319. if (next != wakeup_task)
  320. return;
  321. pc = preempt_count();
  322. /* disable local data, not wakeup_cpu data */
  323. cpu = raw_smp_processor_id();
  324. disabled = atomic_inc_return(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
  325. if (likely(disabled != 1))
  326. goto out;
  327. local_irq_save(flags);
  328. arch_spin_lock(&wakeup_lock);
  329. /* We could race with grabbing wakeup_lock */
  330. if (unlikely(!tracer_enabled || next != wakeup_task))
  331. goto out_unlock;
  332. /* The task we are waiting for is waking up */
  333. data = per_cpu_ptr(wakeup_trace->trace_buffer.data, wakeup_cpu);
  334. __trace_function(wakeup_trace, CALLER_ADDR0, CALLER_ADDR1, flags, pc);
  335. tracing_sched_switch_trace(wakeup_trace, prev, next, flags, pc);
  336. T0 = data->preempt_timestamp;
  337. T1 = ftrace_now(cpu);
  338. delta = T1-T0;
  339. if (!report_latency(wakeup_trace, delta))
  340. goto out_unlock;
  341. if (likely(!is_tracing_stopped())) {
  342. wakeup_trace->max_latency = delta;
  343. update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu);
  344. }
  345. out_unlock:
  346. __wakeup_reset(wakeup_trace);
  347. arch_spin_unlock(&wakeup_lock);
  348. local_irq_restore(flags);
  349. out:
  350. atomic_dec(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
  351. }
  352. static void __wakeup_reset(struct trace_array *tr)
  353. {
  354. wakeup_cpu = -1;
  355. wakeup_prio = -1;
  356. tracing_dl = 0;
  357. if (wakeup_task)
  358. put_task_struct(wakeup_task);
  359. wakeup_task = NULL;
  360. }
  361. static void wakeup_reset(struct trace_array *tr)
  362. {
  363. unsigned long flags;
  364. tracing_reset_online_cpus(&tr->trace_buffer);
  365. local_irq_save(flags);
  366. arch_spin_lock(&wakeup_lock);
  367. __wakeup_reset(tr);
  368. arch_spin_unlock(&wakeup_lock);
  369. local_irq_restore(flags);
  370. }
  371. static void
  372. probe_wakeup(void *ignore, struct task_struct *p, int success)
  373. {
  374. struct trace_array_cpu *data;
  375. int cpu = smp_processor_id();
  376. unsigned long flags;
  377. long disabled;
  378. int pc;
  379. if (likely(!tracer_enabled))
  380. return;
  381. tracing_record_cmdline(p);
  382. tracing_record_cmdline(current);
  383. /*
  384. * Semantic is like this:
  385. * - wakeup tracer handles all tasks in the system, independently
  386. * from their scheduling class;
  387. * - wakeup_rt tracer handles tasks belonging to sched_dl and
  388. * sched_rt class;
  389. * - wakeup_dl handles tasks belonging to sched_dl class only.
  390. */
  391. if (tracing_dl || (wakeup_dl && !dl_task(p)) ||
  392. (wakeup_rt && !dl_task(p) && !rt_task(p)) ||
  393. (!dl_task(p) && (p->prio >= wakeup_prio || p->prio >= current->prio)))
  394. return;
  395. pc = preempt_count();
  396. disabled = atomic_inc_return(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
  397. if (unlikely(disabled != 1))
  398. goto out;
  399. /* interrupts should be off from try_to_wake_up */
  400. arch_spin_lock(&wakeup_lock);
  401. /* check for races. */
  402. if (!tracer_enabled || tracing_dl ||
  403. (!dl_task(p) && p->prio >= wakeup_prio))
  404. goto out_locked;
  405. /* reset the trace */
  406. __wakeup_reset(wakeup_trace);
  407. wakeup_cpu = task_cpu(p);
  408. wakeup_current_cpu = wakeup_cpu;
  409. wakeup_prio = p->prio;
  410. /*
  411. * Once you start tracing a -deadline task, don't bother tracing
  412. * another task until the first one wakes up.
  413. */
  414. if (dl_task(p))
  415. tracing_dl = 1;
  416. else
  417. tracing_dl = 0;
  418. wakeup_task = p;
  419. get_task_struct(wakeup_task);
  420. local_save_flags(flags);
  421. data = per_cpu_ptr(wakeup_trace->trace_buffer.data, wakeup_cpu);
  422. data->preempt_timestamp = ftrace_now(cpu);
  423. tracing_sched_wakeup_trace(wakeup_trace, p, current, flags, pc);
  424. /*
  425. * We must be careful in using CALLER_ADDR2. But since wake_up
  426. * is not called by an assembly function (where as schedule is)
  427. * it should be safe to use it here.
  428. */
  429. __trace_function(wakeup_trace, CALLER_ADDR1, CALLER_ADDR2, flags, pc);
  430. out_locked:
  431. arch_spin_unlock(&wakeup_lock);
  432. out:
  433. atomic_dec(&per_cpu_ptr(wakeup_trace->trace_buffer.data, cpu)->disabled);
  434. }
  435. static void start_wakeup_tracer(struct trace_array *tr)
  436. {
  437. int ret;
  438. ret = register_trace_sched_wakeup(probe_wakeup, NULL);
  439. if (ret) {
  440. pr_info("wakeup trace: Couldn't activate tracepoint"
  441. " probe to kernel_sched_wakeup\n");
  442. return;
  443. }
  444. ret = register_trace_sched_wakeup_new(probe_wakeup, NULL);
  445. if (ret) {
  446. pr_info("wakeup trace: Couldn't activate tracepoint"
  447. " probe to kernel_sched_wakeup_new\n");
  448. goto fail_deprobe;
  449. }
  450. ret = register_trace_sched_switch(probe_wakeup_sched_switch, NULL);
  451. if (ret) {
  452. pr_info("sched trace: Couldn't activate tracepoint"
  453. " probe to kernel_sched_switch\n");
  454. goto fail_deprobe_wake_new;
  455. }
  456. ret = register_trace_sched_migrate_task(probe_wakeup_migrate_task, NULL);
  457. if (ret) {
  458. pr_info("wakeup trace: Couldn't activate tracepoint"
  459. " probe to kernel_sched_migrate_task\n");
  460. return;
  461. }
  462. wakeup_reset(tr);
  463. /*
  464. * Don't let the tracer_enabled = 1 show up before
  465. * the wakeup_task is reset. This may be overkill since
  466. * wakeup_reset does a spin_unlock after setting the
  467. * wakeup_task to NULL, but I want to be safe.
  468. * This is a slow path anyway.
  469. */
  470. smp_wmb();
  471. if (start_func_tracer(tr, is_graph()))
  472. printk(KERN_ERR "failed to start wakeup tracer\n");
  473. return;
  474. fail_deprobe_wake_new:
  475. unregister_trace_sched_wakeup_new(probe_wakeup, NULL);
  476. fail_deprobe:
  477. unregister_trace_sched_wakeup(probe_wakeup, NULL);
  478. }
  479. static void stop_wakeup_tracer(struct trace_array *tr)
  480. {
  481. tracer_enabled = 0;
  482. stop_func_tracer(tr, is_graph());
  483. unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL);
  484. unregister_trace_sched_wakeup_new(probe_wakeup, NULL);
  485. unregister_trace_sched_wakeup(probe_wakeup, NULL);
  486. unregister_trace_sched_migrate_task(probe_wakeup_migrate_task, NULL);
  487. }
  488. static bool wakeup_busy;
  489. static int __wakeup_tracer_init(struct trace_array *tr)
  490. {
  491. save_flags = trace_flags;
  492. /* non overwrite screws up the latency tracers */
  493. set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
  494. set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
  495. tr->max_latency = 0;
  496. wakeup_trace = tr;
  497. ftrace_init_array_ops(tr, wakeup_tracer_call);
  498. start_wakeup_tracer(tr);
  499. wakeup_busy = true;
  500. return 0;
  501. }
  502. static int wakeup_tracer_init(struct trace_array *tr)
  503. {
  504. if (wakeup_busy)
  505. return -EBUSY;
  506. wakeup_dl = 0;
  507. wakeup_rt = 0;
  508. return __wakeup_tracer_init(tr);
  509. }
  510. static int wakeup_rt_tracer_init(struct trace_array *tr)
  511. {
  512. if (wakeup_busy)
  513. return -EBUSY;
  514. wakeup_dl = 0;
  515. wakeup_rt = 1;
  516. return __wakeup_tracer_init(tr);
  517. }
  518. static int wakeup_dl_tracer_init(struct trace_array *tr)
  519. {
  520. if (wakeup_busy)
  521. return -EBUSY;
  522. wakeup_dl = 1;
  523. wakeup_rt = 0;
  524. return __wakeup_tracer_init(tr);
  525. }
  526. static void wakeup_tracer_reset(struct trace_array *tr)
  527. {
  528. int lat_flag = save_flags & TRACE_ITER_LATENCY_FMT;
  529. int overwrite_flag = save_flags & TRACE_ITER_OVERWRITE;
  530. stop_wakeup_tracer(tr);
  531. /* make sure we put back any tasks we are tracing */
  532. wakeup_reset(tr);
  533. set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, lat_flag);
  534. set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
  535. ftrace_reset_array_ops(tr);
  536. wakeup_busy = false;
  537. }
  538. static void wakeup_tracer_start(struct trace_array *tr)
  539. {
  540. wakeup_reset(tr);
  541. tracer_enabled = 1;
  542. }
  543. static void wakeup_tracer_stop(struct trace_array *tr)
  544. {
  545. tracer_enabled = 0;
  546. }
  547. static struct tracer wakeup_tracer __read_mostly =
  548. {
  549. .name = "wakeup",
  550. .init = wakeup_tracer_init,
  551. .reset = wakeup_tracer_reset,
  552. .start = wakeup_tracer_start,
  553. .stop = wakeup_tracer_stop,
  554. .print_max = true,
  555. .print_header = wakeup_print_header,
  556. .print_line = wakeup_print_line,
  557. .flags = &tracer_flags,
  558. .set_flag = wakeup_set_flag,
  559. .flag_changed = wakeup_flag_changed,
  560. #ifdef CONFIG_FTRACE_SELFTEST
  561. .selftest = trace_selftest_startup_wakeup,
  562. #endif
  563. .open = wakeup_trace_open,
  564. .close = wakeup_trace_close,
  565. .allow_instances = true,
  566. .use_max_tr = true,
  567. };
  568. static struct tracer wakeup_rt_tracer __read_mostly =
  569. {
  570. .name = "wakeup_rt",
  571. .init = wakeup_rt_tracer_init,
  572. .reset = wakeup_tracer_reset,
  573. .start = wakeup_tracer_start,
  574. .stop = wakeup_tracer_stop,
  575. .print_max = true,
  576. .print_header = wakeup_print_header,
  577. .print_line = wakeup_print_line,
  578. .flags = &tracer_flags,
  579. .set_flag = wakeup_set_flag,
  580. .flag_changed = wakeup_flag_changed,
  581. #ifdef CONFIG_FTRACE_SELFTEST
  582. .selftest = trace_selftest_startup_wakeup,
  583. #endif
  584. .open = wakeup_trace_open,
  585. .close = wakeup_trace_close,
  586. .allow_instances = true,
  587. .use_max_tr = true,
  588. };
  589. static struct tracer wakeup_dl_tracer __read_mostly =
  590. {
  591. .name = "wakeup_dl",
  592. .init = wakeup_dl_tracer_init,
  593. .reset = wakeup_tracer_reset,
  594. .start = wakeup_tracer_start,
  595. .stop = wakeup_tracer_stop,
  596. .print_max = true,
  597. .print_header = wakeup_print_header,
  598. .print_line = wakeup_print_line,
  599. .flags = &tracer_flags,
  600. .set_flag = wakeup_set_flag,
  601. .flag_changed = wakeup_flag_changed,
  602. #ifdef CONFIG_FTRACE_SELFTEST
  603. .selftest = trace_selftest_startup_wakeup,
  604. #endif
  605. .open = wakeup_trace_open,
  606. .close = wakeup_trace_close,
  607. .use_max_tr = true,
  608. };
  609. __init static int init_wakeup_tracer(void)
  610. {
  611. int ret;
  612. ret = register_tracer(&wakeup_tracer);
  613. if (ret)
  614. return ret;
  615. ret = register_tracer(&wakeup_rt_tracer);
  616. if (ret)
  617. return ret;
  618. ret = register_tracer(&wakeup_dl_tracer);
  619. if (ret)
  620. return ret;
  621. return 0;
  622. }
  623. core_initcall(init_wakeup_tracer);