From: Michael Jeanson Date: Thu, 7 Jan 2021 19:50:50 +0000 (-0500) Subject: fix: kprobes: Remove kretprobe hash (v5.11) X-Git-Tag: v2.13.0-rc1~59 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=087269072e2d96540d137789a6c91687edeb33bd;p=lttng-modules.git fix: kprobes: Remove kretprobe hash (v5.11) See upstream commit: commit d741bf41d7c7db4898bacfcb020353cddc032fd8 Author: Peter Zijlstra 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 Signed-off-by: Mathieu Desnoyers Change-Id: I855765f390ad7caf481ef5fea334645e852f5b0f --- diff --git a/include/wrapper/kprobes.h b/include/wrapper/kprobes.h new file mode 100644 index 00000000..4d6993e2 --- /dev/null +++ b/include/wrapper/kprobes.h @@ -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 + */ + +#ifndef _LTTNG_WRAPPER_KPROBES_H +#define _LTTNG_WRAPPER_KPROBES_H + +#include +#include + +#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 */ diff --git a/src/probes/lttng-kretprobes.c b/src/probes/lttng-kretprobes.c index 8cde4edd..24cb52e4 100644 --- a/src/probes/lttng-kretprobes.c +++ b/src/probes/lttng-kretprobes.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include @@ -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, <tng_probe_ctx, sizeof(payload),