plugin_tlb.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-License-Identifier: LGPL-2.1
  2. /*
  3. * Copyright (C) 2015 Red Hat Inc, Steven Rostedt <[email protected]>
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "event-parse.h"
  9. enum tlb_flush_reason {
  10. TLB_FLUSH_ON_TASK_SWITCH,
  11. TLB_REMOTE_SHOOTDOWN,
  12. TLB_LOCAL_SHOOTDOWN,
  13. TLB_LOCAL_MM_SHOOTDOWN,
  14. NR_TLB_FLUSH_REASONS,
  15. };
  16. static int tlb_flush_handler(struct trace_seq *s, struct tep_record *record,
  17. struct tep_event *event, void *context)
  18. {
  19. unsigned long long val;
  20. trace_seq_printf(s, "pages=");
  21. tep_print_num_field(s, "%ld", event, "pages", record, 1);
  22. if (tep_get_field_val(s, event, "reason", record, &val, 1) < 0)
  23. return -1;
  24. trace_seq_puts(s, " reason=");
  25. switch (val) {
  26. case TLB_FLUSH_ON_TASK_SWITCH:
  27. trace_seq_puts(s, "flush on task switch");
  28. break;
  29. case TLB_REMOTE_SHOOTDOWN:
  30. trace_seq_puts(s, "remote shootdown");
  31. break;
  32. case TLB_LOCAL_SHOOTDOWN:
  33. trace_seq_puts(s, "local shootdown");
  34. break;
  35. case TLB_LOCAL_MM_SHOOTDOWN:
  36. trace_seq_puts(s, "local mm shootdown");
  37. break;
  38. }
  39. trace_seq_printf(s, " (%lld)", val);
  40. return 0;
  41. }
  42. int TEP_PLUGIN_LOADER(struct tep_handle *tep)
  43. {
  44. tep_register_event_handler(tep, -1, "tlb", "tlb_flush",
  45. tlb_flush_handler, NULL);
  46. return 0;
  47. }
  48. void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
  49. {
  50. tep_unregister_event_handler(tep, -1,
  51. "tlb", "tlb_flush",
  52. tlb_flush_handler, NULL);
  53. }