diff mbox series

[09/11] libtraceeval task-eval: Do not add pdata to non RUNNING tasks

Message ID 20231011032640.1804571-10-rostedt@goodmis.org (mailing list archive)
State Under Review
Headers show
Series libtraceeval task-eval: Updates to evaluate tasks | expand

Commit Message

Steven Rostedt Oct. 11, 2023, 3:25 a.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The pdata is used to daisy chain all the threads for each task with the
same name. But since the tasks saving is broken up for each of their
scheduling states, the pdata is saved in just the RUNNING state. But since
it also needs to be freed, each pdata only needs to be saved once in the
traceeval for tasks.

Make sure that when updating the tasks, the pdata for the task is only
saved with the RUNNING state, and all other states just have NULL.

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

Patch

diff --git a/samples/task-eval.c b/samples/task-eval.c
index 79039580ce78..420d87f498cc 100644
--- a/samples/task-eval.c
+++ b/samples/task-eval.c
@@ -496,6 +496,10 @@  static void update_thread(struct task_data *tdata, int pid, const char *comm,
 
 		traceeval_insert(pdata->teval_threads, thread_keys, vals);
 
+		/* Only the RUNNING state keeps pdata */
+		if (state != RUNNING)
+			pdata = NULL;
+
 		/* Also update the process */
 		assign_task_keys(task_keys, comm, state);
 		assign_task_vals(pvals, pdata, delta, ts);