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