From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> 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@xxxxxxxxxxx> --- tracecmd/trace-analyze.c | 4 ++++ 1 file changed, 4 insertions(+) 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) { -- 2.35.1