cgroup.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM cgroup
  3. #if !defined(_TRACE_CGROUP_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_CGROUP_H
  5. #include <linux/cgroup.h>
  6. #include <linux/tracepoint.h>
  7. DECLARE_EVENT_CLASS(cgroup_root,
  8. TP_PROTO(struct cgroup_root *root),
  9. TP_ARGS(root),
  10. TP_STRUCT__entry(
  11. __field( int, root )
  12. __field( u16, ss_mask )
  13. __string( name, root->name )
  14. ),
  15. TP_fast_assign(
  16. __entry->root = root->hierarchy_id;
  17. __entry->ss_mask = root->subsys_mask;
  18. __assign_str(name, root->name);
  19. ),
  20. TP_printk("root=%d ss_mask=%#x name=%s",
  21. __entry->root, __entry->ss_mask, __get_str(name))
  22. );
  23. DEFINE_EVENT(cgroup_root, cgroup_setup_root,
  24. TP_PROTO(struct cgroup_root *root),
  25. TP_ARGS(root)
  26. );
  27. DEFINE_EVENT(cgroup_root, cgroup_destroy_root,
  28. TP_PROTO(struct cgroup_root *root),
  29. TP_ARGS(root)
  30. );
  31. DEFINE_EVENT(cgroup_root, cgroup_remount,
  32. TP_PROTO(struct cgroup_root *root),
  33. TP_ARGS(root)
  34. );
  35. DECLARE_EVENT_CLASS(cgroup,
  36. TP_PROTO(struct cgroup *cgrp),
  37. TP_ARGS(cgrp),
  38. TP_STRUCT__entry(
  39. __field( int, root )
  40. __field( int, id )
  41. __field( int, level )
  42. __dynamic_array(char, path,
  43. cgrp->kn ? cgroup_path(cgrp, NULL, 0) + 1
  44. : strlen("(null)"))
  45. ),
  46. TP_fast_assign(
  47. __entry->root = cgrp->root->hierarchy_id;
  48. __entry->id = cgrp->id;
  49. __entry->level = cgrp->level;
  50. if (cgrp->kn)
  51. cgroup_path(cgrp, __get_dynamic_array(path),
  52. __get_dynamic_array_len(path));
  53. else
  54. __assign_str(path, "(null)");
  55. ),
  56. TP_printk("root=%d id=%d level=%d path=%s",
  57. __entry->root, __entry->id, __entry->level, __get_str(path))
  58. );
  59. DEFINE_EVENT(cgroup, cgroup_mkdir,
  60. TP_PROTO(struct cgroup *cgroup),
  61. TP_ARGS(cgroup)
  62. );
  63. DEFINE_EVENT(cgroup, cgroup_rmdir,
  64. TP_PROTO(struct cgroup *cgroup),
  65. TP_ARGS(cgroup)
  66. );
  67. DEFINE_EVENT(cgroup, cgroup_release,
  68. TP_PROTO(struct cgroup *cgroup),
  69. TP_ARGS(cgroup)
  70. );
  71. DEFINE_EVENT(cgroup, cgroup_rename,
  72. TP_PROTO(struct cgroup *cgroup),
  73. TP_ARGS(cgroup)
  74. );
  75. DECLARE_EVENT_CLASS(cgroup_migrate,
  76. TP_PROTO(struct cgroup *dst_cgrp, struct task_struct *task, bool threadgroup),
  77. TP_ARGS(dst_cgrp, task, threadgroup),
  78. TP_STRUCT__entry(
  79. __field( int, dst_root )
  80. __field( int, dst_id )
  81. __field( int, dst_level )
  82. __dynamic_array(char, dst_path,
  83. dst_cgrp->kn ? cgroup_path(dst_cgrp, NULL, 0) + 1
  84. : strlen("(null)"))
  85. __field( int, pid )
  86. __string( comm, task->comm )
  87. ),
  88. TP_fast_assign(
  89. __entry->dst_root = dst_cgrp->root->hierarchy_id;
  90. __entry->dst_id = dst_cgrp->id;
  91. __entry->dst_level = dst_cgrp->level;
  92. if (dst_cgrp->kn)
  93. cgroup_path(dst_cgrp, __get_dynamic_array(dst_path),
  94. __get_dynamic_array_len(dst_path));
  95. else
  96. __assign_str(dst_path, "(null)");
  97. __entry->pid = task->pid;
  98. __assign_str(comm, task->comm);
  99. ),
  100. TP_printk("dst_root=%d dst_id=%d dst_level=%d dst_path=%s pid=%d comm=%s",
  101. __entry->dst_root, __entry->dst_id, __entry->dst_level,
  102. __get_str(dst_path), __entry->pid, __get_str(comm))
  103. );
  104. DEFINE_EVENT(cgroup_migrate, cgroup_attach_task,
  105. TP_PROTO(struct cgroup *dst_cgrp, struct task_struct *task, bool threadgroup),
  106. TP_ARGS(dst_cgrp, task, threadgroup)
  107. );
  108. DEFINE_EVENT(cgroup_migrate, cgroup_transfer_tasks,
  109. TP_PROTO(struct cgroup *dst_cgrp, struct task_struct *task, bool threadgroup),
  110. TP_ARGS(dst_cgrp, task, threadgroup)
  111. );
  112. #endif /* _TRACE_CGROUP_H */
  113. /* This part must be outside protection */
  114. #include <trace/define_trace.h>