fix: tracepoint: Optimize using static_call() (v5.10)
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 26 Oct 2020 21:09:05 +0000 (17:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 Nov 2020 20:39:31 +0000 (15:39 -0500)
See upstream commit :

  commit d25e37d89dd2f41d7acae0429039d2f0ae8b4a07
  Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
  Date:   Tue Aug 18 15:57:52 2020 +0200

    tracepoint: Optimize using static_call()

    Currently the tracepoint site will iterate a vector and issue indirect
    calls to however many handlers are registered (ie. the vector is
    long).

    Using static_call() it is possible to optimize this for the common
    case of only having a single handler registered. In this case the
    static_call() can directly call this handler. Otherwise, if the vector
    is longer than 1, call a function that iterates the whole vector like
    the current code.

Change-Id: I739dd84d62cc1a821b8bd8acff74fa29aa25d22f
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/wrapper/tracepoint.h
src/lttng-statedump-impl.c
src/probes/lttng.c
tests/probes/lttng-test.c

index 9f631abdbd30010e56523e95c5dff8b143c43b57..41fcfad670e48a5ed2d2b0e3c7603eb5d7743901 100644 (file)
 #include <linux/tracepoint.h>
 #include <linux/module.h>
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))
+#define LTTNG_DEFINE_TRACE(name, proto, args)          \
+       DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+#else
+#define LTTNG_DEFINE_TRACE(name, proto, args)          \
+       DEFINE_TRACE(name)
+#endif
+
 #ifndef HAVE_KABI_2635_TRACEPOINT
 
 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
index 153ddf8e9de83719b8471b97174ff72646e6f85c..42052fae08fadcc293aadf854d4cdac1207fc687 100644 (file)
 #define LTTNG_INSTRUMENTATION
 #include <instrumentation/events/lttng-statedump.h>
 
-DEFINE_TRACE(lttng_statedump_block_device);
-DEFINE_TRACE(lttng_statedump_end);
-DEFINE_TRACE(lttng_statedump_interrupt);
-DEFINE_TRACE(lttng_statedump_file_descriptor);
-DEFINE_TRACE(lttng_statedump_start);
-DEFINE_TRACE(lttng_statedump_process_state);
-DEFINE_TRACE(lttng_statedump_process_pid_ns);
+LTTNG_DEFINE_TRACE(lttng_statedump_block_device,
+       TP_PROTO(struct lttng_session *session,
+               dev_t dev, const char *diskname),
+       TP_ARGS(session, dev, diskname));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_end,
+       TP_PROTO(struct lttng_session *session),
+       TP_ARGS(session));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_interrupt,
+       TP_PROTO(struct lttng_session *session,
+               unsigned int irq, const char *chip_name,
+               struct irqaction *action),
+       TP_ARGS(session, irq, chip_name, action));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_file_descriptor,
+       TP_PROTO(struct lttng_session *session,
+               struct files_struct *files,
+               int fd, const char *filename,
+               unsigned int flags, fmode_t fmode),
+       TP_ARGS(session, files, fd, filename, flags, fmode));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_start,
+       TP_PROTO(struct lttng_session *session),
+       TP_ARGS(session));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_state,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               int type, int mode, int submode, int status,
+               struct files_struct *files),
+       TP_ARGS(session, p, type, mode, submode, status, files));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_pid_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct pid_namespace *pid_ns),
+       TP_ARGS(session, p, pid_ns));
+
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0))
-DEFINE_TRACE(lttng_statedump_process_cgroup_ns);
+LTTNG_DEFINE_TRACE(lttng_statedump_process_cgroup_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct cgroup_namespace *cgroup_ns),
+       TP_ARGS(session, p, cgroup_ns));
 #endif
-DEFINE_TRACE(lttng_statedump_process_ipc_ns);
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_ipc_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct ipc_namespace *ipc_ns),
+       TP_ARGS(session, p, ipc_ns));
+
 #ifndef LTTNG_MNT_NS_MISSING_HEADER
-DEFINE_TRACE(lttng_statedump_process_mnt_ns);
+LTTNG_DEFINE_TRACE(lttng_statedump_process_mnt_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct mnt_namespace *mnt_ns),
+       TP_ARGS(session, p, mnt_ns));
 #endif
-DEFINE_TRACE(lttng_statedump_process_net_ns);
-DEFINE_TRACE(lttng_statedump_process_user_ns);
-DEFINE_TRACE(lttng_statedump_process_uts_ns);
-DEFINE_TRACE(lttng_statedump_process_time_ns);
-DEFINE_TRACE(lttng_statedump_network_interface);
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_net_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct net *net_ns),
+       TP_ARGS(session, p, net_ns));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_user_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct user_namespace *user_ns),
+       TP_ARGS(session, p, user_ns));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_uts_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct uts_namespace *uts_ns),
+       TP_ARGS(session, p, uts_ns));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_process_time_ns,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               struct time_namespace *time_ns),
+       TP_ARGS(session, p, time_ns));
+
+LTTNG_DEFINE_TRACE(lttng_statedump_network_interface,
+       TP_PROTO(struct lttng_session *session,
+               struct net_device *dev, struct in_ifaddr *ifa),
+       TP_ARGS(session, dev, ifa));
+
 #ifdef LTTNG_HAVE_STATEDUMP_CPU_TOPOLOGY
-DEFINE_TRACE(lttng_statedump_cpu_topology);
+LTTNG_DEFINE_TRACE(lttng_statedump_cpu_topology,
+       TP_PROTO(struct lttng_session *session, struct cpuinfo_x86 *c),
+       TP_ARGS(session, c));
 #endif
 
 struct lttng_fd_ctx {
index ab233c1a4452184f410f86acd285f90f7692da0b..1892d5896d25780d763fded733f78bde086f072f 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <linux/module.h>
-#include <linux/tracepoint.h>
+#include <wrapper/tracepoint.h>
 #include <linux/uaccess.h>
 #include <linux/gfp.h>
 #include <linux/fs.h>
 #define LTTNG_LOGGER_COUNT_MAX 1024
 #define LTTNG_LOGGER_FILE      "lttng-logger"
 
-DEFINE_TRACE(lttng_logger);
+LTTNG_DEFINE_TRACE(lttng_logger,
+       PARAMS(const char __user *text, size_t len),
+       PARAMS(text, len)
+);
 
 static struct proc_dir_entry *lttng_logger_dentry;
 
index 5064a685dad971693e3ee3bd04edb77491cbe2d3..098ceae825a93d60947fdae53083e826cd06ac72 100644 (file)
 #define LTTNG_INSTRUMENTATION
 #include <instrumentation/events/lttng-test.h>
 
-DEFINE_TRACE(lttng_test_filter_event);
+LTTNG_DEFINE_TRACE(lttng_test_filter_event,
+       PARAMS(int anint, int netint, long *values,
+               char *text, size_t textlen,
+               char *etext, uint32_t * net_values),
+       PARAMS(anint, netint, values, text, textlen, etext, net_values)
+);
 
 #define LTTNG_TEST_FILTER_EVENT_FILE   "lttng-test-filter-event"
 
This page took 0.030276 seconds and 4 git commands to generate.