From 56f320664342ebf7b00376a2b813189484e22d6d Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 28 Oct 2024 16:02:59 -0400 Subject: [PATCH] Fix: silence 'non-consumed' message for non-started sessions Destroying a session with at least one enabled event and which has never been started will currently result in an error message in the kernel log about 'non-consumed data' for each of the per-cpu buffer. This happens because a packet header is created in the buffer but never consumed if the session is not started. Add a check in the buffer cleanup code to avoid printing 'non-consumed data' errors for buffers associated with a session taht was never started. Change-Id: I1358e1ae49d03544a961515b97b115a488434e27 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/ringbuffer/frontend_types.h | 1 + src/lib/ringbuffer/ring_buffer_frontend.c | 8 +++++++- src/lttng-events.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/ringbuffer/frontend_types.h b/include/ringbuffer/frontend_types.h index 07d23be2..4158033d 100644 --- a/include/ringbuffer/frontend_types.h +++ b/include/ringbuffer/frontend_types.h @@ -71,6 +71,7 @@ struct lttng_kernel_ring_buffer_channel { int finalized; /* Has channel been finalized */ struct channel_iter iter; /* Channel read-side iterator */ struct kref ref; /* Reference count */ + int been_active; /* Tracing was started at least once */ }; /* Per-subbuffer commit counters used on the hot path */ diff --git a/src/lib/ringbuffer/ring_buffer_frontend.c b/src/lib/ringbuffer/ring_buffer_frontend.c index 468d3bbc..e5984e67 100644 --- a/src/lib/ringbuffer/ring_buffer_frontend.c +++ b/src/lib/ringbuffer/ring_buffer_frontend.c @@ -1502,7 +1502,13 @@ void lib_ring_buffer_print_buffer_errors(struct lttng_kernel_ring_buffer *buf, */ write_offset = v_read(config, &buf->offset); cons_offset = atomic_long_read(&buf->consumed); - if (write_offset != cons_offset) + + /* + * Only print errors if the session associated with the buffer has been + * active, otherwise destroying an un-started session results in errors + * because of the un-consumed packet header present in the buffer. + */ + if (chan->been_active && write_offset != cons_offset) printk(KERN_DEBUG "LTTng: ring buffer %s, cpu %d: " "non-consumed data\n" diff --git a/src/lttng-events.c b/src/lttng-events.c index 314fb3ec..e3ce3e74 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -499,6 +499,8 @@ int lttng_session_enable(struct lttng_kernel_session *session) list_for_each_entry(chan_priv, &session->priv->chan, node) { if (chan_priv->channel_type != METADATA_CHANNEL) lib_ring_buffer_clear_quiescent_channel(chan_priv->rb_chan); + + WRITE_ONCE(chan_priv->rb_chan->been_active, 1); } WRITE_ONCE(session->active, 1); -- 2.34.1