From: Jonathan Rajotte Date: Mon, 15 May 2017 19:37:21 +0000 (-0400) Subject: Fix: check lttng-modules ABI version for RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS support X-Git-Tag: v2.10.0-rc2~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=883d847805ee5d3c222e0649872744a93f3e5a6b;p=lttng-tools.git Fix: check lttng-modules ABI version for RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS support 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index b836f3d8f..58b81477b 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -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: { diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index e47849933..b32193451 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -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; +} diff --git a/src/bin/lttng-sessiond/kernel.h b/src/bin/lttng-sessiond/kernel.h index 233ceffea..1b394947b 100644 --- a/src/bin/lttng-sessiond/kernel.h +++ b/src/bin/lttng-sessiond/kernel.h @@ -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 */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index e282a9c76..b2745086f 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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;