Implement event notifiers for kprobes
[lttng-modules.git] / include / lttng / events.h
index e32480a98791286c5ad7f46d59f0b646746e8941..cf04a30585dc3f0839e1dd9937f672f9477c5893 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef _LTTNG_EVENTS_H
 #define _LTTNG_EVENTS_H
 
+#include <linux/irq_work.h>
 #include <linux/version.h>
 #include <linux/list.h>
 #include <linux/kprobes.h>
@@ -169,6 +170,7 @@ struct lttng_perf_counter_field {
 
 struct lttng_probe_ctx {
        struct lttng_event *event;
+       struct lttng_event_notifier *event_notifier; // Not sure if we will ever need it.
        uint8_t interruptible;
 };
 
@@ -211,6 +213,7 @@ struct lttng_event_desc {
        const struct lttng_event_field *fields; /* event payload */
        unsigned int nr_fields;
        struct module *owner;
+       void *event_notifier_callback;
 };
 
 struct lttng_probe_desc {
@@ -273,6 +276,11 @@ struct lttng_uprobe_handler {
        struct list_head node;
 };
 
+struct lttng_kprobe {
+       struct kprobe kp;
+       char *symbol_name;
+};
+
 enum lttng_syscall_entryexit {
        LTTNG_SYSCALL_ENTRY,
        LTTNG_SYSCALL_EXIT,
@@ -297,10 +305,7 @@ struct lttng_event {
        struct lttng_ctx *ctx;
        enum lttng_kernel_instrumentation instrumentation;
        union {
-               struct {
-                       struct kprobe kp;
-                       char *symbol_name;
-               } kprobe;
+               struct lttng_kprobe kprobe;
                struct {
                        struct lttng_krp *lttng_krp;
                        char *symbol_name;
@@ -339,6 +344,7 @@ struct lttng_event_notifier {
 
        enum lttng_kernel_instrumentation instrumentation;
        union {
+               struct lttng_kprobe kprobe;
        } u;
 
        /* Backward references: list of lttng_enabler_ref (ref to enablers) */
@@ -348,6 +354,7 @@ struct lttng_event_notifier {
        struct list_head bytecode_runtime_head;
        int has_enablers_without_bytecode;
 
+       void (*send_notification)(struct lttng_event_notifier *event_notifier);
        struct lttng_event_notifier_group *group; /* Weak ref */
 };
 
@@ -604,6 +611,7 @@ struct lttng_session {
 
 struct lttng_event_notifier_group {
        struct file *file;              /* File associated to event notifier group */
+       struct file *notif_file;        /* File used to expose notifications to userspace. */
        struct list_head node;          /* event notifier group list */
        struct list_head enablers_head; /* List of enablers */
        struct list_head event_notifiers_head; /* List of event notifier */
@@ -613,6 +621,8 @@ struct lttng_event_notifier_group {
        struct lttng_transport *transport;
        struct channel *chan;           /* Ring buffer channel for event notifier group. */
        struct lib_ring_buffer *buf;    /* Ring buffer for event notifier group. */
+       wait_queue_head_t read_wait;
+       struct irq_work wakeup_pending; /* Pending wakeup irq work. */
 };
 
 struct lttng_metadata_cache {
@@ -649,7 +659,9 @@ int lttng_event_notifier_enabler_enable(
 int lttng_event_notifier_enabler_disable(
                struct lttng_event_notifier_enabler *event_notifier_enabler);
 int lttng_fix_pending_events(void);
+int lttng_fix_pending_event_notifiers(void);
 int lttng_session_active(void);
+bool lttng_event_notifier_active(void);
 
 struct lttng_session *lttng_session_create(void);
 int lttng_session_enable(struct lttng_session *session);
@@ -712,6 +724,9 @@ int lttng_channel_disable(struct lttng_channel *channel);
 int lttng_event_enable(struct lttng_event *event);
 int lttng_event_disable(struct lttng_event *event);
 
+int lttng_event_notifier_enable(struct lttng_event_notifier *event_notifier);
+int lttng_event_notifier_disable(struct lttng_event_notifier *event_notifier);
+
 void lttng_transport_register(struct lttng_transport *transport);
 void lttng_transport_unregister(struct lttng_transport *transport);
 
@@ -998,16 +1013,22 @@ void lttng_logger_exit(void);
 extern int lttng_statedump_start(struct lttng_session *session);
 
 #ifdef CONFIG_KPROBES
-int lttng_kprobes_register(const char *name,
+int lttng_kprobes_register_event(const char *name,
                const char *symbol_name,
                uint64_t offset,
                uint64_t addr,
                struct lttng_event *event);
-void lttng_kprobes_unregister(struct lttng_event *event);
-void lttng_kprobes_destroy_private(struct lttng_event *event);
+void lttng_kprobes_unregister_event(struct lttng_event *event);
+void lttng_kprobes_destroy_event_private(struct lttng_event *event);
+int lttng_kprobes_register_event_notifier(const char *symbol_name,
+               uint64_t offset,
+               uint64_t addr,
+               struct lttng_event_notifier *event_notifier);
+void lttng_kprobes_unregister_event_notifier(struct lttng_event_notifier *event_notifier);
+void lttng_kprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier);
 #else
 static inline
-int lttng_kprobes_register(const char *name,
+int lttng_kprobes_register_event(const char *name,
                const char *symbol_name,
                uint64_t offset,
                uint64_t addr,
@@ -1017,12 +1038,31 @@ int lttng_kprobes_register(const char *name,
 }
 
 static inline
-void lttng_kprobes_unregister(struct lttng_event *event)
+void lttng_kprobes_unregister_event(struct lttng_event *event)
+{
+}
+
+static inline
+void lttng_kprobes_destroy_event_private(struct lttng_event *event)
+{
+}
+
+static inline
+int lttng_kprobes_register_event_notifier(const char *symbol_name,
+               uint64_t offset,
+               uint64_t addr,
+               struct lttng_event_notifier *event_notifier)
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_kprobes_unregister_event_notifier(struct lttng_event_notifier *event_notifier)
 {
 }
 
 static inline
-void lttng_kprobes_destroy_private(struct lttng_event *event)
+void lttng_kprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier)
 {
 }
 #endif
This page took 0.025027 seconds and 4 git commands to generate.