[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-5cedb413a63d452356aa634e0d4ffcc24f7dbcb5@git.kernel.org>
Date: Fri, 9 Mar 2018 00:54:22 -0800
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
linux-kernel@...r.kernel.org, tglx@...utronix.de,
dsahern@...il.com, mingo@...nel.org, namhyung@...nel.org,
hpa@...or.com, peterz@...radead.org, acme@...hat.com
Subject: [tip:perf/core] perf c2c: Use mem_info refcnt logic
Commit-ID: 5cedb413a63d452356aa634e0d4ffcc24f7dbcb5
Gitweb: https://git.kernel.org/tip/5cedb413a63d452356aa634e0d4ffcc24f7dbcb5
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Wed, 7 Mar 2018 16:50:07 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Thu, 8 Mar 2018 11:30:45 -0300
perf c2c: Use mem_info refcnt logic
Switch to refcnt logic instead of duplicating mem_info objects. No
functional change, just saving some memory.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20180307155020.32613-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-c2c.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 539c3d460158..98d243fa0c06 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -237,9 +237,12 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (mi == NULL)
return -ENOMEM;
- mi_dup = memdup(mi, sizeof(*mi));
- if (!mi_dup)
- goto free_mi;
+ /*
+ * The mi object is released in hists__add_entry_ops,
+ * if it gets sorted out into existing data, so we need
+ * to take the copy now.
+ */
+ mi_dup = mem_info__get(mi);
c2c_decode_stats(&stats, mi);
@@ -247,7 +250,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
&al, NULL, NULL, mi,
sample, true);
if (he == NULL)
- goto free_mi_dup;
+ goto free_mi;
c2c_he = container_of(he, struct c2c_hist_entry, he);
c2c_add_stats(&c2c_he->stats, &stats);
@@ -272,19 +275,15 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
mi = mi_dup;
- mi_dup = memdup(mi, sizeof(*mi));
- if (!mi_dup)
- goto free_mi;
-
c2c_hists = he__get_c2c_hists(he, c2c.cl_sort, 2);
if (!c2c_hists)
- goto free_mi_dup;
+ goto free_mi;
he = hists__add_entry_ops(&c2c_hists->hists, &c2c_entry_ops,
&al, NULL, NULL, mi,
sample, true);
if (he == NULL)
- goto free_mi_dup;
+ goto free_mi;
c2c_he = container_of(he, struct c2c_hist_entry, he);
c2c_add_stats(&c2c_he->stats, &stats);
@@ -303,10 +302,9 @@ out:
addr_location__put(&al);
return ret;
-free_mi_dup:
- free(mi_dup);
free_mi:
- free(mi);
+ mem_info__put(mi_dup);
+ mem_info__put(mi);
ret = -ENOMEM;
goto out;
}
Powered by blists - more mailing lists