From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: Ross Zwisler <zwisler@google.com>,
"Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 11/11] libtraceeval task-evals: Free the libtraceevals
Date: Tue, 10 Oct 2023 23:25:27 -0400 [thread overview]
Message-ID: <20231011032640.1804571-12-rostedt@goodmis.org> (raw)
In-Reply-To: <20231011032640.1804571-1-rostedt@goodmis.org>
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Add code to free the allocated traceveals including the ones that are
daisy chained in the teval_tasks.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
samples/task-eval.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/samples/task-eval.c b/samples/task-eval.c
index 25032293c9a3..382e30514ec3 100644
--- a/samples/task-eval.c
+++ b/samples/task-eval.c
@@ -225,6 +225,20 @@ static void assign_task_keys(struct traceeval_data keys[2],
TRACEEVAL_SET_NUMBER(keys[1], state);
}
+static void release_data(const struct traceeval_type *type,
+ struct traceeval_data *data);
+
+static int copy_data(const struct traceeval_type *type,
+ struct traceeval_data *dst,
+ const struct traceeval_data *src)
+{
+ if (dst->pointer && dst->pointer != src->pointer)
+ die("Pointers do not match!");
+ /* This prevents releases of data */
+ *dst = *src;
+ return 0;
+}
+
/*
* For each state the process is in, record the time delta for
* that state. Also, only for the RUNNING state, this will
@@ -237,6 +251,8 @@ static struct traceeval_type task_vals[] = {
{
.type = TRACEEVAL_TYPE_POINTER,
.name = "data",
+ .release = release_data,
+ .copy = copy_data,
},
{
.type = TRACEEVAL_TYPE_DELTA,
@@ -326,6 +342,21 @@ enum command {
STOP
};
+static void release_data(const struct traceeval_type *type,
+ struct traceeval_data *data)
+{
+ struct process_data *pdata;
+
+ if (!data || !data->pointer)
+ return;
+
+ pdata = data->pointer;
+ traceeval_release(pdata->teval_cpus);
+ traceeval_release(pdata->teval_threads);
+ free(pdata);
+ data->pointer = NULL;
+}
+
static void init_process_data(struct process_data *pdata)
{
pdata->teval_cpus = traceeval_init(cpu_keys, cpu_vals);
@@ -1043,6 +1074,11 @@ static void display(struct task_data *tdata)
static void free_tdata(struct task_data *tdata)
{
+ if (!tdata)
+ return;
+
+ traceeval_release(tdata->teval_cpus);
+ traceeval_release(tdata->teval_tasks);
}
/*
--
2.42.0
prev parent reply other threads:[~2023-10-11 3:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 3:25 [PATCH 00/11] libtraceeval task-eval: Updates to evaluate tasks Steven Rostedt
2023-10-11 3:25 ` [PATCH 01/11] libtraceeval task-eval: Fix naming conventions of variables Steven Rostedt
2023-10-11 3:25 ` [PATCH 02/11] libtraceeval task-eval: Use "assign_*keys/vals()" helper functions Steven Rostedt
2023-10-11 3:25 ` [PATCH 03/11] libtraceeval task-eval: Add tracking of priority Steven Rostedt
2023-10-11 3:25 ` [PATCH 04/11] libtraceeval task-eval: Add way to read trace.dat buffer instances Steven Rostedt
2023-10-11 3:25 ` [PATCH 05/11] libtraceeval task-eval: Account for ZOMBIE and EXITED states Steven Rostedt
2023-10-11 3:25 ` [PATCH 06/11] libtraceeval task-eval: Show max, min and count of deltas too Steven Rostedt
2023-10-11 3:25 ` [PATCH 07/11] libtraceeval task-eval: Add more comments Steven Rostedt
2023-10-11 3:25 ` [PATCH 08/11] libtraceeval task-eval: Only release results if found Steven Rostedt
2023-10-11 3:25 ` [PATCH 09/11] libtraceeval task-eval: Do not add pdata to non RUNNING tasks Steven Rostedt
2023-10-11 3:25 ` [PATCH 10/11] libtraceveal task-eval: Clean up all traceeval_iterators Steven Rostedt
2023-10-11 3:25 ` Steven Rostedt [this message]
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=20231011032640.1804571-12-rostedt@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=zwisler@google.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).