plugin_jbd2.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  3. *
  4. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation;
  8. * version 2.1 of the License (not later!)
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this program; if not, see <http://www.gnu.org/licenses>
  17. *
  18. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include "event-parse.h"
  24. #include "trace-seq.h"
  25. #define MINORBITS 20
  26. #define MINORMASK ((1U << MINORBITS) - 1)
  27. #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
  28. #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
  29. static unsigned long long
  30. process_jbd2_dev_to_name(struct trace_seq *s, unsigned long long *args)
  31. {
  32. unsigned int dev = args[0];
  33. trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev));
  34. return 0;
  35. }
  36. static unsigned long long
  37. process_jiffies_to_msecs(struct trace_seq *s, unsigned long long *args)
  38. {
  39. unsigned long long jiffies = args[0];
  40. trace_seq_printf(s, "%lld", jiffies);
  41. return jiffies;
  42. }
  43. int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
  44. {
  45. tep_register_print_function(pevent,
  46. process_jbd2_dev_to_name,
  47. TEP_FUNC_ARG_STRING,
  48. "jbd2_dev_to_name",
  49. TEP_FUNC_ARG_INT,
  50. TEP_FUNC_ARG_VOID);
  51. tep_register_print_function(pevent,
  52. process_jiffies_to_msecs,
  53. TEP_FUNC_ARG_LONG,
  54. "jiffies_to_msecs",
  55. TEP_FUNC_ARG_LONG,
  56. TEP_FUNC_ARG_VOID);
  57. return 0;
  58. }
  59. void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
  60. {
  61. tep_unregister_print_function(pevent, process_jbd2_dev_to_name,
  62. "jbd2_dev_to_name");
  63. tep_unregister_print_function(pevent, process_jiffies_to_msecs,
  64. "jiffies_to_msecs");
  65. }