diff mbox series

[05/12] trace-cmd analyze: Use sched_switch event to update times

Message ID 20220324025726.1727204-6-rostedt@goodmis.org
State New
Headers show
Series trace-cmd: Add trace-cmd analyze command | expand

Commit Message

Steven Rostedt March 24, 2022, 2:57 a.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

If the sched_switch event is available, use that to figure out how long a
task is running on the CPU. It gives better accuracy than just basing it
off of events.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-analyze.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/tracecmd/trace-analyze.c b/tracecmd/trace-analyze.c
index dec705ce8e15..56123f9b4f86 100644
--- a/tracecmd/trace-analyze.c
+++ b/tracecmd/trace-analyze.c
@@ -270,6 +270,8 @@  static void process_switch(struct analysis_data *data,
 	cpu_task = get_cpu_task(cpu_data, pid);
 	task = cpu_task->task;
 
+	update_cpu_task_times(cpu_data, cpu_task, record->ts);
+
 	/* Fill in missing comms */
 	if (pid && data->prev_comm && !task->comm) {
 		comm = (char *)(record->data + data->prev_comm->offset);
@@ -283,6 +285,8 @@  static void process_switch(struct analysis_data *data,
 		pid = val;
 		cpu_task = get_cpu_task(cpu_data, pid);
 		task = cpu_task->task;
+		task->start_ts = record->ts;
+		cpu_data->current_pid = pid;
 
 		/* Fill in missing comms */
 		if (pid && data->next_comm && !task->comm) {