Fix: check lttng-modules ABI version for RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS support
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 15 May 2017 19:37:21 +0000 (15:37 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 13 Jun 2017 16:29:59 +0000 (12:29 -0400)
The RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS was introduced in
lttng-modules ABI version 2.3. When interacting with a kernel tracer
with ABI versions < 2.3, pass zero as monitor_timer_interval to disable
the monitoring.

Warn during sessiond startup and channel enabling if not supported.

Fixes #1101

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/kernel.h
src/bin/lttng-sessiond/main.c

index b836f3d8f5a4c71b408731c3dcdfe1e394e3147e..58b81477b6bd8345bfafc9c603abd9e2686b49dc 100644 (file)
@@ -34,6 +34,7 @@
 #include <lttng/trigger/trigger-internal.h>
 #include <lttng/condition/condition.h>
 #include <lttng/action/action.h>
+#include <lttng/channel.h>
 #include <lttng/channel-internal.h>
 #include <common/string-utils/string-utils.h>
 
@@ -1357,6 +1358,30 @@ int cmd_enable_channel(struct ltt_session *session,
                attr->attr.switch_timer_interval = 0;
        }
 
+       /* Check for feature support */
+       switch (domain->type) {
+       case LTTNG_DOMAIN_KERNEL:
+       {
+               if (kernel_supports_ring_buffer_snapshot_sample_positions(kernel_tracer_fd) != 1) {
+                       /* Sampling position of buffer is not supported */
+                       WARN("Kernel tracer does not support buffer monitoring. "
+                                       "Setting the monitor interval timer to 0 "
+                                       "(disabled) for channel '%s' of session '%s'",
+                                       attr-> name, session->name);
+                       lttng_channel_set_monitor_timer_interval(attr, 0);
+               }
+               break;
+       }
+       case LTTNG_DOMAIN_UST:
+       case LTTNG_DOMAIN_JUL:
+       case LTTNG_DOMAIN_LOG4J:
+       case LTTNG_DOMAIN_PYTHON:
+               break;
+       default:
+               ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+               goto error;
+       }
+
        switch (domain->type) {
        case LTTNG_DOMAIN_KERNEL:
        {
index e478499336896f5d739e087c8ee91e3a395886cd..b32193451f2060c401ac9d7503f2e48574be3fe4 100644 (file)
@@ -1088,3 +1088,35 @@ int kernel_syscall_mask(int chan_fd, char **syscall_mask, uint32_t *nr_bits)
 
        return kernctl_syscall_mask(chan_fd, syscall_mask, nr_bits);
 }
+
+/*
+ * Check for the support of the RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS via abi
+ * version number.
+ *
+ * Return 1 on success, 0 when feature is not supported, negative value in case
+ * of errors.
+ */
+int kernel_supports_ring_buffer_snapshot_sample_positions(int tracer_fd)
+{
+       int ret = 0; // Not supported by default
+       struct lttng_kernel_tracer_abi_version abi;
+
+       ret = kernctl_tracer_abi_version(tracer_fd, &abi);
+       if (ret < 0) {
+               ERR("Failed to retrieve lttng-modules ABI version");
+               goto error;
+       }
+
+       /*
+        * RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS was introduced in 2.3
+        */
+       if (abi.major >= 2 && abi.minor >= 3) {
+               /* Supported */
+               ret = 1;
+       } else {
+               /* Not supported */
+               ret = 0;
+       }
+error:
+       return ret;
+}
index 233ceffea09222a4a140a774e0723915adc19aee..1b394947b31f8c4c2c4ca6cc88efbc291c6a8db6 100644 (file)
@@ -65,5 +65,6 @@ int kernel_syscall_mask(int chan_fd, char **syscall_mask, uint32_t *nr_bits);
 int init_kernel_workarounds(void);
 ssize_t kernel_list_tracker_pids(struct ltt_kernel_session *session,
                int **_pids);
+int kernel_supports_ring_buffer_snapshot_sample_positions(int tracer_fd);
 
 #endif /* _LTT_KERNEL_CTL_H */
index e282a9c7699845ae4a15e4a9216fa81f812f9020..b2745086f3860fab9062d5b24ed995d4cfab9325 100644 (file)
@@ -2797,6 +2797,18 @@ static int init_kernel_tracer(void)
                goto error_modules;
        }
 
+       ret = kernel_supports_ring_buffer_snapshot_sample_positions(
+                       kernel_tracer_fd);
+       if (ret < 0) {
+               goto error_modules;
+       }
+
+       if (ret < 1) {
+               WARN("Kernel tracer does not support buffer monitoring. "
+                       "The monitoring timer of channels in the kernel domain "
+                       "will be set to 0 (disabled).");
+       }
+
        DBG("Kernel tracer fd %d", kernel_tracer_fd);
        return 0;
 
This page took 0.031967 seconds and 5 git commands to generate.