Write event header
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 22 May 2011 05:16:50 +0000 (01:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 22 May 2011 05:16:50 +0000 (01:16 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ltt-events.c
ltt-events.h
ltt-ring-buffer-client.h
ltt-ring-buffer-metadata-client.h
probes/lttng-events.h
probes/lttng-ftrace.c
probes/lttng-kprobes.c

index 71fb8c70cdf99945534118674268fa77046dd0e7..46da159117bc27be766f1eebc97fac5f421e01d8 100644 (file)
@@ -362,7 +362,7 @@ int lttng_metadata_printf(struct ltt_session *session,
                 */
                waitret = wait_event_interruptible_timeout(*chan->ops->get_reader_wait_queue(chan),
                        ({
-                               ret = chan->ops->event_reserve(&ctx);
+                               ret = chan->ops->event_reserve(&ctx, 0);
                                ret != -ENOBUFS || !ret;
                        }),
                        msecs_to_jiffies(LTTNG_METADATA_TIMEOUT_MSEC));
index 5fd0b67a0c5137cbbd0e68ad67fd1c3254e61302..859b43b7b6e7feca15f28940b0bada2cb2d2d6f1 100644 (file)
@@ -180,7 +180,8 @@ struct ltt_channel_ops {
        void (*channel_destroy)(struct channel *chan);
        struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
        void (*buffer_read_close)(struct lib_ring_buffer *buf);
-       int (*event_reserve)(struct lib_ring_buffer_ctx *ctx);
+       int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
+                            uint16_t event_id);
        void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
        void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
                            size_t len);
index 0177d48b6cfab82926dce3ccb0330879eea6647e..e7bc4329f40e2f75a7f8b5e904424e3b4006dc9a 100644 (file)
@@ -126,7 +126,7 @@ unsigned char record_header_size(const struct lib_ring_buffer_config *config,
 extern
 void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
                                 struct lib_ring_buffer_ctx *ctx,
-                                u16 eID, u32 event_size);
+                                uint16_t event_id);
 
 /*
  * ltt_write_event_header
@@ -135,13 +135,12 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
  *
  * @config: ring buffer instance configuration
  * @ctx: reservation context
- * @eID : event ID
- * @event_size : size of the event, excluding the event header.
+ * @event_id: event ID
  */
 static __inline__
 void ltt_write_event_header(const struct lib_ring_buffer_config *config,
                            struct lib_ring_buffer_ctx *ctx,
-                           u16 eID, u32 event_size)
+                           uint16_t event_id)
 {
        struct ltt_channel *ltt_chan = channel_get_private(ctx->chan);
 
@@ -153,14 +152,13 @@ void ltt_write_event_header(const struct lib_ring_buffer_config *config,
        {
                uint32_t id_time = 0;
 
-               bt_bitfield_write(&id_time, uint32_t, 0, 5, eID);
+               bt_bitfield_write(&id_time, uint32_t, 0, 5, event_id);
                bt_bitfield_write(&id_time, uint32_t, 5, 27, ctx->tsc);
                lib_ring_buffer_write(config, ctx, &id_time, sizeof(id_time));
                break;
        }
        case 2: /* large */
        {
-               uint16_t event_id = eID;
                uint32_t timestamp = (uint32_t) ctx->tsc;
 
                lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
@@ -174,7 +172,7 @@ void ltt_write_event_header(const struct lib_ring_buffer_config *config,
        return;
 
 slow_path:
-       ltt_write_event_header_slow(config, ctx, eID, event_size);
+       ltt_write_event_header_slow(config, ctx, event_id);
 }
 
 /*
@@ -182,7 +180,7 @@ slow_path:
  */
 void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
                                   struct lib_ring_buffer_ctx *ctx,
-                                  u16 eID, u32 event_size)
+                                  uint16_t event_id)
 {
        struct ltt_channel *ltt_chan = channel_get_private(ctx->chan);
 
@@ -191,12 +189,12 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
                if (!(ctx->rflags & RING_BUFFER_RFLAG_FULL_TSC)) {
                        uint32_t id_time = 0;
 
-                       bt_bitfield_write(&id_time, uint32_t, 0, 5, eID);
+                       bt_bitfield_write(&id_time, uint32_t, 0, 5, event_id);
                        bt_bitfield_write(&id_time, uint32_t, 5, 27, ctx->tsc);
                        lib_ring_buffer_write(config, ctx, &id_time, sizeof(id_time));
                } else {
                        uint8_t id = 0;
-                       uint32_t event_id = (uint32_t) eID;
+                       uint32_t event_id = (uint32_t) event_id;
                        uint64_t timestamp = ctx->tsc;
 
                        bt_bitfield_write(&id, uint8_t, 0, 5, 31);
@@ -211,7 +209,6 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
        case 2: /* large */
        {
                if (!(ctx->rflags & RING_BUFFER_RFLAG_FULL_TSC)) {
-                       uint16_t event_id = eID;
                        uint32_t timestamp = (uint32_t) ctx->tsc;
 
                        lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
@@ -219,7 +216,7 @@ void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
                        lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
                } else {
                        uint16_t event_id = 65535;
-                       uint32_t event_id_ext = (uint32_t) eID;
+                       uint32_t event_id_ext = (uint32_t) event_id;
                        uint64_t timestamp = ctx->tsc;
 
                        lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
@@ -382,7 +379,8 @@ void ltt_buffer_read_close(struct lib_ring_buffer *buf)
 }
 
 static
-int ltt_event_reserve(struct lib_ring_buffer_ctx *ctx)
+int ltt_event_reserve(struct lib_ring_buffer_ctx *ctx,
+                     uint16_t event_id)
 {
        int ret, cpu;
 
@@ -394,8 +392,8 @@ int ltt_event_reserve(struct lib_ring_buffer_ctx *ctx)
        ret = lib_ring_buffer_reserve(&client_config, ctx);
        if (ret)
                goto put;
-       return ret;
-
+       ltt_write_event_header(&client_config, ctx, event_id);
+       return 0;
 put:
        lib_ring_buffer_put_cpu(&client_config);
        return ret;
index c457aea21361832cdb7c38de3483b559279922b5..17207f27ab928a929ec0a25cdb5a1cb5069ec84a 100644 (file)
@@ -187,7 +187,7 @@ void ltt_buffer_read_close(struct lib_ring_buffer *buf)
 }
 
 static
-int ltt_event_reserve(struct lib_ring_buffer_ctx *ctx)
+int ltt_event_reserve(struct lib_ring_buffer_ctx *ctx, uint16_t event_id)
 {
        return lib_ring_buffer_reserve(&client_config, ctx);
 }
index 8ffc23a28034d96cab6cd632d9a408ef71a878f9..422f959018c47c2d05d5c91bb2e328797854cf4a 100644 (file)
@@ -474,7 +474,7 @@ static void __event_probe__##_name(void *__data, _proto)                  \
        __event_align = __event_get_align__##_name(_args);                    \
        lib_ring_buffer_ctx_init(&ctx, __chan->chan, NULL, __event_len,       \
                                 __event_align, -1);                          \
-       __ret = __chan->ops->event_reserve(&ctx);                             \
+       __ret = __chan->ops->event_reserve(&ctx, __event->id);                \
        if (__ret < 0)                                                        \
                return;                                                       \
        /* Control code (field ordering) */                                   \
index da6d79c1078ae537f7d1f3d63a89c0275c9d5321..7c4fc9f55d78f5fc98898cd45af8a630b37e90ae 100644 (file)
@@ -38,7 +38,7 @@ void lttng_ftrace_handler(unsigned long ip, unsigned long parent_ip, void **data
                return;
        lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL,
                                 sizeof(payload), ltt_alignof(payload), -1);
-       ret = chan->ops->event_reserve(&ctx);
+       ret = chan->ops->event_reserve(&ctx, event->id);
        if (ret < 0)
                return;
        payload.ip = ip;
index 87806e37240695b6d2452b9e39d22a3f482769f7..65c1d3ba80ecf30eedbe8ccf1402c81ab4864998 100644 (file)
@@ -29,7 +29,7 @@ int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs)
                return 0;
        lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, sizeof(data),
                                 ltt_alignof(data), -1);
-       ret = chan->ops->event_reserve(&ctx);
+       ret = chan->ops->event_reserve(&ctx, event->id);
        if (ret < 0)
                return 0;
        lib_ring_buffer_align_ctx(&ctx, ltt_alignof(data));
This page took 0.032332 seconds and 4 git commands to generate.