cgroup.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM cgroup
  4. #if !defined(_TRACE_CGROUP_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_CGROUP_H
  6. #include <linux/cgroup.h>
  7. #include <linux/tracepoint.h>
  8. DECLARE_EVENT_CLASS(cgroup_root,
  9. TP_PROTO(struct cgroup_root *root),
  10. TP_ARGS(root),
  11. TP_STRUCT__entry(
  12. __field( int, root )
  13. __field( u16, ss_mask )
  14. __string( name, root->name )
  15. ),
  16. TP_fast_assign(
  17. __entry->root = root->hierarchy_id;
  18. __entry->ss_mask = root->subsys_mask;
  19. __assign_str(name, root->name);
  20. ),
  21. TP_printk("root=%d ss_mask=%#x name=%s",
  22. __entry->root, __entry->ss_mask, __get_str(name))
  23. );
  24. DEFINE_EVENT(cgroup_root, cgroup_setup_root,
  25. TP_PROTO(struct cgroup_root *root),
  26. TP_ARGS(root)
  27. );
  28. DEFINE_EVENT(cgroup_root, cgroup_destroy_root,
  29. TP_PROTO(struct cgroup_root *root),
  30. TP_ARGS(root)
  31. );
  32. DEFINE_EVENT(cgroup_root, cgroup_remount,
  33. TP_PROTO(struct cgroup_root *root),
  34. TP_ARGS(root)
  35. );
  36. DECLARE_EVENT_CLASS(cgroup,
  37. TP_PROTO(struct cgroup *cgrp, const char *path),
  38. TP_ARGS(cgrp, path),
  39. TP_STRUCT__entry(
  40. __field( int, root )
  41. __field( int, level )
  42. __field( u64, id )
  43. __string( path, path )
  44. ),
  45. TP_fast_assign(
  46. __entry->root = cgrp->root->hierarchy_id;
  47. __entry->id = cgroup_id(cgrp);
  48. __entry->level = cgrp->level;
  49. __assign_str(path, path);
  50. ),
  51. TP_printk("root=%d id=%llu level=%d path=%s",
  52. __entry->root, __entry->id, __entry->level, __get_str(path))
  53. );
  54. DEFINE_EVENT(cgroup, cgroup_mkdir,
  55. TP_PROTO(struct cgroup *cgrp, const char *path),
  56. TP_ARGS(cgrp, path)
  57. );
  58. DEFINE_EVENT(cgroup, cgroup_rmdir,
  59. TP_PROTO(struct cgroup *cgrp, const char *path),
  60. TP_ARGS(cgrp, path)
  61. );
  62. DEFINE_EVENT(cgroup, cgroup_release,
  63. TP_PROTO(struct cgroup *cgrp, const char *path),
  64. TP_ARGS(cgrp, path)
  65. );
  66. DEFINE_EVENT(cgroup, cgroup_rename,
  67. TP_PROTO(struct cgroup *cgrp, const char *path),
  68. TP_ARGS(cgrp, path)
  69. );
  70. DEFINE_EVENT(cgroup, cgroup_freeze,
  71. TP_PROTO(struct cgroup *cgrp, const char *path),
  72. TP_ARGS(cgrp, path)
  73. );
  74. DEFINE_EVENT(cgroup, cgroup_unfreeze,
  75. TP_PROTO(struct cgroup *cgrp, const char *path),
  76. TP_ARGS(cgrp, path)
  77. );
  78. DECLARE_EVENT_CLASS(cgroup_migrate,
  79. TP_PROTO(struct cgroup *dst_cgrp, const char *path,
  80. struct task_struct *task, bool threadgroup),
  81. TP_ARGS(dst_cgrp, path, task, threadgroup),
  82. TP_STRUCT__entry(
  83. __field( int, dst_root )
  84. __field( int, dst_level )
  85. __field( u64, dst_id )
  86. __field( int, pid )
  87. __string( dst_path, path )
  88. __string( comm, task->comm )
  89. ),
  90. TP_fast_assign(
  91. __entry->dst_root = dst_cgrp->root->hierarchy_id;
  92. __entry->dst_id = cgroup_id(dst_cgrp);
  93. __entry->dst_level = dst_cgrp->level;
  94. __assign_str(dst_path, path);
  95. __entry->pid = task->pid;
  96. __assign_str(comm, task->comm);
  97. ),
  98. TP_printk("dst_root=%d dst_id=%llu dst_level=%d dst_path=%s pid=%d comm=%s",
  99. __entry->dst_root, __entry->dst_id, __entry->dst_level,
  100. __get_str(dst_path), __entry->pid, __get_str(comm))
  101. );
  102. DEFINE_EVENT(cgroup_migrate, cgroup_attach_task,
  103. TP_PROTO(struct cgroup *dst_cgrp, const char *path,
  104. struct task_struct *task, bool threadgroup),
  105. TP_ARGS(dst_cgrp, path, task, threadgroup)
  106. );
  107. DEFINE_EVENT(cgroup_migrate, cgroup_transfer_tasks,
  108. TP_PROTO(struct cgroup *dst_cgrp, const char *path,
  109. struct task_struct *task, bool threadgroup),
  110. TP_ARGS(dst_cgrp, path, task, threadgroup)
  111. );
  112. DECLARE_EVENT_CLASS(cgroup_event,
  113. TP_PROTO(struct cgroup *cgrp, const char *path, int val),
  114. TP_ARGS(cgrp, path, val),
  115. TP_STRUCT__entry(
  116. __field( int, root )
  117. __field( int, level )
  118. __field( u64, id )
  119. __string( path, path )
  120. __field( int, val )
  121. ),
  122. TP_fast_assign(
  123. __entry->root = cgrp->root->hierarchy_id;
  124. __entry->id = cgroup_id(cgrp);
  125. __entry->level = cgrp->level;
  126. __assign_str(path, path);
  127. __entry->val = val;
  128. ),
  129. TP_printk("root=%d id=%llu level=%d path=%s val=%d",
  130. __entry->root, __entry->id, __entry->level, __get_str(path),
  131. __entry->val)
  132. );
  133. DEFINE_EVENT(cgroup_event, cgroup_notify_populated,
  134. TP_PROTO(struct cgroup *cgrp, const char *path, int val),
  135. TP_ARGS(cgrp, path, val)
  136. );
  137. DEFINE_EVENT(cgroup_event, cgroup_notify_frozen,
  138. TP_PROTO(struct cgroup *cgrp, const char *path, int val),
  139. TP_ARGS(cgrp, path, val)
  140. );
  141. #endif /* _TRACE_CGROUP_H */
  142. /* This part must be outside protection */
  143. #include <trace/define_trace.h>