blob: 5892a408b33817a77ab98c474c4d82fb4bbba81d [file] [log] [blame]
Andrew Geisslerc723b722021-01-08 16:14:09 -06001From bb346792c2cb6995ffc08d2084121935c6384865 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Mon, 26 Oct 2020 17:09:05 -0400
4Subject: [PATCH 14/19] fix: tracepoint: Optimize using static_call() (v5.10)
5
6See upstream commit :
7
8 commit d25e37d89dd2f41d7acae0429039d2f0ae8b4a07
9 Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
10 Date: Tue Aug 18 15:57:52 2020 +0200
11
12 tracepoint: Optimize using static_call()
13
14 Currently the tracepoint site will iterate a vector and issue indirect
15 calls to however many handlers are registered (ie. the vector is
16 long).
17
18 Using static_call() it is possible to optimize this for the common
19 case of only having a single handler registered. In this case the
20 static_call() can directly call this handler. Otherwise, if the vector
21 is longer than 1, call a function that iterates the whole vector like
22 the current code.
23
24Upstream-Status: Backport
25
26Change-Id: I739dd84d62cc1a821b8bd8acff74fa29aa25d22f
27Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
28Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
29---
30 lttng-statedump-impl.c | 80 +++++++++++++++++++++++++++++++--------
31 probes/lttng.c | 7 +++-
32 tests/probes/lttng-test.c | 7 +++-
33 wrapper/tracepoint.h | 8 ++++
34 4 files changed, 84 insertions(+), 18 deletions(-)
35
36diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c
37index a6fa71a5..67ecd33c 100644
38--- a/lttng-statedump-impl.c
39+++ b/lttng-statedump-impl.c
40@@ -55,26 +55,76 @@
41 #define LTTNG_INSTRUMENTATION
42 #include <instrumentation/events/lttng-module/lttng-statedump.h>
43
44-DEFINE_TRACE(lttng_statedump_block_device);
45-DEFINE_TRACE(lttng_statedump_end);
46-DEFINE_TRACE(lttng_statedump_interrupt);
47-DEFINE_TRACE(lttng_statedump_file_descriptor);
48-DEFINE_TRACE(lttng_statedump_start);
49-DEFINE_TRACE(lttng_statedump_process_state);
50-DEFINE_TRACE(lttng_statedump_process_pid_ns);
51+LTTNG_DEFINE_TRACE(lttng_statedump_block_device,
52+ TP_PROTO(struct lttng_session *session,
53+ dev_t dev, const char *diskname),
54+ TP_ARGS(session, dev, diskname));
55+
56+LTTNG_DEFINE_TRACE(lttng_statedump_end,
57+ TP_PROTO(struct lttng_session *session),
58+ TP_ARGS(session));
59+
60+LTTNG_DEFINE_TRACE(lttng_statedump_interrupt,
61+ TP_PROTO(struct lttng_session *session,
62+ unsigned int irq, const char *chip_name,
63+ struct irqaction *action),
64+ TP_ARGS(session, irq, chip_name, action));
65+
66+LTTNG_DEFINE_TRACE(lttng_statedump_file_descriptor,
67+ TP_PROTO(struct lttng_session *session,
68+ struct files_struct *files,
69+ int fd, const char *filename,
70+ unsigned int flags, fmode_t fmode),
71+ TP_ARGS(session, files, fd, filename, flags, fmode));
72+
73+LTTNG_DEFINE_TRACE(lttng_statedump_start,
74+ TP_PROTO(struct lttng_session *session),
75+ TP_ARGS(session));
76+
77+LTTNG_DEFINE_TRACE(lttng_statedump_process_state,
78+ TP_PROTO(struct lttng_session *session,
79+ struct task_struct *p,
80+ int type, int mode, int submode, int status,
81+ struct files_struct *files),
82+ TP_ARGS(session, p, type, mode, submode, status, files));
83+
84+LTTNG_DEFINE_TRACE(lttng_statedump_process_pid_ns,
85+ TP_PROTO(struct lttng_session *session,
86+ struct task_struct *p,
87+ struct pid_namespace *pid_ns),
88+ TP_ARGS(session, p, pid_ns));
89+
90 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
91-DEFINE_TRACE(lttng_statedump_process_cgroup_ns);
92+LTTNG_DEFINE_TRACE(lttng_statedump_process_cgroup_ns,
93+ TP_PROTO(struct lttng_session *session,
94+ struct task_struct *p,
95+ struct cgroup_namespace *cgroup_ns),
96+ TP_ARGS(session, p, cgroup_ns));
97 #endif
98-DEFINE_TRACE(lttng_statedump_process_ipc_ns);
99+
100+LTTNG_DEFINE_TRACE(lttng_statedump_process_ipc_ns,
101+ TP_PROTO(struct lttng_session *session,
102+ struct task_struct *p,
103+ struct ipc_namespace *ipc_ns),
104+ TP_ARGS(session, p, ipc_ns));
105+
106 #ifndef LTTNG_MNT_NS_MISSING_HEADER
107-DEFINE_TRACE(lttng_statedump_process_mnt_ns);
108+LTTNG_DEFINE_TRACE(lttng_statedump_process_mnt_ns,
109+ TP_PROTO(struct lttng_session *session,
110+ struct task_struct *p,
111+ struct mnt_namespace *mnt_ns),
112+ TP_ARGS(session, p, mnt_ns));
113 #endif
114-DEFINE_TRACE(lttng_statedump_process_net_ns);
115-DEFINE_TRACE(lttng_statedump_process_user_ns);
116-DEFINE_TRACE(lttng_statedump_process_uts_ns);
117-DEFINE_TRACE(lttng_statedump_network_interface);
118+
119+LTTNG_DEFINE_TRACE(lttng_statedump_network_interface,
120+ TP_PROTO(struct lttng_session *session,
121+ struct net_device *dev, struct in_ifaddr *ifa),
122+ TP_ARGS(session, dev, ifa));
123+
124 #ifdef LTTNG_HAVE_STATEDUMP_CPU_TOPOLOGY
125-DEFINE_TRACE(lttng_statedump_cpu_topology);
126+LTTNG_DEFINE_TRACE(lttng_statedump_cpu_topology,
127+ TP_PROTO(struct lttng_session *session, struct cpuinfo_x86 *c),
128+ TP_ARGS(session, c));
129 #endif
130
131 struct lttng_fd_ctx {
132diff --git a/probes/lttng.c b/probes/lttng.c
133index 05bc1388..7ddaa69f 100644
134--- a/probes/lttng.c
135+++ b/probes/lttng.c
136@@ -8,7 +8,7 @@
137 */
138
139 #include <linux/module.h>
140-#include <linux/tracepoint.h>
141+#include <wrapper/tracepoint.h>
142 #include <linux/uaccess.h>
143 #include <linux/gfp.h>
144 #include <linux/fs.h>
145@@ -32,7 +32,10 @@
146 #define LTTNG_LOGGER_COUNT_MAX 1024
147 #define LTTNG_LOGGER_FILE "lttng-logger"
148
149-DEFINE_TRACE(lttng_logger);
150+LTTNG_DEFINE_TRACE(lttng_logger,
151+ PARAMS(const char __user *text, size_t len),
152+ PARAMS(text, len)
153+);
154
155 static struct proc_dir_entry *lttng_logger_dentry;
156
157diff --git a/tests/probes/lttng-test.c b/tests/probes/lttng-test.c
158index b450e7d7..a4fa0645 100644
159--- a/tests/probes/lttng-test.c
160+++ b/tests/probes/lttng-test.c
161@@ -25,7 +25,12 @@
162 #define LTTNG_INSTRUMENTATION
163 #include <instrumentation/events/lttng-module/lttng-test.h>
164
165-DEFINE_TRACE(lttng_test_filter_event);
166+LTTNG_DEFINE_TRACE(lttng_test_filter_event,
167+ PARAMS(int anint, int netint, long *values,
168+ char *text, size_t textlen,
169+ char *etext, uint32_t * net_values),
170+ PARAMS(anint, netint, values, text, textlen, etext, net_values)
171+);
172
173 #define LTTNG_TEST_FILTER_EVENT_FILE "lttng-test-filter-event"
174
175diff --git a/wrapper/tracepoint.h b/wrapper/tracepoint.h
176index c4ba0123..bc19d8c1 100644
177--- a/wrapper/tracepoint.h
178+++ b/wrapper/tracepoint.h
179@@ -14,6 +14,14 @@
180 #include <linux/tracepoint.h>
181 #include <linux/module.h>
182
183+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))
184+#define LTTNG_DEFINE_TRACE(name, proto, args) \
185+ DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
186+#else
187+#define LTTNG_DEFINE_TRACE(name, proto, args) \
188+ DEFINE_TRACE(name)
189+#endif
190+
191 #ifndef HAVE_KABI_2635_TRACEPOINT
192
193 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
194--
1952.19.1
196