From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756870AbbE2SgK (ORCPT ); Fri, 29 May 2015 14:36:10 -0400 Received: from terminus.zytor.com ([198.137.202.10]:35131 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756542AbbE2SgH (ORCPT ); Fri, 29 May 2015 14:36:07 -0400 Date: Fri, 29 May 2015 11:35:41 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: jolsa@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, acme@redhat.com, hpa@zytor.com, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@redhat.com, hpa@zytor.com, adrian.hunter@intel.com, acme@redhat.com, mingo@kernel.org In-Reply-To: <1432906425-9911-2-git-send-email-adrian.hunter@intel.com> References: <1432906425-9911-2-git-send-email-adrian.hunter@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf db-export: Fix thread ref-counting Git-Commit-ID: 427cde3287f2c6349f308d0e22c9223f9ea05ef1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 427cde3287f2c6349f308d0e22c9223f9ea05ef1 Gitweb: http://git.kernel.org/tip/427cde3287f2c6349f308d0e22c9223f9ea05ef1 Author: Adrian Hunter AuthorDate: Fri, 29 May 2015 16:33:29 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 29 May 2015 12:43:39 -0300 perf db-export: Fix thread ref-counting 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 Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1432906425-9911-2-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- 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 eb7a2ac..1c9689e 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 {