trace_functions.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * ring buffer based function tracer
  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 William Lee Irwin III
  11. */
  12. #include <linux/debugfs.h>
  13. #include <linux/uaccess.h>
  14. #include <linux/ftrace.h>
  15. #include <linux/fs.h>
  16. #include "trace.h"
  17. static void start_function_trace(struct trace_array *tr)
  18. {
  19. tr->cpu = get_cpu();
  20. tracing_reset_online_cpus(tr);
  21. put_cpu();
  22. tracing_start_cmdline_record();
  23. tracing_start_function_trace();
  24. }
  25. static void stop_function_trace(struct trace_array *tr)
  26. {
  27. tracing_stop_function_trace();
  28. tracing_stop_cmdline_record();
  29. }
  30. static int function_trace_init(struct trace_array *tr)
  31. {
  32. start_function_trace(tr);
  33. return 0;
  34. }
  35. static void function_trace_reset(struct trace_array *tr)
  36. {
  37. stop_function_trace(tr);
  38. }
  39. static void function_trace_start(struct trace_array *tr)
  40. {
  41. tracing_reset_online_cpus(tr);
  42. }
  43. static struct tracer function_trace __read_mostly =
  44. {
  45. .name = "function",
  46. .init = function_trace_init,
  47. .reset = function_trace_reset,
  48. .start = function_trace_start,
  49. #ifdef CONFIG_FTRACE_SELFTEST
  50. .selftest = trace_selftest_startup_function,
  51. #endif
  52. };
  53. static __init int init_function_trace(void)
  54. {
  55. return register_tracer(&function_trace);
  56. }
  57. device_initcall(init_function_trace);