trace_sched_wakeup.c 17 KB

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