plugin_jbd2.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: LGPL-2.1
  2. /*
  3. * Copyright (C) 2010 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. #include "trace-seq.h"
  10. #define MINORBITS 20
  11. #define MINORMASK ((1U << MINORBITS) - 1)
  12. #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
  13. #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
  14. static unsigned long long
  15. process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args)
  16. {
  17. unsigned int dev = args[0];
  18. trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev));
  19. return 0;
  20. }
  21. static unsigned long long
  22. process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
  23. {
  24. unsigned long long jiffies = args[0];
  25. trace_seq_printf(s, "%lld", jiffies);
  26. return jiffies;
  27. }
  28. int TEP_PLUGIN_LOADER(struct tep_handle *tep)
  29. {
  30. tep_register_print_function(tep,
  31. process_jbd2_dev_to_name,
  32. TEP_FUNC_ARG_STRING,
  33. "jbd2_dev_to_name",
  34. TEP_FUNC_ARG_INT,
  35. TEP_FUNC_ARG_VOID);
  36. tep_register_print_function(tep,
  37. process_jiffies_to_msecs,
  38. TEP_FUNC_ARG_LONG,
  39. "jiffies_to_msecs",
  40. TEP_FUNC_ARG_LONG,
  41. TEP_FUNC_ARG_VOID);
  42. return 0;
  43. }
  44. void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
  45. {
  46. tep_unregister_print_function(tep, process_jbd2_dev_to_name,
  47. "jbd2_dev_to_name");
  48. tep_unregister_print_function(tep, process_jiffies_to_msecs,
  49. "jiffies_to_msecs");
  50. }