fix: kprobes: Remove kretprobe hash (v5.11)
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 7 Jan 2021 19:50:50 +0000 (14:50 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 19 Jan 2021 14:28:59 +0000 (09:28 -0500)
See upstream commit:

  commit d741bf41d7c7db4898bacfcb020353cddc032fd8
  Author: Peter Zijlstra <peterz@infradead.org>
  Date:   Sat Aug 29 22:03:24 2020 +0900

    kprobes: Remove kretprobe hash

    The kretprobe hash is mostly superfluous, replace it with a per-task
    variable.

    This gets rid of the task hash and it's related locking.

    Note that this may change the kprobes module-exported API for kretprobe
    handlers. If any out-of-tree kretprobe user uses ri->rp, use
    get_kretprobe(ri) instead.

Link: https://lore.kernel.org/r/159870620431.1229682.16325792502413731312.stgit@devnote2
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I855765f390ad7caf481ef5fea334645e852f5b0f

include/wrapper/kprobes.h [new file with mode: 0644]
src/probes/lttng-kretprobes.c

diff --git a/include/wrapper/kprobes.h b/include/wrapper/kprobes.h
new file mode 100644 (file)
index 0000000..4d6993e
--- /dev/null
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * src/wrapper/kprobes.h
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#ifndef _LTTNG_WRAPPER_KPROBES_H
+#define _LTTNG_WRAPPER_KPROBES_H
+
+#include <linux/kprobes.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
+
+static inline
+struct kretprobe *lttng_get_kretprobe(struct kretprobe_instance *ri)
+{
+       return get_kretprobe(ri);
+}
+
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) */
+
+static inline
+struct kretprobe *lttng_get_kretprobe(struct kretprobe_instance *ri)
+{
+       return ri->rp;
+}
+
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) */
+
+#endif /* _LTTNG_WRAPPER_KPROBES_H */
index 8cde4edd16d13f43d2a7d2190a4907eaaaf50c35..24cb52e4af9c6885451cf7d6463a959d45a8207e 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <linux/module.h>
-#include <linux/kprobes.h>
+#include <wrapper/kprobes.h>
 #include <linux/slab.h>
 #include <linux/kref.h>
 #include <lttng/events.h>
@@ -36,7 +36,7 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
                              enum lttng_kretprobe_type type)
 {
        struct lttng_krp *lttng_krp =
-               container_of(krpi->rp, struct lttng_krp, krp);
+               container_of(lttng_get_kretprobe(krpi), struct lttng_krp, krp);
        struct lttng_event *event =
                lttng_krp->event[type];
        struct lttng_probe_ctx lttng_probe_ctx = {
@@ -58,7 +58,7 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
        if (unlikely(!LTTNG_READ_ONCE(event->enabled)))
                return 0;
 
-       payload.ip = (unsigned long) krpi->rp->kp.addr;
+       payload.ip = (unsigned long) lttng_get_kretprobe(krpi)->kp.addr;
        payload.parent_ip = (unsigned long) krpi->ret_addr;
 
        lib_ring_buffer_ctx_init(&ctx, chan->chan, &lttng_probe_ctx, sizeof(payload),
This page took 0.029302 seconds and 4 git commands to generate.