Commit | Line | Data |
---|---|---|
9f36eaed | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
c337ddc2 MD |
2 | #undef TRACE_SYSTEM |
3 | #define TRACE_SYSTEM lttng_statedump | |
4 | ||
3bc29f0a MD |
5 | #if !defined(LTTNG_TRACE_LTTNG_STATEDUMP_H) || defined(TRACE_HEADER_MULTI_READ) |
6 | #define LTTNG_TRACE_LTTNG_STATEDUMP_H | |
c337ddc2 | 7 | |
6ec43db8 | 8 | #include <probes/lttng-tracepoint-event.h> |
90fffd13 | 9 | #include <linux/nsproxy.h> |
1965e6b4 MJ |
10 | #include <linux/cgroup.h> |
11 | #include <linux/ipc_namespace.h> | |
12 | #include <net/net_namespace.h> | |
73e8ba37 | 13 | #include <linux/pid_namespace.h> |
1965e6b4 MJ |
14 | #include <linux/user_namespace.h> |
15 | #include <linux/utsname.h> | |
f0dbdefb | 16 | #include <linux/types.h> |
7bbf55ea | 17 | #include <linux/version.h> |
1965e6b4 MJ |
18 | #include <wrapper/namespace.h> |
19 | #include <wrapper/user_namespace.h> | |
7bbf55ea | 20 | |
1965e6b4 MJ |
21 | #ifndef LTTNG_MNT_NS_MISSING_HEADER |
22 | # ifndef ONCE_LTTNG_FS_MOUNT_H | |
23 | # define ONCE_LTTNG_FS_MOUNT_H | |
24 | # include <../fs/mount.h> | |
25 | # endif | |
7bbf55ea | 26 | #endif |
c337ddc2 | 27 | |
3bc29f0a | 28 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_start, |
c337ddc2 MD |
29 | TP_PROTO(struct lttng_session *session), |
30 | TP_ARGS(session), | |
f127e61e | 31 | TP_FIELDS() |
c337ddc2 MD |
32 | ) |
33 | ||
3bc29f0a | 34 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_end, |
c337ddc2 MD |
35 | TP_PROTO(struct lttng_session *session), |
36 | TP_ARGS(session), | |
f127e61e | 37 | TP_FIELDS() |
c337ddc2 MD |
38 | ) |
39 | ||
3bc29f0a | 40 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state, |
c337ddc2 MD |
41 | TP_PROTO(struct lttng_session *session, |
42 | struct task_struct *p, | |
e7a0ca72 MD |
43 | int type, int mode, int submode, int status, |
44 | struct files_struct *files), | |
45 | TP_ARGS(session, p, type, mode, submode, status, files), | |
f127e61e MD |
46 | TP_FIELDS( |
47 | ctf_integer(pid_t, tid, p->pid) | |
f127e61e | 48 | ctf_integer(pid_t, pid, p->tgid) |
f127e61e | 49 | ctf_integer(pid_t, ppid, |
c337ddc2 MD |
50 | ({ |
51 | pid_t ret; | |
52 | ||
53 | rcu_read_lock(); | |
54 | ret = task_tgid_nr(p->real_parent); | |
55 | rcu_read_unlock(); | |
56 | ret; | |
57 | })) | |
f127e61e MD |
58 | ctf_array_text(char, name, p->comm, TASK_COMM_LEN) |
59 | ctf_integer(int, type, type) | |
60 | ctf_integer(int, mode, mode) | |
61 | ctf_integer(int, submode, submode) | |
62 | ctf_integer(int, status, status) | |
7a479375 | 63 | ctf_integer(unsigned int, cpu, task_cpu(p)) |
e7a0ca72 | 64 | ctf_integer_hex(struct files_struct *, file_table_address, files) |
f127e61e | 65 | ) |
c337ddc2 MD |
66 | ) |
67 | ||
1965e6b4 MJ |
68 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) |
69 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_cgroup_ns, | |
70 | TP_PROTO(struct lttng_session *session, | |
71 | struct task_struct *p, | |
72 | struct cgroup_namespace *cgroup_ns), | |
73 | TP_ARGS(session, p, cgroup_ns), | |
74 | TP_FIELDS( | |
75 | ctf_integer(pid_t, tid, p->pid) | |
76 | ctf_integer(unsigned int, ns_inum, cgroup_ns ? cgroup_ns->lttng_ns_inum : 0) | |
77 | ) | |
78 | ) | |
79 | #endif | |
80 | ||
81 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_ipc_ns, | |
82 | TP_PROTO(struct lttng_session *session, | |
83 | struct task_struct *p, | |
84 | struct ipc_namespace *ipc_ns), | |
85 | TP_ARGS(session, p, ipc_ns), | |
86 | TP_FIELDS( | |
87 | ctf_integer(pid_t, tid, p->pid) | |
88 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
89 | ctf_integer(unsigned int, ns_inum, ipc_ns ? ipc_ns->lttng_ns_inum : 0) | |
90 | #endif | |
91 | ) | |
92 | ) | |
93 | ||
94 | #if !defined(LTTNG_MNT_NS_MISSING_HEADER) | |
95 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_mnt_ns, | |
96 | TP_PROTO(struct lttng_session *session, | |
97 | struct task_struct *p, | |
98 | struct mnt_namespace *mnt_ns), | |
99 | TP_ARGS(session, p, mnt_ns), | |
100 | TP_FIELDS( | |
101 | ctf_integer(pid_t, tid, p->pid) | |
102 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
103 | ctf_integer(unsigned int, ns_inum, mnt_ns ? mnt_ns->lttng_ns_inum : 0) | |
104 | #endif | |
105 | ) | |
106 | ) | |
107 | #endif | |
108 | ||
109 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_net_ns, | |
110 | TP_PROTO(struct lttng_session *session, | |
111 | struct task_struct *p, | |
112 | struct net *net_ns), | |
113 | TP_ARGS(session, p, net_ns), | |
114 | TP_FIELDS( | |
115 | ctf_integer(pid_t, tid, p->pid) | |
116 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
117 | ctf_integer(unsigned int, ns_inum, net_ns ? net_ns->lttng_ns_inum : 0) | |
118 | #endif | |
119 | ) | |
120 | ) | |
121 | ||
122 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_pid_ns, | |
123 | TP_PROTO(struct lttng_session *session, | |
124 | struct task_struct *p, | |
125 | struct pid_namespace *pid_ns), | |
126 | TP_ARGS(session, p, pid_ns), | |
127 | TP_FIELDS( | |
128 | ctf_integer(pid_t, tid, p->pid) | |
129 | ctf_integer(pid_t, vtid, pid_ns ? task_pid_nr_ns(p, pid_ns) : 0) | |
130 | ctf_integer(pid_t, vpid, pid_ns ? task_tgid_nr_ns(p, pid_ns) : 0) | |
131 | ctf_integer(pid_t, vppid, | |
132 | ({ | |
133 | struct task_struct *parent; | |
134 | pid_t ret = 0; | |
135 | ||
136 | if (pid_ns) { | |
137 | rcu_read_lock(); | |
138 | parent = rcu_dereference(p->real_parent); | |
139 | ret = task_tgid_nr_ns(parent, pid_ns); | |
140 | rcu_read_unlock(); | |
141 | } | |
142 | ret; | |
143 | })) | |
144 | ctf_integer(int, ns_level, pid_ns ? pid_ns->level : 0) | |
145 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
146 | ctf_integer(unsigned int, ns_inum, pid_ns ? pid_ns->lttng_ns_inum : 0) | |
147 | #endif | |
148 | ) | |
149 | ) | |
150 | ||
151 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_user_ns, | |
152 | TP_PROTO(struct lttng_session *session, | |
153 | struct task_struct *p, | |
154 | struct user_namespace *user_ns), | |
155 | TP_ARGS(session, p, user_ns), | |
156 | TP_FIELDS( | |
157 | ctf_integer(pid_t, tid, p->pid) | |
158 | ctf_integer(uid_t, vuid, user_ns ? lttng_task_vuid(p, user_ns) : 0) | |
159 | ctf_integer(gid_t, vgid, user_ns ? lttng_task_vgid(p, user_ns) : 0) | |
160 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) | |
161 | ctf_integer(int, ns_level, user_ns ? user_ns->level : 0) | |
162 | #endif | |
163 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
164 | ctf_integer(unsigned int, ns_inum, user_ns ? user_ns->lttng_ns_inum : 0) | |
165 | #endif | |
166 | ) | |
167 | ) | |
168 | ||
169 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_uts_ns, | |
170 | TP_PROTO(struct lttng_session *session, | |
171 | struct task_struct *p, | |
172 | struct uts_namespace *uts_ns), | |
173 | TP_ARGS(session, p, uts_ns), | |
174 | TP_FIELDS( | |
175 | ctf_integer(pid_t, tid, p->pid) | |
176 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
177 | ctf_integer(unsigned int, ns_inum, uts_ns ? uts_ns->lttng_ns_inum : 0) | |
178 | #endif | |
179 | ) | |
180 | ) | |
181 | ||
3bc29f0a | 182 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_file_descriptor, |
c337ddc2 | 183 | TP_PROTO(struct lttng_session *session, |
e7a0ca72 MD |
184 | struct files_struct *files, |
185 | int fd, const char *filename, | |
29021503 | 186 | unsigned int flags, fmode_t fmode), |
e7a0ca72 | 187 | TP_ARGS(session, files, fd, filename, flags, fmode), |
f127e61e | 188 | TP_FIELDS( |
e7a0ca72 | 189 | ctf_integer_hex(struct files_struct *, file_table_address, files) |
f127e61e MD |
190 | ctf_integer(int, fd, fd) |
191 | ctf_integer_oct(unsigned int, flags, flags) | |
192 | ctf_integer_hex(fmode_t, fmode, fmode) | |
193 | ctf_string(filename, filename) | |
194 | ) | |
c337ddc2 MD |
195 | ) |
196 | ||
3bc29f0a | 197 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_vm_map, |
c337ddc2 MD |
198 | TP_PROTO(struct lttng_session *session, |
199 | struct task_struct *p, struct vm_area_struct *map, | |
200 | unsigned long inode), | |
201 | TP_ARGS(session, p, map, inode), | |
f127e61e MD |
202 | TP_FIELDS( |
203 | ctf_integer(pid_t, pid, p->tgid) | |
204 | ctf_integer_hex(unsigned long, start, map->vm_start) | |
205 | ctf_integer_hex(unsigned long, end, map->vm_end) | |
206 | ctf_integer_hex(unsigned long, flags, map->vm_flags) | |
207 | ctf_integer(unsigned long, inode, inode) | |
208 | ctf_integer(unsigned long, pgoff, map->vm_pgoff << PAGE_SHIFT) | |
209 | ) | |
c337ddc2 MD |
210 | ) |
211 | ||
3bc29f0a | 212 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_network_interface, |
c337ddc2 MD |
213 | TP_PROTO(struct lttng_session *session, |
214 | struct net_device *dev, struct in_ifaddr *ifa), | |
215 | TP_ARGS(session, dev, ifa), | |
f127e61e MD |
216 | TP_FIELDS( |
217 | ctf_string(name, dev->name) | |
218 | ctf_integer_network_hex(uint32_t, address_ipv4, | |
219 | ifa ? ifa->ifa_address : 0U) | |
220 | ) | |
c337ddc2 MD |
221 | ) |
222 | ||
3bc29f0a | 223 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_block_device, |
f0dbdefb HD |
224 | TP_PROTO(struct lttng_session *session, |
225 | dev_t dev, const char *diskname), | |
226 | TP_ARGS(session, dev, diskname), | |
f127e61e MD |
227 | TP_FIELDS( |
228 | ctf_integer(dev_t, dev, dev) | |
229 | ctf_string(diskname, diskname) | |
230 | ) | |
f0dbdefb HD |
231 | ) |
232 | ||
c337ddc2 | 233 | /* Called with desc->lock held */ |
3bc29f0a | 234 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_interrupt, |
c337ddc2 MD |
235 | TP_PROTO(struct lttng_session *session, |
236 | unsigned int irq, const char *chip_name, | |
237 | struct irqaction *action), | |
238 | TP_ARGS(session, irq, chip_name, action), | |
f127e61e MD |
239 | TP_FIELDS( |
240 | ctf_integer(unsigned int, irq, irq) | |
241 | ctf_string(name, chip_name) | |
242 | ctf_string(action, action->name ? : "") | |
afded8f5 | 243 | ctf_integer(pid_t, tid, action->thread ? action->thread->pid : 0) |
f127e61e | 244 | ) |
c337ddc2 MD |
245 | ) |
246 | ||
502e4132 | 247 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) |
d0b55e4c MD |
248 | |
249 | #define LTTNG_HAVE_STATEDUMP_CPU_TOPOLOGY | |
250 | ||
502e4132 JD |
251 | LTTNG_TRACEPOINT_EVENT(lttng_statedump_cpu_topology, |
252 | TP_PROTO(struct lttng_session *session, struct cpuinfo_x86 *c), | |
253 | TP_ARGS(session, c), | |
254 | TP_FIELDS( | |
255 | ctf_string(architecture, "x86") | |
256 | ctf_integer(uint16_t, cpu_id, c->cpu_index) | |
257 | ctf_string(vendor, c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown") | |
258 | ctf_integer(uint8_t, family, c->x86) | |
259 | ctf_integer(uint8_t, model, c->x86_model) | |
260 | ctf_string(model_name, c->x86_model_id[0] ? c->x86_model_id : "unknown") | |
261 | ctf_integer(uint16_t, physical_id, c->phys_proc_id) | |
262 | ctf_integer(uint16_t, core_id, c->cpu_core_id) | |
263 | ctf_integer(uint16_t, cores, c->booted_cores) | |
264 | ) | |
265 | ) | |
266 | #endif /* CONFIG_X86_32 || CONFIG_X86_64 */ | |
267 | ||
3bc29f0a | 268 | #endif /* LTTNG_TRACE_LTTNG_STATEDUMP_H */ |
c337ddc2 MD |
269 | |
270 | /* This part must be outside protection */ | |
6ec43db8 | 271 | #include <probes/define_trace.h> |