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