| 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); | 
|---|
| 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, const char *path), | 
|---|
| 57 |  | 
|---|
| 58 | TP_ARGS(cgrp, path), | 
|---|
| 59 |  | 
|---|
| 60 | TP_STRUCT__entry( | 
|---|
| 61 | __field(	int,		root			) | 
|---|
| 62 | __field(	int,		level			) | 
|---|
| 63 | __field(	u64,		id			) | 
|---|
| 64 | __string(	path,		path			) | 
|---|
| 65 | ), | 
|---|
| 66 |  | 
|---|
| 67 | TP_fast_assign( | 
|---|
| 68 | __entry->root = cgrp->root->hierarchy_id; | 
|---|
| 69 | __entry->id = cgroup_id(cgrp); | 
|---|
| 70 | __entry->level = cgrp->level; | 
|---|
| 71 | __assign_str(path); | 
|---|
| 72 | ), | 
|---|
| 73 |  | 
|---|
| 74 | TP_printk( "root=%d id=%llu level=%d path=%s", | 
|---|
| 75 | __entry->root, __entry->id, __entry->level, __get_str(path)) | 
|---|
| 76 | ); | 
|---|
| 77 |  | 
|---|
| 78 | DEFINE_EVENT(cgroup, cgroup_mkdir, | 
|---|
| 79 |  | 
|---|
| 80 | TP_PROTO(struct cgroup *cgrp, const char *path), | 
|---|
| 81 |  | 
|---|
| 82 | TP_ARGS(cgrp, path) | 
|---|
| 83 | ); | 
|---|
| 84 |  | 
|---|
| 85 | DEFINE_EVENT(cgroup, cgroup_rmdir, | 
|---|
| 86 |  | 
|---|
| 87 | TP_PROTO(struct cgroup *cgrp, const char *path), | 
|---|
| 88 |  | 
|---|
| 89 | TP_ARGS(cgrp, path) | 
|---|
| 90 | ); | 
|---|
| 91 |  | 
|---|
| 92 | DEFINE_EVENT(cgroup, cgroup_release, | 
|---|
| 93 |  | 
|---|
| 94 | TP_PROTO(struct cgroup *cgrp, const char *path), | 
|---|
| 95 |  | 
|---|
| 96 | TP_ARGS(cgrp, path) | 
|---|
| 97 | ); | 
|---|
| 98 |  | 
|---|
| 99 | DEFINE_EVENT(cgroup, cgroup_rename, | 
|---|
| 100 |  | 
|---|
| 101 | TP_PROTO(struct cgroup *cgrp, const char *path), | 
|---|
| 102 |  | 
|---|
| 103 | TP_ARGS(cgrp, path) | 
|---|
| 104 | ); | 
|---|
| 105 |  | 
|---|
| 106 | DEFINE_EVENT(cgroup, cgroup_freeze, | 
|---|
| 107 |  | 
|---|
| 108 | TP_PROTO(struct cgroup *cgrp, const char *path), | 
|---|
| 109 |  | 
|---|
| 110 | TP_ARGS(cgrp, path) | 
|---|
| 111 | ); | 
|---|
| 112 |  | 
|---|
| 113 | DEFINE_EVENT(cgroup, cgroup_unfreeze, | 
|---|
| 114 |  | 
|---|
| 115 | TP_PROTO(struct cgroup *cgrp, const char *path), | 
|---|
| 116 |  | 
|---|
| 117 | TP_ARGS(cgrp, path) | 
|---|
| 118 | ); | 
|---|
| 119 |  | 
|---|
| 120 | DECLARE_EVENT_CLASS(cgroup_migrate, | 
|---|
| 121 |  | 
|---|
| 122 | TP_PROTO(struct cgroup *dst_cgrp, const char *path, | 
|---|
| 123 | struct task_struct *task, bool threadgroup), | 
|---|
| 124 |  | 
|---|
| 125 | TP_ARGS(dst_cgrp, path, task, threadgroup), | 
|---|
| 126 |  | 
|---|
| 127 | TP_STRUCT__entry( | 
|---|
| 128 | __field(	int,		dst_root		) | 
|---|
| 129 | __field(	int,		dst_level		) | 
|---|
| 130 | __field(	u64,		dst_id			) | 
|---|
| 131 | __field(	int,		pid			) | 
|---|
| 132 | __string(	dst_path,	path			) | 
|---|
| 133 | __string(	comm,		task->comm		) | 
|---|
| 134 | ), | 
|---|
| 135 |  | 
|---|
| 136 | TP_fast_assign( | 
|---|
| 137 | __entry->dst_root = dst_cgrp->root->hierarchy_id; | 
|---|
| 138 | __entry->dst_id = cgroup_id(dst_cgrp); | 
|---|
| 139 | __entry->dst_level = dst_cgrp->level; | 
|---|
| 140 | __assign_str(dst_path); | 
|---|
| 141 | __entry->pid = task->pid; | 
|---|
| 142 | __assign_str(comm); | 
|---|
| 143 | ), | 
|---|
| 144 |  | 
|---|
| 145 | TP_printk( "dst_root=%d dst_id=%llu dst_level=%d dst_path=%s pid=%d comm=%s", | 
|---|
| 146 | __entry->dst_root, __entry->dst_id, __entry->dst_level, | 
|---|
| 147 | __get_str(dst_path), __entry->pid, __get_str(comm)) | 
|---|
| 148 | ); | 
|---|
| 149 |  | 
|---|
| 150 | DEFINE_EVENT(cgroup_migrate, cgroup_attach_task, | 
|---|
| 151 |  | 
|---|
| 152 | TP_PROTO(struct cgroup *dst_cgrp, const char *path, | 
|---|
| 153 | struct task_struct *task, bool threadgroup), | 
|---|
| 154 |  | 
|---|
| 155 | TP_ARGS(dst_cgrp, path, task, threadgroup) | 
|---|
| 156 | ); | 
|---|
| 157 |  | 
|---|
| 158 | DEFINE_EVENT(cgroup_migrate, cgroup_transfer_tasks, | 
|---|
| 159 |  | 
|---|
| 160 | TP_PROTO(struct cgroup *dst_cgrp, const char *path, | 
|---|
| 161 | struct task_struct *task, bool threadgroup), | 
|---|
| 162 |  | 
|---|
| 163 | TP_ARGS(dst_cgrp, path, task, threadgroup) | 
|---|
| 164 | ); | 
|---|
| 165 |  | 
|---|
| 166 | DECLARE_EVENT_CLASS(cgroup_event, | 
|---|
| 167 |  | 
|---|
| 168 | TP_PROTO(struct cgroup *cgrp, const char *path, int val), | 
|---|
| 169 |  | 
|---|
| 170 | TP_ARGS(cgrp, path, val), | 
|---|
| 171 |  | 
|---|
| 172 | TP_STRUCT__entry( | 
|---|
| 173 | __field(	int,		root			) | 
|---|
| 174 | __field(	int,		level			) | 
|---|
| 175 | __field(	u64,		id			) | 
|---|
| 176 | __string(	path,		path			) | 
|---|
| 177 | __field(	int,		val			) | 
|---|
| 178 | ), | 
|---|
| 179 |  | 
|---|
| 180 | TP_fast_assign( | 
|---|
| 181 | __entry->root = cgrp->root->hierarchy_id; | 
|---|
| 182 | __entry->id = cgroup_id(cgrp); | 
|---|
| 183 | __entry->level = cgrp->level; | 
|---|
| 184 | __assign_str(path); | 
|---|
| 185 | __entry->val = val; | 
|---|
| 186 | ), | 
|---|
| 187 |  | 
|---|
| 188 | TP_printk( "root=%d id=%llu level=%d path=%s val=%d", | 
|---|
| 189 | __entry->root, __entry->id, __entry->level, __get_str(path), | 
|---|
| 190 | __entry->val) | 
|---|
| 191 | ); | 
|---|
| 192 |  | 
|---|
| 193 | DEFINE_EVENT(cgroup_event, cgroup_notify_populated, | 
|---|
| 194 |  | 
|---|
| 195 | TP_PROTO(struct cgroup *cgrp, const char *path, int val), | 
|---|
| 196 |  | 
|---|
| 197 | TP_ARGS(cgrp, path, val) | 
|---|
| 198 | ); | 
|---|
| 199 |  | 
|---|
| 200 | DEFINE_EVENT(cgroup_event, cgroup_notify_frozen, | 
|---|
| 201 |  | 
|---|
| 202 | TP_PROTO(struct cgroup *cgrp, const char *path, int val), | 
|---|
| 203 |  | 
|---|
| 204 | TP_ARGS(cgrp, path, val) | 
|---|
| 205 | ); | 
|---|
| 206 |  | 
|---|
| 207 | DECLARE_EVENT_CLASS(cgroup_rstat, | 
|---|
| 208 |  | 
|---|
| 209 | TP_PROTO(struct cgroup *cgrp, int cpu, bool contended), | 
|---|
| 210 |  | 
|---|
| 211 | TP_ARGS(cgrp, cpu, contended), | 
|---|
| 212 |  | 
|---|
| 213 | TP_STRUCT__entry( | 
|---|
| 214 | __field(	int,		root			) | 
|---|
| 215 | __field(	int,		level			) | 
|---|
| 216 | __field(	u64,		id			) | 
|---|
| 217 | __field(	int,		cpu			) | 
|---|
| 218 | __field(	bool,		contended		) | 
|---|
| 219 | ), | 
|---|
| 220 |  | 
|---|
| 221 | TP_fast_assign( | 
|---|
| 222 | __entry->root = cgrp->root->hierarchy_id; | 
|---|
| 223 | __entry->id = cgroup_id(cgrp); | 
|---|
| 224 | __entry->level = cgrp->level; | 
|---|
| 225 | __entry->cpu = cpu; | 
|---|
| 226 | __entry->contended = contended; | 
|---|
| 227 | ), | 
|---|
| 228 |  | 
|---|
| 229 | TP_printk( "root=%d id=%llu level=%d cpu=%d lock contended:%d", | 
|---|
| 230 | __entry->root, __entry->id, __entry->level, | 
|---|
| 231 | __entry->cpu, __entry->contended) | 
|---|
| 232 | ); | 
|---|
| 233 |  | 
|---|
| 234 | /* | 
|---|
| 235 | * Related to locks: | 
|---|
| 236 | * global rstat_base_lock for base stats | 
|---|
| 237 | * cgroup_subsys::rstat_ss_lock for subsystem stats | 
|---|
| 238 | */ | 
|---|
| 239 | DEFINE_EVENT(cgroup_rstat, cgroup_rstat_lock_contended, | 
|---|
| 240 |  | 
|---|
| 241 | TP_PROTO(struct cgroup *cgrp, int cpu, bool contended), | 
|---|
| 242 |  | 
|---|
| 243 | TP_ARGS(cgrp, cpu, contended) | 
|---|
| 244 | ); | 
|---|
| 245 |  | 
|---|
| 246 | DEFINE_EVENT(cgroup_rstat, cgroup_rstat_locked, | 
|---|
| 247 |  | 
|---|
| 248 | TP_PROTO(struct cgroup *cgrp, int cpu, bool contended), | 
|---|
| 249 |  | 
|---|
| 250 | TP_ARGS(cgrp, cpu, contended) | 
|---|
| 251 | ); | 
|---|
| 252 |  | 
|---|
| 253 | DEFINE_EVENT(cgroup_rstat, cgroup_rstat_unlock, | 
|---|
| 254 |  | 
|---|
| 255 | TP_PROTO(struct cgroup *cgrp, int cpu, bool contended), | 
|---|
| 256 |  | 
|---|
| 257 | TP_ARGS(cgrp, cpu, contended) | 
|---|
| 258 | ); | 
|---|
| 259 |  | 
|---|
| 260 | #endif /* _TRACE_CGROUP_H */ | 
|---|
| 261 |  | 
|---|
| 262 | /* This part must be outside protection */ | 
|---|
| 263 | #include <trace/define_trace.h> | 
|---|
| 264 |  | 
|---|