From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
Luis Goncalves <lgoncalv@redhat.com>,
Gabriele Monaco <gmonaco@redhat.com>
Subject: [for-next][PATCH 11/14] rtla: Count missed trace events
Date: Fri, 24 Jan 2025 13:48:46 -0500 [thread overview]
Message-ID: <20250124184858.068142598@goodmis.org> (raw)
In-Reply-To: 20250124184835.052017152@goodmis.org
From: Tomas Glozar <tglozar@redhat.com>
Add function collect_missed_events to trace.c to act as a callback for
tracefs_follow_missed_events, summing the number of total missed events
into a new field missing_events of struct trace_instance.
In case record->missed_events is negative, trace->missed_events is set
to UINT64_MAX to signify an unknown number of events was missed.
The callback is activated on initialization of the trace instance.
Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250123142339.990300-2-tglozar@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tools/tracing/rtla/src/trace.c | 34 ++++++++++++++++++++++++++++++++++
tools/tracing/rtla/src/trace.h | 1 +
2 files changed, 35 insertions(+)
diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c
index 80b14b8a3c2e..94e490782f14 100644
--- a/tools/tracing/rtla/src/trace.c
+++ b/tools/tracing/rtla/src/trace.c
@@ -126,6 +126,31 @@ collect_registered_events(struct tep_event *event, struct tep_record *record,
return 0;
}
+/*
+ * collect_missed_events - record number of missed events
+ *
+ * If rtla cannot keep up with events generated by tracer, events are going
+ * to fall out of the ring buffer.
+ * Collect how many events were missed so it can be reported to the user.
+ */
+static int
+collect_missed_events(struct tep_event *event, struct tep_record *record,
+ int cpu, void *context)
+{
+ struct trace_instance *trace = context;
+
+ if (trace->missed_events == UINT64_MAX)
+ return 0;
+
+ if (record->missed_events > 0)
+ trace->missed_events += record->missed_events;
+ else
+ /* Events missed but no data on how many */
+ trace->missed_events = UINT64_MAX;
+
+ return 0;
+}
+
/*
* trace_instance_destroy - destroy and free a rtla trace instance
*/
@@ -181,6 +206,15 @@ int trace_instance_init(struct trace_instance *trace, char *tool_name)
*/
tracefs_trace_off(trace->inst);
+ /*
+ * Collect the number of events missed due to tracefs buffer
+ * overflow.
+ */
+ trace->missed_events = 0;
+ tracefs_follow_missed_events(trace->inst,
+ collect_missed_events,
+ trace);
+
return 0;
out_err:
diff --git a/tools/tracing/rtla/src/trace.h b/tools/tracing/rtla/src/trace.h
index c3e03f7df770..a6e88709604b 100644
--- a/tools/tracing/rtla/src/trace.h
+++ b/tools/tracing/rtla/src/trace.h
@@ -17,6 +17,7 @@ struct trace_instance {
struct tracefs_instance *inst;
struct tep_handle *tep;
struct trace_seq *seq;
+ unsigned long long missed_events;
};
int trace_instance_init(struct trace_instance *trace, char *tool_name);
--
2.45.2
next prev parent reply other threads:[~2025-01-24 18:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 18:48 [for-next][PATCH 00/14] rtla: Update for tools for 6.14 Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 01/14] tools/rtla: Add basic test suite Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 02/14] rtla: Add trace_instance_stop Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 03/14] rtla/timerlat_hist: Stop timerlat tracer on signal Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 04/14] rtla/timerlat_top: " Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 05/14] rtla/timerlat_hist: Abort event processing on second signal Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 06/14] rtla/timerlat_top: " Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 07/14] rtla/osnoise: Distinguish missing workload option Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 08/14] rtla/timerlat_hist: Set OSNOISE_WORKLOAD for kernel threads Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 09/14] rtla/timerlat_top: " Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 10/14] tools/rtla: Add osnoise_trace_is_off() Steven Rostedt
2025-01-24 18:48 ` Steven Rostedt [this message]
2025-01-24 18:48 ` [for-next][PATCH 12/14] rtla: Count all processed events Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 13/14] rtla: Add function to report missed events Steven Rostedt
2025-01-24 18:48 ` [for-next][PATCH 14/14] rtla: Report missed event count Steven Rostedt
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=20250124184858.068142598@goodmis.org \
--to=rostedt@goodmis.org \
--cc=gmonaco@redhat.com \
--cc=jkacur@redhat.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglozar@redhat.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