Skip to contentSkip to conversation

Fix: consumerd: add missing put_subbuf for ust and kernel errors

PATCH New Mathieu Desnoyers 2 participants 2 messages Jan 11, 2017 – Jan 24, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Fix: consumerd: add missing put_subbuf for ust and kernel errors

While reading a sub-buffer, error handling need to put the sub-buffer, else all future attempts to use the stream will trigger warnings.

The affects recent features added to UST and kernel tracing.

---
 src/common/kernel-consumer/kernel-consumer.c | 22 ++++++++++++++++++++++
 src/common/ust-consumer/ust-consumer.c       |  4 ++++
 2 files changed, 26 insertions(+)
src/common/kernel-consumer/kernel-consumer.c +22 -0
index bb5ba3b..d5418dc 100644
@@ -1315,12 +1315,34 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
 		}
 		ret = update_stream_stats(stream);
 		if (ret < 0) {
+			err = kernctl_put_subbuf(infd);
+			if (err != 0) {
+				if (err == -EFAULT) {
+					PERROR("Error in unreserving sub buffer\n");
+				} else if (err == -EIO) {
+					/* Should never happen with newer LTTng versions */
+					PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
+				}
+				ret = err;
+				goto end;
+			}
 			goto end;
 		}
 	} else {
 		write_index = 0;
 		ret = metadata_stream_check_version(infd, stream);
 		if (ret < 0) {
+			err = kernctl_put_subbuf(infd);
+			if (err != 0) {
+				if (err == -EFAULT) {
+					PERROR("Error in unreserving sub buffer\n");
+				} else if (err == -EIO) {
+					/* Should never happen with newer LTTng versions */
+					PERROR("Reader has been pushed by the writer, last sub-buffer corrupted.");
+				}
+				ret = err;
+				goto end;
+			}
 			goto end;
 		}
 	}
src/common/ust-consumer/ust-consumer.c +4 -0
index 7bbfa60..97f0497 100644
@@ -2496,6 +2496,8 @@ retry:
 		index.offset = htobe64(stream->out_fd_offset);
 		ret = get_index_values(&index, ustream);
 		if (ret < 0) {
+			err = ustctl_put_subbuf(ustream);
+			assert(err == 0);
 			goto end;
 		}
 
@@ -2503,6 +2505,8 @@ retry:
 		ret = update_stream_stats(stream);
 		if (ret < 0) {
 			PERROR("kernctl_get_events_discarded");
+			err = ustctl_put_subbuf(ustream);
+			assert(err == 0);
 			goto end;
 		}
 	} else {
Signature · 6 lines
2.1.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#2 lore raw

Re: [PATCH lttng-tools 1/2] Fix: sessiond: only send streams to consumer once

In reply to a message not in the archive

Both patches were merged in master, stable-2.9 and stable-2.8.

Thanks!
Jérémie

Quoted 51 lines · Mathieu Desnoyers

Session daemon should not send streams to consumer daemon repeatedly when CPU hotplug is performed while doing kernel tracing.

This causes the consumer daemon to have multiple file descriptors on the same stream, and thus try to perform operations like reading a sub-buffer and checking for data pending concurrently. This triggers safety-net warnings in the kernel tracer.

---
 src/bin/lttng-sessiond/kernel-consumer.c | 3 ++-
 src/bin/lttng-sessiond/trace-kernel.h    | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
src/bin/lttng-sessiond/kernel-consumer.c +2 -1
index 7582d80..b9d689f 100644
@@ -338,7 +338,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
 
        /* Send streams */
        cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
-               if (!stream->fd) {
+               if (!stream->fd || stream->sent_to_consumer) {
                        continue;
                }
 
@@ -348,6 +348,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock,
                if (ret < 0) {
                        goto error;
                }
+               stream->sent_to_consumer = 1;
        }
 
 error:
src/bin/lttng-sessiond/trace-kernel.h +1 -1
index b9bcbfa..91672bc 100644
@@ -84,6 +84,7 @@ struct ltt_kernel_stream {
        int fd;
        int state;
        int cpu;
+       int sent_to_consumer;
        /* Format is %s_%d respectively channel name and CPU number. */
        char name[DEFAULT_STREAM_NAME_LEN];
        uint64_t tracefile_size;
--

2.1.4

Signature · 7 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev