X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=probes%2Flttng-kretprobes.c;h=49b7de82d86e32ed0a9afd81d971159f43d80aa4;hb=a8f2d0c75c9cc179fc9e7f7ca17ea3b3b3b5af41;hp=d71090a2bc321edcac3695c774508c1d0d025655;hpb=13ab8b0a749053960f81a4924a3ed27775518f94;p=lttng-modules.git diff --git a/probes/lttng-kretprobes.c b/probes/lttng-kretprobes.c index d71090a2..49b7de82 100644 --- a/probes/lttng-kretprobes.c +++ b/probes/lttng-kretprobes.c @@ -1,5 +1,5 @@ /* - * probes/lttng-kretprobes.c +* probes/lttng-kretprobes.c * * LTTng kretprobes integration module. * @@ -24,10 +24,11 @@ #include #include #include -#include "../lttng-events.h" -#include "../wrapper/ringbuffer/frontend_types.h" -#include "../wrapper/vmalloc.h" -#include "../lttng-tracer.h" +#include +#include +#include +#include +#include enum lttng_kretprobe_type { EVENT_ENTRY = 0, @@ -50,6 +51,10 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi, container_of(krpi->rp, struct lttng_krp, krp); struct lttng_event *event = lttng_krp->event[type]; + struct lttng_probe_ctx lttng_probe_ctx = { + .event = event, + .interruptible = !lttng_regs_irqs_disabled(regs), + }; struct lttng_channel *chan = event->chan; struct lib_ring_buffer_ctx ctx; int ret; @@ -58,17 +63,17 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi, unsigned long parent_ip; } payload; - if (unlikely(!ACCESS_ONCE(chan->session->active))) + if (unlikely(!READ_ONCE(chan->session->active))) return 0; - if (unlikely(!ACCESS_ONCE(chan->enabled))) + if (unlikely(!READ_ONCE(chan->enabled))) return 0; - if (unlikely(!ACCESS_ONCE(event->enabled))) + if (unlikely(!READ_ONCE(event->enabled))) return 0; payload.ip = (unsigned long) krpi->rp->kp.addr; payload.parent_ip = (unsigned long) krpi->ret_addr; - lib_ring_buffer_ctx_init(&ctx, chan->chan, event, sizeof(payload), + lib_ring_buffer_ctx_init(&ctx, chan->chan, <tng_probe_ctx, sizeof(payload), lttng_alignof(payload), -1); ret = chan->ops->event_reserve(&ctx, event->id); if (ret < 0) @@ -219,9 +224,9 @@ int lttng_kretprobes_register(const char *name, * unregistered. Same for memory allocation. */ kref_init(<tng_krp->kref_alloc); - kref_get(<tng_krp->kref_alloc); /* inc refcount to 2 */ + kref_get(<tng_krp->kref_alloc); /* inc refcount to 2, no overflow. */ kref_init(<tng_krp->kref_register); - kref_get(<tng_krp->kref_register); /* inc refcount to 2 */ + kref_get(<tng_krp->kref_register); /* inc refcount to 2, no overflow. */ /* * Ensure the memory we just allocated don't trigger page faults. @@ -285,6 +290,26 @@ void lttng_kretprobes_destroy_private(struct lttng_event *event) } EXPORT_SYMBOL_GPL(lttng_kretprobes_destroy_private); +int lttng_kretprobes_event_enable_state(struct lttng_event *event, + int enable) +{ + struct lttng_event *event_return; + struct lttng_krp *lttng_krp; + + if (event->instrumentation != LTTNG_KERNEL_KRETPROBE) { + return -EINVAL; + } + if (event->enabled == enable) { + return -EBUSY; + } + lttng_krp = event->u.kretprobe.lttng_krp; + event_return = lttng_krp->event[EVENT_RETURN]; + WRITE_ONCE(event->enabled, enable); + WRITE_ONCE(event_return->enabled, enable); + return 0; +} +EXPORT_SYMBOL_GPL(lttng_kretprobes_event_enable_state); + MODULE_LICENSE("GPL and additional rights"); MODULE_AUTHOR("Mathieu Desnoyers"); MODULE_DESCRIPTION("Linux Trace Toolkit Kretprobes Support");