From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>
Subject: [PATCH] trace-cmd split: Save missed events
Date: Wed, 8 Jun 2022 11:14:24 -0400 [thread overview]
Message-ID: <20220608111424.4a66d384@gandalf.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If the file that is being split has missed events, the new file does not
create them. This gets confusing for users that see gaps in the trace.
Have the split code preserve the missed events in the new file.
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212421
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
tracecmd/trace-split.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index 83c5402c279b..851ec94eda1f 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -40,6 +40,7 @@ enum split_types {
struct cpu_data {
unsigned long long ts;
unsigned long long offset;
+ unsigned long long missed_events;
struct tep_record *record;
int cpu;
int fd;
@@ -137,18 +138,37 @@ static int write_record(struct tracecmd_input *handle,
return 1;
}
+#define MISSING_EVENTS (1UL << 31)
+#define MISSING_STORED (1UL << 30)
+
+#define COMMIT_MASK ((1 << 27) - 1)
+
static void write_page(struct tep_handle *pevent,
struct cpu_data *cpu_data, int long_size)
{
+ unsigned long long *ptr = NULL;
+ unsigned int flags = 0;
+
+ if (cpu_data->missed_events) {
+ flags |= MISSING_EVENTS;
+ if (cpu_data->missed_events > 0) {
+ flags |= MISSING_STORED;
+ ptr = cpu_data->page + cpu_data->index;
+ }
+ }
+
if (long_size == 8) {
- unsigned long long index = cpu_data->index - 16;
+ unsigned long long index = cpu_data->index - 16 + flags;;
*(unsigned long long *)cpu_data->commit =
tep_read_number(pevent, &index, 8);
} else {
- unsigned int index = cpu_data->index - 12;
+ unsigned int index = cpu_data->index - 12 + flags;;
*(unsigned int *)cpu_data->commit =
tep_read_number(pevent, &index, 4);
}
+ if (ptr)
+ *ptr = tep_read_number(pevent, &cpu_data->missed_events, 8);
+
write(cpu_data->fd, cpu_data->page, page_size);
}
@@ -224,7 +244,8 @@ static int parse_cpu(struct tracecmd_input *handle,
start = record->ts;
while (record && (!end || record->ts <= end)) {
- if (cpu_data[cpu].index + record->record_size > page_size) {
+ if ((cpu_data[cpu].index + record->record_size > page_size) ||
+ record->missed_events) {
if (type == SPLIT_PAGES && ++pages > count_limit)
break;
@@ -237,6 +258,8 @@ static int parse_cpu(struct tracecmd_input *handle,
die("Failed to allocate page");
}
+ cpu_data[cpu].missed_events = record->missed_events;
+
memset(cpu_data[cpu].page, 0, page_size);
ptr = cpu_data[cpu].page;
--
2.35.1
reply other threads:[~2022-06-08 15:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220608111424.4a66d384@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=johannes@sipsolutions.net \
--cc=linux-trace-devel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).