linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	linux-kernel@vger.kernel.org, tglx@linutronix.de,
	dsahern@gmail.com, mingo@kernel.org, namhyung@kernel.org,
	hpa@zytor.com, peterz@infradead.org, acme@redhat.com
Subject: [tip:perf/core] perf c2c: Use mem_info refcnt logic
Date: Fri, 9 Mar 2018 00:54:22 -0800	[thread overview]
Message-ID: <tip-5cedb413a63d452356aa634e0d4ffcc24f7dbcb5@git.kernel.org> (raw)
In-Reply-To: <20180307155020.32613-7-jolsa@kernel.org>

Commit-ID:  5cedb413a63d452356aa634e0d4ffcc24f7dbcb5
Gitweb:     https://git.kernel.org/tip/5cedb413a63d452356aa634e0d4ffcc24f7dbcb5
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 7 Mar 2018 16:50:07 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.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@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180307155020.32613-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.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;
 }

  reply	other threads:[~2018-03-09  8:54 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 15:50 [PATCH 00/19] perf tools: Assorted fixes Jiri Olsa
2018-03-07 15:50 ` [PATCH 01/19] perf report: Fix the output for stdio events list Jiri Olsa
2018-03-09  8:51   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 02/19] perf report: Display perf.data header info Jiri Olsa
2018-03-09  8:52   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 03/19] perf record: Move machine variable down the function Jiri Olsa
2018-03-09  8:52   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 04/19] perf record: Remove progname from struct record Jiri Olsa
2018-03-09  8:53   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 05/19] perf tools: Add refcnt into struct mem_info Jiri Olsa
2018-03-07 18:56   ` Arnaldo Carvalho de Melo
2018-03-08 10:59     ` Jiri Olsa
2018-03-09  8:53   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 06/19] perf c2c: Use mem_info refcnt logic Jiri Olsa
2018-03-09  8:54   ` tip-bot for Jiri Olsa [this message]
2018-03-07 15:50 ` [PATCH 07/19] perf tools: Add MEM_TOPOLOGY feature to perf data file Jiri Olsa
2018-03-07 19:28   ` Arnaldo Carvalho de Melo
2018-03-09  8:54   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 08/19] perf tools: Add mem2node object Jiri Olsa
2018-03-07 19:27   ` Arnaldo Carvalho de Melo
2018-03-08 11:03     ` Jiri Olsa
2018-03-08 12:58       ` Arnaldo Carvalho de Melo
2018-03-08 13:00         ` Arnaldo Carvalho de Melo
2018-03-08 13:18         ` Jiri Olsa
2018-03-07 15:50 ` [PATCH 09/19] perf tests: Add mem2node object test Jiri Olsa
2018-03-07 15:50 ` [PATCH 10/19] perf c2c record: Record physical addresses in samples Jiri Olsa
2018-03-07 15:50 ` [PATCH 11/19] perf c2c report: Make calc_width work with struct c2c_hist_entry Jiri Olsa
2018-03-07 15:50 ` [PATCH 12/19] perf c2c report: Call calc_width only for displayed entries Jiri Olsa
2018-03-07 15:50 ` [PATCH 13/19] perf c2c report: Display node for cacheline address Jiri Olsa
2018-03-07 15:50 ` [PATCH 14/19] perf c2c report: Add span header over cacheline data Jiri Olsa
2018-03-07 15:50 ` [PATCH 15/19] perf c2c report: Add cacheline address count column Jiri Olsa
2018-03-07 15:50 ` [PATCH 16/19] perf tools: Update tags with .cpp files Jiri Olsa
2018-03-07 19:28   ` Arnaldo Carvalho de Melo
2018-03-09  8:55   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 17/19] perf build: Add llvm/clang/cxx make tests into FEATURE_TESTS_EXTRA Jiri Olsa
2018-03-09  8:55   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 18/19] perf build: Add llvm/clang make targets to FILES Jiri Olsa
2018-03-09  8:56   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-03-07 15:50 ` [PATCH 19/19] perf build: Force llvm/clang test compile output to .make.output Jiri Olsa
2018-03-07 19:30   ` Arnaldo Carvalho de Melo
2018-03-09  8:56   ` [tip:perf/core] " tip-bot for Jiri Olsa

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=tip-5cedb413a63d452356aa634e0d4ffcc24f7dbcb5@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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 NNTP newsgroup(s).