Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] [PATCH lttng-tools 1/3 master, 2.10-rc] Fix: discard event/lost packet counters
Date: Fri, 26 May 2017 18:14:18 +0200	[thread overview]
Message-ID: <1495815260-21060-1-git-send-email-mathieu.desnoyers@efficios.com> (raw)

For per-pid buffers, we need to sum the counters for each application.

For per-uid buffers, if no application has launched yet, it should not
be considered as an error (which stops iteration on all other channels),
but rather as values of 0.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/bin/lttng-sessiond/ust-app.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c
index d292779..8176d4d 100644
--- a/src/bin/lttng-sessiond/ust-app.c
+++ b/src/bin/lttng-sessiond/ust-app.c
@@ -6083,21 +6083,24 @@ int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id,
 	int ret;
 	uint64_t consumer_chan_key;
 
+	*discarded = 0;
+	*lost = 0;
+
 	ret = buffer_reg_uid_consumer_channel_key(
 			buffer_reg_uid_list, ust_session_id,
 			uchan_id, &consumer_chan_key);
 	if (ret < 0) {
+		/* Not found */
+		ret = 0;
 		goto end;
 	}
 
 	if (overwrite) {
 		ret = consumer_get_lost_packets(ust_session_id,
 				consumer_chan_key, consumer, lost);
-		*discarded = 0;
 	} else {
 		ret = consumer_get_discarded_events(ust_session_id,
 				consumer_chan_key, consumer, discarded);
-		*lost = 0;
 	}
 
 end:
@@ -6116,10 +6119,13 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
 	struct ust_app_session *ua_sess;
 	struct ust_app_channel *ua_chan;
 
+	*discarded = 0;
+	*lost = 0;
+
 	rcu_read_lock();
 	/*
-	 * Iterate over every registered applications, return when we
-	 * found one in the right session and channel.
+	 * Iterate over every registered applications. Sum counters for
+	 * all applications containing requested session and channel.
 	 */
 	cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
 		struct lttng_ht_iter uiter;
@@ -6138,19 +6144,26 @@ int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess,
 		ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
 
 		if (overwrite) {
+			uint64_t _lost;
+
 			ret = consumer_get_lost_packets(usess->id, ua_chan->key,
-					consumer, lost);
-			*discarded = 0;
-			goto end;
+					consumer, &_lost);
+			if (ret < 0) {
+				break;
+			}
+			(*lost) += _lost;
 		} else {
+			uint64_t _discarded;
+
 			ret = consumer_get_discarded_events(usess->id,
-					ua_chan->key, consumer, discarded);
-			*lost = 0;
-			goto end;
+					ua_chan->key, consumer, &_discarded);
+			if (ret < 0) {
+				break;
+			}
+			(*discarded) += _discarded;
 		}
 	}
 
-end:
 	rcu_read_unlock();
 	return ret;
 }
-- 
2.1.4



             reply	other threads:[~2017-05-26 16:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 16:14 Mathieu Desnoyers [this message]
2017-05-26 16:14 ` [lttng-dev] [PATCH lttng-tools 2/3 master, 2.10-rc] Fix: lttng list of channels should return errors Mathieu Desnoyers
2017-05-26 16:14 ` [lttng-dev] [PATCH lttng-tools 3/3 master, 2.10-rc] Introduce "--blocking-timeout" channel parameter Mathieu Desnoyers
2017-05-26 18:18   ` Jonathan Rajotte-Julien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495815260-21060-1-git-send-email-mathieu.desnoyers@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox