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