linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/14] perf db-export: Fix thread ref-counting
Date: Fri, 29 May 2015 13:30:13 -0300	[thread overview]
Message-ID: <1432917024-3899-4-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1432917024-3899-1-git-send-email-acme@kernel.org>

From: Adrian Hunter <adrian.hunter@intel.com>

Thread ref-counting was not done for get_main_thread() meaning that
there was a thread__get() from machine__find_thread() that was not being
paired with thread__put(). Fix that.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1432906425-9911-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/db-export.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index eb7a2acb973b..1c9689e4cc17 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -234,7 +234,7 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym,
 static struct thread *get_main_thread(struct machine *machine, struct thread *thread)
 {
 	if (thread->pid_ == thread->tid)
-		return thread;
+		return thread__get(thread);
 
 	if (thread->pid_ == -1)
 		return NULL;
@@ -308,19 +308,18 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
 	if (err)
 		return err;
 
-	/* FIXME: check refcounting for get_main_thread, that calls machine__find_thread... */
 	main_thread = get_main_thread(al->machine, thread);
 	if (main_thread)
 		comm = machine__thread_exec_comm(al->machine, main_thread);
 
 	err = db_export__thread(dbe, thread, al->machine, comm);
 	if (err)
-		return err;
+		goto out_put;
 
 	if (comm) {
 		err = db_export__comm(dbe, comm, main_thread);
 		if (err)
-			return err;
+			goto out_put;
 		es.comm_db_id = comm->db_id;
 	}
 
@@ -328,7 +327,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
 
 	err = db_ids_from_al(dbe, al, &es.dso_db_id, &es.sym_db_id, &es.offset);
 	if (err)
-		return err;
+		goto out_put;
 
 	if ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
 	    sample_addr_correlates_sym(&evsel->attr)) {
@@ -338,20 +337,22 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
 		err = db_ids_from_al(dbe, &addr_al, &es.addr_dso_db_id,
 				     &es.addr_sym_db_id, &es.addr_offset);
 		if (err)
-			return err;
+			goto out_put;
 		if (dbe->crp) {
 			err = thread_stack__process(thread, comm, sample, al,
 						    &addr_al, es.db_id,
 						    dbe->crp);
 			if (err)
-				return err;
+				goto out_put;
 		}
 	}
 
 	if (dbe->export_sample)
-		return dbe->export_sample(dbe, &es);
+		err = dbe->export_sample(dbe, &es);
 
-	return 0;
+out_put:
+	thread__put(main_thread);
+	return err;
 }
 
 static struct {
-- 
2.1.0


  parent reply	other threads:[~2015-05-29 16:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29 16:30 [GIT PULL 00/14] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 01/14] perf annotate: Fix -i option, which is currently ignored Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 02/14] perf probe: Fix 'function unused' warning Arnaldo Carvalho de Melo
2015-05-29 16:30 ` Arnaldo Carvalho de Melo [this message]
2015-05-29 16:30 ` [PATCH 04/14] perf kmem: Fix compiler warning about may be accessing uninitialized variable Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 05/14] perf tools: Add ARM64 perf_regs_load to support libunwind and enable testing Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 06/14] perf tests: Switch from open to openat Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 07/14] perf tests: Aename open*.c to openat*.c Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 08/14] perf tests: Remove getpgrp from mmap-basic Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 09/14] perf machine: Adopt findnew_kernel method Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 10/14] perf machine: No need to have two DSOs lists Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 11/14] perf machine: Introduce machine__findnew_dso() method Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 12/14] perf machine: Fix up vdso methods names Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 13/14] perf build: Do not fail on missing Build file Arnaldo Carvalho de Melo
2015-05-29 16:30 ` [PATCH 14/14] perf tools: Make Ctrl-C stop processing on TUI Arnaldo Carvalho de Melo
2015-05-29 18:20 ` [GIT PULL 00/14] perf/core improvements and fixes Ingo Molnar

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=1432917024-3899-4-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /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).