CPU topology statedump on x86
[lttng-modules.git] / instrumentation / events / lttng-module / lttng-statedump.h
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/pid_namespace.h>
11 #include <linux/types.h>
12 #include <linux/version.h>
13
14
15 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
16 #define lttng_proc_inum ns.inum
17 #else
18 #define lttng_proc_inum proc_inum
19 #endif
20
21 LTTNG_TRACEPOINT_EVENT(lttng_statedump_start,
22 TP_PROTO(struct lttng_session *session),
23 TP_ARGS(session),
24 TP_FIELDS()
25 )
26
27 LTTNG_TRACEPOINT_EVENT(lttng_statedump_end,
28 TP_PROTO(struct lttng_session *session),
29 TP_ARGS(session),
30 TP_FIELDS()
31 )
32
33 LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state,
34 TP_PROTO(struct lttng_session *session,
35 struct task_struct *p,
36 int type, int mode, int submode, int status,
37 struct pid_namespace *pid_ns),
38 TP_ARGS(session, p, type, mode, submode, status, pid_ns),
39 TP_FIELDS(
40 ctf_integer(pid_t, tid, p->pid)
41 ctf_integer(pid_t, vtid, pid_ns ? task_pid_nr_ns(p, pid_ns) : 0)
42 ctf_integer(pid_t, pid, p->tgid)
43 ctf_integer(pid_t, vpid, pid_ns ? task_tgid_nr_ns(p, pid_ns) : 0)
44 ctf_integer(pid_t, ppid,
45 ({
46 pid_t ret;
47
48 rcu_read_lock();
49 ret = task_tgid_nr(p->real_parent);
50 rcu_read_unlock();
51 ret;
52 }))
53 ctf_integer(pid_t, vppid,
54 ({
55 struct task_struct *parent;
56 pid_t ret = 0;
57
58 if (pid_ns) {
59 rcu_read_lock();
60 parent = rcu_dereference(p->real_parent);
61 ret = task_tgid_nr_ns(parent, pid_ns);
62 rcu_read_unlock();
63 }
64 ret;
65 }))
66 ctf_array_text(char, name, p->comm, TASK_COMM_LEN)
67 ctf_integer(int, type, type)
68 ctf_integer(int, mode, mode)
69 ctf_integer(int, submode, submode)
70 ctf_integer(int, status, status)
71 ctf_integer(int, ns_level, pid_ns ? pid_ns->level : 0)
72 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
73 ctf_integer(unsigned int, ns_inum, pid_ns ? pid_ns->lttng_proc_inum : 0)
74 #endif
75 ctf_integer(unsigned int, cpu, task_cpu(p))
76 )
77 )
78
79 LTTNG_TRACEPOINT_EVENT(lttng_statedump_file_descriptor,
80 TP_PROTO(struct lttng_session *session,
81 struct task_struct *p, int fd, const char *filename,
82 unsigned int flags, fmode_t fmode),
83 TP_ARGS(session, p, fd, filename, flags, fmode),
84 TP_FIELDS(
85 ctf_integer(pid_t, pid, p->tgid)
86 ctf_integer(int, fd, fd)
87 ctf_integer_oct(unsigned int, flags, flags)
88 ctf_integer_hex(fmode_t, fmode, fmode)
89 ctf_string(filename, filename)
90 )
91 )
92
93 LTTNG_TRACEPOINT_EVENT(lttng_statedump_vm_map,
94 TP_PROTO(struct lttng_session *session,
95 struct task_struct *p, struct vm_area_struct *map,
96 unsigned long inode),
97 TP_ARGS(session, p, map, inode),
98 TP_FIELDS(
99 ctf_integer(pid_t, pid, p->tgid)
100 ctf_integer_hex(unsigned long, start, map->vm_start)
101 ctf_integer_hex(unsigned long, end, map->vm_end)
102 ctf_integer_hex(unsigned long, flags, map->vm_flags)
103 ctf_integer(unsigned long, inode, inode)
104 ctf_integer(unsigned long, pgoff, map->vm_pgoff << PAGE_SHIFT)
105 )
106 )
107
108 LTTNG_TRACEPOINT_EVENT(lttng_statedump_network_interface,
109 TP_PROTO(struct lttng_session *session,
110 struct net_device *dev, struct in_ifaddr *ifa),
111 TP_ARGS(session, dev, ifa),
112 TP_FIELDS(
113 ctf_string(name, dev->name)
114 ctf_integer_network_hex(uint32_t, address_ipv4,
115 ifa ? ifa->ifa_address : 0U)
116 )
117 )
118
119 LTTNG_TRACEPOINT_EVENT(lttng_statedump_block_device,
120 TP_PROTO(struct lttng_session *session,
121 dev_t dev, const char *diskname),
122 TP_ARGS(session, dev, diskname),
123 TP_FIELDS(
124 ctf_integer(dev_t, dev, dev)
125 ctf_string(diskname, diskname)
126 )
127 )
128
129 /* Called with desc->lock held */
130 LTTNG_TRACEPOINT_EVENT(lttng_statedump_interrupt,
131 TP_PROTO(struct lttng_session *session,
132 unsigned int irq, const char *chip_name,
133 struct irqaction *action),
134 TP_ARGS(session, irq, chip_name, action),
135 TP_FIELDS(
136 ctf_integer(unsigned int, irq, irq)
137 ctf_string(name, chip_name)
138 ctf_string(action, action->name ? : "")
139 )
140 )
141
142 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
143 LTTNG_TRACEPOINT_EVENT(lttng_statedump_cpu_topology,
144 TP_PROTO(struct lttng_session *session, struct cpuinfo_x86 *c),
145 TP_ARGS(session, c),
146 TP_FIELDS(
147 ctf_string(architecture, "x86")
148 ctf_integer(uint16_t, cpu_id, c->cpu_index)
149 ctf_string(vendor, c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown")
150 ctf_integer(uint8_t, family, c->x86)
151 ctf_integer(uint8_t, model, c->x86_model)
152 ctf_string(model_name, c->x86_model_id[0] ? c->x86_model_id : "unknown")
153 ctf_integer(uint16_t, physical_id, c->phys_proc_id)
154 ctf_integer(uint16_t, core_id, c->cpu_core_id)
155 ctf_integer(uint16_t, cores, c->booted_cores)
156 )
157 )
158 #endif /* CONFIG_X86_32 || CONFIG_X86_64 */
159
160 #endif /* LTTNG_TRACE_LTTNG_STATEDUMP_H */
161
162 /* This part must be outside protection */
163 #include <probes/define_trace.h>
This page took 0.036681 seconds and 5 git commands to generate.