sessiond: enforce mmap output type for kernel metadata channel
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 5 May 2020 22:54:32 +0000 (18:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 May 2020 20:25:31 +0000 (16:25 -0400)
A follow-up fix causes the consumer daemon to accumulate metadata
packets into a complete "unit" that can be parsed before sending it to
the relay daemon.

The consumer daemon will also need to extract the contents of the
metadata cache when computing a rotation position (follow-up fix too).

Hence, it is not possible to rely on the splice back-end as the
consumer daemon may need to accumulate more content than can be backed
by the ring buffer's underlying pages.

In both cases, the splice output mode could still be used when
combined with a memfd, but I see no tangible benefit. Moreover, it
would require a 3.17 kernel.

Curiously the kernel metadata channel configuration appears to be
hard-coded twice; once in the ltt_kernel_session's
ltt_kernel_metadata, and once again in
kernel_consumer_add_metadata(). kernel_consumer_add_metadata is
modified to use the kernel session's metadata configuration.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia4cad82f595d3eee50d081851c234d4c2ef7ee5f

src/bin/lttng-sessiond/kernel-consumer.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/trace-kernel.c
src/common/defaults.h
tests/unit/test_kernel_data.c

index 9622d3058941e6cbe79ffac6528356b14b0a00ad..6244963cc688746b575719ee09fad3e217db5025 100644 (file)
@@ -222,12 +222,23 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock,
        consumer = ksession->consumer;
 
        /* Prep channel message structure */
        consumer = ksession->consumer;
 
        /* Prep channel message structure */
-       consumer_init_add_channel_comm_msg(&lkm, ksession->metadata->key,
-                       ksession->id, "", ksession->uid, ksession->gid,
-                       consumer->net_seq_index, DEFAULT_METADATA_NAME, 1,
-                       DEFAULT_KERNEL_CHANNEL_OUTPUT,
-                       CONSUMER_CHANNEL_TYPE_METADATA, 0, 0, monitor, 0,
-                       ksession->is_live_session, 0,
+       consumer_init_add_channel_comm_msg(&lkm,
+                       ksession->metadata->key,
+                       ksession->id,
+                       "",
+                       ksession->uid,
+                       ksession->gid,
+                       consumer->net_seq_index,
+                       ksession->metadata->conf->name,
+                       1,
+                       ksession->metadata->conf->attr.output,
+                       CONSUMER_CHANNEL_TYPE_METADATA,
+                       ksession->metadata->conf->attr.tracefile_size,
+                       ksession->metadata->conf->attr.tracefile_count,
+                       monitor,
+                       ksession->metadata->conf->attr.live_timer_interval,
+                       ksession->is_live_session,
+                       0,
                        ksession->current_trace_chunk);
 
        health_code_update();
                        ksession->current_trace_chunk);
 
        health_code_update();
index 53efad5e79ed0b60dbff2d8d3d9b04319ed12e25..a117575b74c45ae067ed9ac31fccc6952a3e9fd0 100644 (file)
@@ -8,6 +8,7 @@
 #include "bin/lttng-sessiond/tracker.h"
 #include "common/tracker.h"
 #include "common/utils.h"
 #include "bin/lttng-sessiond/tracker.h"
 #include "common/tracker.h"
 #include "common/utils.h"
+#include "lttng/event.h"
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
 #define _LGPL_SOURCE
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
 #define _LGPL_SOURCE
index 723ffddd33118ebfd639135decc22bbe1b2c54de..044fc98d2510ddd17c1bb36353e99f9780b8d933 100644 (file)
@@ -19,6 +19,7 @@
 #include <common/common.h>
 #include <common/defaults.h>
 #include <common/trace-chunk.h>
 #include <common/common.h>
 #include <common/defaults.h>
 #include <common/trace-chunk.h>
+#include <common/macros.h>
 
 #include "consumer.h"
 #include "trace-kernel.h"
 
 #include "consumer.h"
 #include "trace-kernel.h"
@@ -485,6 +486,7 @@ error:
  */
 struct ltt_kernel_metadata *trace_kernel_create_metadata(void)
 {
  */
 struct ltt_kernel_metadata *trace_kernel_create_metadata(void)
 {
+       int ret;
        struct ltt_kernel_metadata *lkm;
        struct lttng_channel *chan;
 
        struct ltt_kernel_metadata *lkm;
        struct lttng_channel *chan;
 
@@ -495,13 +497,38 @@ struct ltt_kernel_metadata *trace_kernel_create_metadata(void)
                goto error;
        }
 
                goto error;
        }
 
+       ret = lttng_strncpy(
+                       chan->name, DEFAULT_METADATA_NAME, sizeof(chan->name));
+       if (ret) {
+               ERR("Failed to initialize metadata channel name to `%s`",
+                               DEFAULT_METADATA_NAME);
+               goto error;
+       }
+
        /* Set default attributes */
        /* Set default attributes */
-       chan->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE;
+       chan->attr.overwrite = DEFAULT_METADATA_OVERWRITE;
        chan->attr.subbuf_size = default_get_metadata_subbuf_size();
        chan->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM;
        chan->attr.subbuf_size = default_get_metadata_subbuf_size();
        chan->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM;
-       chan->attr.switch_timer_interval = DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER;
-       chan->attr.read_timer_interval = DEFAULT_KERNEL_CHANNEL_READ_TIMER;
-       chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
+       chan->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER;
+       chan->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER;;
+
+
+       /*
+        * The metadata channel of kernel sessions must use the "mmap"
+        * back-end since the consumer daemon accumulates complete
+        * metadata units before sending them to the relay daemon in
+        * live mode. The consumer daemon also needs to extract the contents
+        * of the metadata cache when computing a rotation position.
+        *
+        * In both cases, it is not possible to rely on the splice
+        * back-end as the consumer daemon may need to accumulate more
+        * content than can be backed by the ring buffer's underlying
+        * pages.
+        */
+       chan->attr.output = LTTNG_EVENT_MMAP;
+       chan->attr.tracefile_size = 0;
+       chan->attr.tracefile_count = 0;
+       chan->attr.live_timer_interval = 0;
 
        /* Init metadata */
        lkm->fd = -1;
 
        /* Init metadata */
        lkm->fd = -1;
index baf3d5fcce5d3f1cdba9374dd64e1408183984af..1e4b7fac7ab7d5d500ddd84985b76051dfefef49 100644 (file)
 #define DEFAULT_METADATA_SUBBUF_SIZE    CONFIG_DEFAULT_METADATA_SUBBUF_SIZE
 #define DEFAULT_METADATA_SUBBUF_NUM     CONFIG_DEFAULT_METADATA_SUBBUF_NUM
 #define DEFAULT_METADATA_CACHE_SIZE     CONFIG_DEFAULT_METADATA_CACHE_SIZE
 #define DEFAULT_METADATA_SUBBUF_SIZE    CONFIG_DEFAULT_METADATA_SUBBUF_SIZE
 #define DEFAULT_METADATA_SUBBUF_NUM     CONFIG_DEFAULT_METADATA_SUBBUF_NUM
 #define DEFAULT_METADATA_CACHE_SIZE     CONFIG_DEFAULT_METADATA_CACHE_SIZE
-#define DEFAULT_METADATA_SWITCH_TIMER  CONFIG_DEFAULT_METADATA_SWITCH_TIMER
-#define DEFAULT_METADATA_READ_TIMER    CONFIG_DEFAULT_METADATA_READ_TIMER
-#define DEFAULT_METADATA_OUTPUT                        _DEFAULT_CHANNEL_OUTPUT
+#define DEFAULT_METADATA_SWITCH_TIMER  0
+#define DEFAULT_METADATA_READ_TIMER    0
+#define DEFAULT_METADATA_OVERWRITE     0
+#define DEFAULT_METADATA_OUTPUT                LTTNG_EVENT_MMAP
 
 /* Kernel has different defaults */
 
 
 /* Kernel has different defaults */
 
index 322c2eb211f12b0aec827c486451c806ab3646e8..444ae86ae200aad7bb0ef2755465972678d06f8b 100644 (file)
@@ -81,17 +81,17 @@ static void test_create_kernel_metadata(void)
        ok(kern->metadata->fd == -1 &&
           kern->metadata->conf != NULL &&
           kern->metadata->conf->attr.overwrite
        ok(kern->metadata->fd == -1 &&
           kern->metadata->conf != NULL &&
           kern->metadata->conf->attr.overwrite
-                       == DEFAULT_CHANNEL_OVERWRITE &&
+                       == DEFAULT_METADATA_OVERWRITE &&
           kern->metadata->conf->attr.subbuf_size
                        == default_get_metadata_subbuf_size() &&
           kern->metadata->conf->attr.num_subbuf
                        == DEFAULT_METADATA_SUBBUF_NUM &&
           kern->metadata->conf->attr.switch_timer_interval
           kern->metadata->conf->attr.subbuf_size
                        == default_get_metadata_subbuf_size() &&
           kern->metadata->conf->attr.num_subbuf
                        == DEFAULT_METADATA_SUBBUF_NUM &&
           kern->metadata->conf->attr.switch_timer_interval
-                       == DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER &&
+                       == DEFAULT_METADATA_SWITCH_TIMER &&
           kern->metadata->conf->attr.read_timer_interval
           kern->metadata->conf->attr.read_timer_interval
-                       == DEFAULT_KERNEL_CHANNEL_READ_TIMER &&
+                       == DEFAULT_METADATA_READ_TIMER &&
           kern->metadata->conf->attr.output
           kern->metadata->conf->attr.output
-              == DEFAULT_KERNEL_CHANNEL_OUTPUT,
+                       == LTTNG_EVENT_MMAP,
           "Validate kernel session metadata");
 
        trace_kernel_destroy_metadata(kern->metadata);
           "Validate kernel session metadata");
 
        trace_kernel_destroy_metadata(kern->metadata);
This page took 0.030081 seconds and 5 git commands to generate.