-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for master branches of lttng
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
From 71540e46aef1da5595b817563ee231c6a3aae3df Mon Sep 17 00:00:00 2001 | ||
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
Date: Sat, 14 Oct 2023 09:36:58 -0400 | ||
Subject: [PATCH] consumer: Fix discarded events aggregation | ||
|
||
- Print error message if overflow is detected on 64-bit, | ||
- Do not update the channel counter if overflow is detected on 64-bit, | ||
so the situation can be recovered on the next aggregation if it was | ||
caused by a spurious race condition, | ||
- Change (1ULL << (CAA_BITS_PER_LONG - 1)) for (1ULL << 32), thus fixing | ||
an off-by-one in the shift on 32-bit. | ||
- Use an explicit shift of 32 rather than CAA_BITS_PER_LONG to eliminate | ||
too-large shift warnings on 64-bit. | ||
|
||
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
Change-Id: I1a0fca2dcf6e3fe5ec37509838515545b5ee9062 | ||
--- | ||
|
||
diff --git a/src/common/consumer/consumer-stream.cpp b/src/common/consumer/consumer-stream.cpp | ||
index 0742c86..2801f1d 100644 | ||
--- a/src/common/consumer/consumer-stream.cpp | ||
+++ b/src/common/consumer/consumer-stream.cpp | ||
@@ -77,13 +77,42 @@ | ||
consumer_stream_data_assert_locked_all(stream); | ||
} | ||
|
||
+static void aggregate_discarded_events(uint64_t *_chan_discarded_events, | ||
+ uint64_t *_stream_last_discarded_events, | ||
+ uint64_t stream_discarded_events) | ||
+{ | ||
+ uint64_t stream_last_discarded_events = *_stream_last_discarded_events; | ||
+ uint64_t stream_delta = 0; | ||
+ | ||
+ if (stream_discarded_events < stream_last_discarded_events) { | ||
+ if (CAA_BITS_PER_LONG >= 64) { | ||
+ ERR("Unexpected events discarded counter 64-bit overflow: prev = %" PRIu64 " current = %" PRIu64, | ||
+ stream_last_discarded_events, stream_discarded_events); | ||
+ /* | ||
+ * Unexpected counter overflow: don't update the counter, | ||
+ * so if this is caused by a race condition, we can | ||
+ * recover on the next aggregation. | ||
+ */ | ||
+ return; | ||
+ } else { | ||
+ /* | ||
+ * A 32-bit overflow is detected. We assume only one | ||
+ * wrap-around has occurred. | ||
+ */ | ||
+ stream_delta += 1ULL << 32; | ||
+ } | ||
+ } | ||
+ stream_delta += stream_discarded_events - stream_last_discarded_events; | ||
+ *_chan_discarded_events += stream_delta; | ||
+ *_stream_last_discarded_events = stream_discarded_events; | ||
+} | ||
+ | ||
/* Only used for data streams. */ | ||
static int consumer_stream_update_stats(struct lttng_consumer_stream *stream, | ||
const struct stream_subbuffer *subbuf) | ||
{ | ||
int ret = 0; | ||
uint64_t sequence_number; | ||
- const uint64_t discarded_events = subbuf->info.data.events_discarded; | ||
|
||
if (!subbuf->info.data.sequence_number.is_set) { | ||
/* Command not supported by the tracer. */ | ||
@@ -111,18 +140,9 @@ | ||
goto end; | ||
} | ||
stream->last_sequence_number = sequence_number; | ||
- | ||
- if (discarded_events < stream->last_discarded_events) { | ||
- /* | ||
- * Overflow has occurred. We assume only one wrap-around | ||
- * has occurred. | ||
- */ | ||
- stream->chan->discarded_events += (1ULL << (CAA_BITS_PER_LONG - 1)) - | ||
- stream->last_discarded_events + discarded_events; | ||
- } else { | ||
- stream->chan->discarded_events += discarded_events - stream->last_discarded_events; | ||
- } | ||
- stream->last_discarded_events = discarded_events; | ||
+ aggregate_discarded_events(&stream->chan->discarded_events, | ||
+ &stream->last_discarded_events, | ||
+ subbuf->info.data.events_discarded); | ||
ret = 0; | ||
|
||
end: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters