Refactoring: kprobes: combine common code between recorder and notifier
[lttng-modules.git] / src / probes / lttng-kretprobes.c
index 7d0db416908f6ba95ff21600d115374a6f9dc477..1d0a5ecbe6563c0a17df4b0f50794ad0cc921571 100644 (file)
@@ -14,6 +14,7 @@
 #include <lttng/events.h>
 #include <lttng/events-internal.h>
 #include <ringbuffer/frontend_types.h>
+#include <wrapper/compiler_attributes.h>
 #include <wrapper/vmalloc.h>
 #include <wrapper/irqflags.h>
 #include <lttng/tracer.h>
@@ -53,15 +54,16 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
        {
                struct lttng_kernel_event_recorder *event_recorder =
                        container_of(event, struct lttng_kernel_event_recorder, parent);
-               struct lttng_channel *chan = event_recorder->chan;
+               struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
 
-               if (unlikely(!LTTNG_READ_ONCE(chan->session->active)))
+               if (unlikely(!LTTNG_READ_ONCE(chan->parent.session->active)))
                        return 0;
-               if (unlikely(!LTTNG_READ_ONCE(chan->enabled)))
+               if (unlikely(!LTTNG_READ_ONCE(chan->parent.enabled)))
                        return 0;
                break;
        }
-       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:  /* Fall-through. */
+       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+               lttng_fallthrough;
        default:
                WARN_ON_ONCE(1);
        }
@@ -74,7 +76,7 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
        {
                struct lttng_kernel_event_recorder *event_recorder =
                        container_of(event, struct lttng_kernel_event_recorder, parent);
-               struct lttng_channel *chan = event_recorder->chan;
+               struct lttng_kernel_channel_buffer *chan = event_recorder->chan;
                struct lttng_kernel_ring_buffer_ctx ctx;
                int ret;
 
@@ -86,12 +88,12 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
                ret = chan->ops->event_reserve(&ctx);
                if (ret < 0)
                        return 0;
-               lib_ring_buffer_align_ctx(&ctx, lttng_alignof(payload));
-               chan->ops->event_write(&ctx, &payload, sizeof(payload));
+               chan->ops->event_write(&ctx, &payload, sizeof(payload), lttng_alignof(payload));
                chan->ops->event_commit(&ctx);
                break;
        }
-       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:  /* Fall-through. */
+       case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
+               lttng_fallthrough;
        default:
                WARN_ON_ONCE(1);
        }
This page took 0.02375 seconds and 4 git commands to generate.