Move LTTng-UST buffer ownership from application to consumer
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-ust-abi.h
index ef663ced23ca633991eede0c73a7ece811a16400..4ef04653cc517bebc3ec87890f03bc9dcc975622 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 #include <stdint.h>
-#include <common/macros.h>
+#include <lttng/ust-compiler.h>
 
 #define LTTNG_UST_SYM_NAME_LEN 256
 
@@ -57,6 +57,11 @@ enum lttng_ust_output {
        LTTNG_UST_MMAP          = 0,
 };
 
+enum lttng_ust_chan_type {
+       LTTNG_UST_CHAN_PER_CPU = 0,
+       LTTNG_UST_CHAN_METADATA = 1,
+};
+
 struct lttng_ust_tracer_version {
        uint32_t major;
        uint32_t minor;
@@ -64,24 +69,29 @@ struct lttng_ust_tracer_version {
 } LTTNG_PACKED;
 
 #define LTTNG_UST_CHANNEL_PADDING      LTTNG_UST_SYM_NAME_LEN + 32
+/*
+ * Given that the consumerd is limited to 64k file descriptors, we
+ * cannot expect much more than 1MB channel structure size. This size is
+ * depends on the number of streams within a channel, which depends on
+ * the number of possible CPUs on the system.
+ */
+#define LTTNG_UST_CHANNEL_DATA_MAX_LEN 1048576U
 struct lttng_ust_channel {
-       uint64_t subbuf_size;                   /* in bytes */
-       uint64_t num_subbuf;
-       int overwrite;                          /* 1: overwrite, 0: discard */
-       unsigned int switch_timer_interval;     /* usecs */
-       unsigned int read_timer_interval;       /* usecs */
-       enum lttng_ust_output output;           /* output mode */
+       uint64_t len;
+       enum lttng_ust_chan_type type;
        char padding[LTTNG_UST_CHANNEL_PADDING];
+       char data[];    /* variable sized data */
 } LTTNG_PACKED;
 
-#define LTTNG_UST_STREAM_PADDING1      16
-#define LTTNG_UST_STREAM_PADDING2      LTTNG_UST_SYM_NAME_LEN + 32
+#define LTTNG_UST_STREAM_PADDING1      LTTNG_UST_SYM_NAME_LEN + 32
 struct lttng_ust_stream {
+       uint64_t len;           /* shm len */
+       uint32_t stream_nr;     /* stream number */
        char padding[LTTNG_UST_STREAM_PADDING1];
-
-       union {
-               char padding[LTTNG_UST_STREAM_PADDING2];
-       } u;
+       /*
+        * shm_fd and wakeup_fd are send over unix socket as file
+        * descriptors after this structure.
+        */
 } LTTNG_PACKED;
 
 #define LTTNG_UST_EVENT_PADDING1       16
@@ -157,13 +167,32 @@ struct lttng_ust_tracepoint_iter {
        char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING];
 } LTTNG_PACKED;
 
-#define LTTNG_UST_OBJECT_DATA_PADDING          LTTNG_UST_SYM_NAME_LEN + 32
+enum lttng_ust_object_type {
+       LTTNG_UST_OBJECT_TYPE_UNKNOWN = -1,
+       LTTNG_UST_OBJECT_TYPE_CHANNEL = 0,
+       LTTNG_UST_OBJECT_TYPE_STREAM = 1,
+};
+
+#define LTTNG_UST_OBJECT_DATA_PADDING1         32
+#define LTTNG_UST_OBJECT_DATA_PADDING2         LTTNG_UST_SYM_NAME_LEN + 32
+
 struct lttng_ust_object_data {
-       uint64_t memory_map_size;
+       enum lttng_ust_object_type type;
        int handle;
-       int shm_fd;
-       int wait_fd;
-       char padding[LTTNG_UST_OBJECT_DATA_PADDING];
+       uint64_t size;
+       char padding1[LTTNG_UST_OBJECT_DATA_PADDING1];
+       union {
+               struct {
+                       void *data;
+                       enum lttng_ust_chan_type type;
+               } channel;
+               struct {
+                       int shm_fd;
+                       int wakeup_fd;
+                       uint32_t stream_nr;
+               } stream;
+               char padding2[LTTNG_UST_OBJECT_DATA_PADDING2];
+       } u;
 } LTTNG_PACKED;
 
 enum lttng_ust_calibrate_type {
@@ -245,14 +274,11 @@ struct lttng_ust_obj;
 
 union ust_args {
        struct {
-               int *shm_fd;
-               int *wait_fd;
-               uint64_t *memory_map_size;
+               void *chan_data;
        } channel;
        struct {
-               int *shm_fd;
-               int *wait_fd;
-               uint64_t *memory_map_size;
+               int shm_fd;
+               int wakeup_fd;
        } stream;
        struct {
                struct lttng_ust_field_iter entry;
This page took 0.025966 seconds and 5 git commands to generate.