1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM lttng_statedump
5 #if !defined(LTTNG_TRACE_LTTNG_STATEDUMP_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define LTTNG_TRACE_LTTNG_STATEDUMP_H
8 #include <probes/lttng-tracepoint-event.h>
9 #include <linux/nsproxy.h>
10 #include <linux/cgroup.h>
11 #include <linux/ipc_namespace.h>
12 #include <net/net_namespace.h>
13 #include <linux/pid_namespace.h>
14 #include <linux/user_namespace.h>
15 #include <linux/utsname.h>
16 #include <linux/types.h>
17 #include <linux/version.h>
18 #include <wrapper/namespace.h>
19 #include <wrapper/user_namespace.h>
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>
28 LTTNG_TRACEPOINT_EVENT(lttng_statedump_start
,
29 TP_PROTO(struct lttng_session
*session
),
34 LTTNG_TRACEPOINT_EVENT(lttng_statedump_end
,
35 TP_PROTO(struct lttng_session
*session
),
40 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state
,
41 TP_PROTO(struct lttng_session
*session
,
42 struct task_struct
*p
,
43 int type
, int mode
, int submode
, int status
,
44 struct pid_namespace
*pid_ns
),
45 TP_ARGS(session
, p
, type
, mode
, submode
, status
, pid_ns
),
47 ctf_integer(pid_t
, tid
, p
->pid
)
48 ctf_integer(pid_t
, vtid
, pid_ns
? task_pid_nr_ns(p
, pid_ns
) : 0)
49 ctf_integer(pid_t
, pid
, p
->tgid
)
50 ctf_integer(pid_t
, vpid
, pid_ns
? task_tgid_nr_ns(p
, pid_ns
) : 0)
51 ctf_integer(pid_t
, ppid
,
56 ret
= task_tgid_nr(p
->real_parent
);
60 ctf_integer(pid_t
, vppid
,
62 struct task_struct
*parent
;
67 parent
= rcu_dereference(p
->real_parent
);
68 ret
= task_tgid_nr_ns(parent
, pid_ns
);
73 ctf_array_text(char, name
, p
->comm
, TASK_COMM_LEN
)
74 ctf_integer(int, type
, type
)
75 ctf_integer(int, mode
, mode
)
76 ctf_integer(int, submode
, submode
)
77 ctf_integer(int, status
, status
)
78 ctf_integer(int, ns_level
, pid_ns
? pid_ns
->level
: 0)
79 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
80 ctf_integer(unsigned int, ns_inum
, pid_ns
? pid_ns
->lttng_proc_inum
: 0)
82 ctf_integer(unsigned int, cpu
, task_cpu(p
))
86 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
87 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_cgroup_ns
,
88 TP_PROTO(struct lttng_session
*session
,
89 struct task_struct
*p
,
90 struct cgroup_namespace
*cgroup_ns
),
91 TP_ARGS(session
, p
, cgroup_ns
),
93 ctf_integer(pid_t
, tid
, p
->pid
)
94 ctf_integer(unsigned int, ns_inum
, cgroup_ns
? cgroup_ns
->lttng_ns_inum
: 0)
99 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_ipc_ns
,
100 TP_PROTO(struct lttng_session
*session
,
101 struct task_struct
*p
,
102 struct ipc_namespace
*ipc_ns
),
103 TP_ARGS(session
, p
, ipc_ns
),
105 ctf_integer(pid_t
, tid
, p
->pid
)
106 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
107 ctf_integer(unsigned int, ns_inum
, ipc_ns
? ipc_ns
->lttng_ns_inum
: 0)
112 #if !defined(LTTNG_MNT_NS_MISSING_HEADER)
113 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_mnt_ns
,
114 TP_PROTO(struct lttng_session
*session
,
115 struct task_struct
*p
,
116 struct mnt_namespace
*mnt_ns
),
117 TP_ARGS(session
, p
, mnt_ns
),
119 ctf_integer(pid_t
, tid
, p
->pid
)
120 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
121 ctf_integer(unsigned int, ns_inum
, mnt_ns
? mnt_ns
->lttng_ns_inum
: 0)
127 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_net_ns
,
128 TP_PROTO(struct lttng_session
*session
,
129 struct task_struct
*p
,
131 TP_ARGS(session
, p
, net_ns
),
133 ctf_integer(pid_t
, tid
, p
->pid
)
134 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
135 ctf_integer(unsigned int, ns_inum
, net_ns
? net_ns
->lttng_ns_inum
: 0)
140 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_pid_ns
,
141 TP_PROTO(struct lttng_session
*session
,
142 struct task_struct
*p
,
143 struct pid_namespace
*pid_ns
),
144 TP_ARGS(session
, p
, pid_ns
),
146 ctf_integer(pid_t
, tid
, p
->pid
)
147 ctf_integer(pid_t
, vtid
, pid_ns
? task_pid_nr_ns(p
, pid_ns
) : 0)
148 ctf_integer(pid_t
, vpid
, pid_ns
? task_tgid_nr_ns(p
, pid_ns
) : 0)
149 ctf_integer(pid_t
, vppid
,
151 struct task_struct
*parent
;
156 parent
= rcu_dereference(p
->real_parent
);
157 ret
= task_tgid_nr_ns(parent
, pid_ns
);
162 ctf_integer(int, ns_level
, pid_ns
? pid_ns
->level
: 0)
163 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
164 ctf_integer(unsigned int, ns_inum
, pid_ns
? pid_ns
->lttng_ns_inum
: 0)
169 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_user_ns
,
170 TP_PROTO(struct lttng_session
*session
,
171 struct task_struct
*p
,
172 struct user_namespace
*user_ns
),
173 TP_ARGS(session
, p
, user_ns
),
175 ctf_integer(pid_t
, tid
, p
->pid
)
176 ctf_integer(uid_t
, vuid
, user_ns
? lttng_task_vuid(p
, user_ns
) : 0)
177 ctf_integer(gid_t
, vgid
, user_ns
? lttng_task_vgid(p
, user_ns
) : 0)
178 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
179 ctf_integer(int, ns_level
, user_ns
? user_ns
->level
: 0)
181 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
182 ctf_integer(unsigned int, ns_inum
, user_ns
? user_ns
->lttng_ns_inum
: 0)
187 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_uts_ns
,
188 TP_PROTO(struct lttng_session
*session
,
189 struct task_struct
*p
,
190 struct uts_namespace
*uts_ns
),
191 TP_ARGS(session
, p
, uts_ns
),
193 ctf_integer(pid_t
, tid
, p
->pid
)
194 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
195 ctf_integer(unsigned int, ns_inum
, uts_ns
? uts_ns
->lttng_ns_inum
: 0)
200 LTTNG_TRACEPOINT_EVENT(lttng_statedump_file_descriptor
,
201 TP_PROTO(struct lttng_session
*session
,
202 struct task_struct
*p
, int fd
, const char *filename
,
203 unsigned int flags
, fmode_t fmode
),
204 TP_ARGS(session
, p
, fd
, filename
, flags
, fmode
),
206 ctf_integer(pid_t
, pid
, p
->tgid
)
207 ctf_integer(int, fd
, fd
)
208 ctf_integer_oct(unsigned int, flags
, flags
)
209 ctf_integer_hex(fmode_t
, fmode
, fmode
)
210 ctf_string(filename
, filename
)
214 LTTNG_TRACEPOINT_EVENT(lttng_statedump_vm_map
,
215 TP_PROTO(struct lttng_session
*session
,
216 struct task_struct
*p
, struct vm_area_struct
*map
,
217 unsigned long inode
),
218 TP_ARGS(session
, p
, map
, inode
),
220 ctf_integer(pid_t
, pid
, p
->tgid
)
221 ctf_integer_hex(unsigned long, start
, map
->vm_start
)
222 ctf_integer_hex(unsigned long, end
, map
->vm_end
)
223 ctf_integer_hex(unsigned long, flags
, map
->vm_flags
)
224 ctf_integer(unsigned long, inode
, inode
)
225 ctf_integer(unsigned long, pgoff
, map
->vm_pgoff
<< PAGE_SHIFT
)
229 LTTNG_TRACEPOINT_EVENT(lttng_statedump_network_interface
,
230 TP_PROTO(struct lttng_session
*session
,
231 struct net_device
*dev
, struct in_ifaddr
*ifa
),
232 TP_ARGS(session
, dev
, ifa
),
234 ctf_string(name
, dev
->name
)
235 ctf_integer_network_hex(uint32_t, address_ipv4
,
236 ifa
? ifa
->ifa_address
: 0U)
240 LTTNG_TRACEPOINT_EVENT(lttng_statedump_block_device
,
241 TP_PROTO(struct lttng_session
*session
,
242 dev_t dev
, const char *diskname
),
243 TP_ARGS(session
, dev
, diskname
),
245 ctf_integer(dev_t
, dev
, dev
)
246 ctf_string(diskname
, diskname
)
250 /* Called with desc->lock held */
251 LTTNG_TRACEPOINT_EVENT(lttng_statedump_interrupt
,
252 TP_PROTO(struct lttng_session
*session
,
253 unsigned int irq
, const char *chip_name
,
254 struct irqaction
*action
),
255 TP_ARGS(session
, irq
, chip_name
, action
),
257 ctf_integer(unsigned int, irq
, irq
)
258 ctf_string(name
, chip_name
)
259 ctf_string(action
, action
->name
? : "")
263 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
265 #define LTTNG_HAVE_STATEDUMP_CPU_TOPOLOGY
267 LTTNG_TRACEPOINT_EVENT(lttng_statedump_cpu_topology
,
268 TP_PROTO(struct lttng_session
*session
, struct cpuinfo_x86
*c
),
271 ctf_string(architecture
, "x86")
272 ctf_integer(uint16_t, cpu_id
, c
->cpu_index
)
273 ctf_string(vendor
, c
->x86_vendor_id
[0] ? c
->x86_vendor_id
: "unknown")
274 ctf_integer(uint8_t, family
, c
->x86
)
275 ctf_integer(uint8_t, model
, c
->x86_model
)
276 ctf_string(model_name
, c
->x86_model_id
[0] ? c
->x86_model_id
: "unknown")
277 ctf_integer(uint16_t, physical_id
, c
->phys_proc_id
)
278 ctf_integer(uint16_t, core_id
, c
->cpu_core_id
)
279 ctf_integer(uint16_t, cores
, c
->booted_cores
)
282 #endif /* CONFIG_X86_32 || CONFIG_X86_64 */
284 #endif /* LTTNG_TRACE_LTTNG_STATEDUMP_H */
286 /* This part must be outside protection */
287 #include <probes/define_trace.h>