plugin_jbd2.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #define MINORBITS 20
  25. #define MINORMASK ((1U << MINORBITS) - 1)
  26. #define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
  27. #define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
  28. static unsigned long long
  29. process_jbd2_dev_to_name(struct trace_seq *s,
  30. 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,
  38. unsigned long long *args)
  39. {
  40. unsigned long long jiffies = args[0];
  41. trace_seq_printf(s, "%lld", jiffies);
  42. return jiffies;
  43. }
  44. int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
  45. {
  46. pevent_register_print_function(pevent,
  47. process_jbd2_dev_to_name,
  48. PEVENT_FUNC_ARG_STRING,
  49. "jbd2_dev_to_name",
  50. PEVENT_FUNC_ARG_INT,
  51. PEVENT_FUNC_ARG_VOID);
  52. pevent_register_print_function(pevent,
  53. process_jiffies_to_msecs,
  54. PEVENT_FUNC_ARG_LONG,
  55. "jiffies_to_msecs",
  56. PEVENT_FUNC_ARG_LONG,
  57. PEVENT_FUNC_ARG_VOID);
  58. return 0;
  59. }
  60. void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
  61. {
  62. pevent_unregister_print_function(pevent, process_jbd2_dev_to_name,
  63. "jbd2_dev_to_name");
  64. pevent_unregister_print_function(pevent, process_jiffies_to_msecs,
  65. "jiffies_to_msecs");
  66. }