plugin_hrtimer.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: LGPL-2.1
  2. /*
  3. * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <[email protected]>
  4. * Copyright (C) 2009 Johannes Berg <[email protected]>
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "event-parse.h"
  10. #include "trace-seq.h"
  11. static int timer_expire_handler(struct trace_seq *s,
  12. struct tep_record *record,
  13. struct tep_event *event, void *context)
  14. {
  15. trace_seq_printf(s, "hrtimer=");
  16. if (tep_print_num_field(s, "0x%llx", event, "timer",
  17. record, 0) == -1)
  18. tep_print_num_field(s, "0x%llx", event, "hrtimer",
  19. record, 1);
  20. trace_seq_printf(s, " now=");
  21. tep_print_num_field(s, "%llu", event, "now", record, 1);
  22. tep_print_func_field(s, " function=%s", event, "function",
  23. record, 0);
  24. return 0;
  25. }
  26. static int timer_start_handler(struct trace_seq *s,
  27. struct tep_record *record,
  28. struct tep_event *event, void *context)
  29. {
  30. trace_seq_printf(s, "hrtimer=");
  31. if (tep_print_num_field(s, "0x%llx", event, "timer",
  32. record, 0) == -1)
  33. tep_print_num_field(s, "0x%llx", event, "hrtimer",
  34. record, 1);
  35. tep_print_func_field(s, " function=%s", event, "function",
  36. record, 0);
  37. trace_seq_printf(s, " expires=");
  38. tep_print_num_field(s, "%llu", event, "expires", record, 1);
  39. trace_seq_printf(s, " softexpires=");
  40. tep_print_num_field(s, "%llu", event, "softexpires", record, 1);
  41. return 0;
  42. }
  43. int TEP_PLUGIN_LOADER(struct tep_handle *tep)
  44. {
  45. tep_register_event_handler(tep, -1,
  46. "timer", "hrtimer_expire_entry",
  47. timer_expire_handler, NULL);
  48. tep_register_event_handler(tep, -1, "timer", "hrtimer_start",
  49. timer_start_handler, NULL);
  50. return 0;
  51. }
  52. void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
  53. {
  54. tep_unregister_event_handler(tep, -1,
  55. "timer", "hrtimer_expire_entry",
  56. timer_expire_handler, NULL);
  57. tep_unregister_event_handler(tep, -1, "timer", "hrtimer_start",
  58. timer_start_handler, NULL);
  59. }