From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbcFBGbN (ORCPT ); Thu, 2 Jun 2016 02:31:13 -0400 Received: from terminus.zytor.com ([198.137.202.10]:55712 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750754AbcFBGbL (ORCPT ); Thu, 2 Jun 2016 02:31:11 -0400 Date: Wed, 1 Jun 2016 23:30:56 -0700 From: tip-bot for Andi Kleen Message-ID: Cc: linux-kernel@vger.kernel.org, ak@linux.intel.com, hpa@zytor.com, acme@redhat.com, jolsa@kernel.org, mingo@kernel.org, tglx@linutronix.de Reply-To: ak@linux.intel.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, acme@redhat.com, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <1464051145-19968-2-git-send-email-andi@firstfloor.org> References: <1464051145-19968-2-git-send-email-andi@firstfloor.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf thread: Adopt get_main_thread from db-export.c Git-Commit-ID: 480ca357fd7f86a381a5b35a8157aa176eddbed4 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: 480ca357fd7f86a381a5b35a8157aa176eddbed4 Gitweb: http://git.kernel.org/tip/480ca357fd7f86a381a5b35a8157aa176eddbed4 Author: Andi Kleen AuthorDate: Mon, 23 May 2016 17:52:24 -0700 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 30 May 2016 12:41:43 -0300 perf thread: Adopt get_main_thread from db-export.c Move the get_main_thread function from db-export.c to thread.c so that it can be used elsewhere. Signed-off-by: Andi Kleen Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1464051145-19968-2-git-send-email-andi@firstfloor.org [ Removed leftover bits from db-export.h ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/db-export.c | 13 +------------ tools/perf/util/thread.c | 11 +++++++++++ tools/perf/util/thread.h | 2 ++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index c9a6dc1..b0c2b5c 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c @@ -233,17 +233,6 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym, return 0; } -static struct thread *get_main_thread(struct machine *machine, struct thread *thread) -{ - if (thread->pid_ == thread->tid) - return thread__get(thread); - - if (thread->pid_ == -1) - return NULL; - - return machine__find_thread(machine, thread->pid_, thread->pid_); -} - static int db_ids_from_al(struct db_export *dbe, struct addr_location *al, u64 *dso_db_id, u64 *sym_db_id, u64 *offset) { @@ -382,7 +371,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, if (err) return err; - main_thread = get_main_thread(al->machine, thread); + main_thread = thread__main_thread(al->machine, thread); if (main_thread) comm = machine__thread_exec_comm(al->machine, main_thread); diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 45fcb71..ada58e6 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -265,3 +265,14 @@ void thread__find_cpumode_addr_location(struct thread *thread, break; } } + +struct thread *thread__main_thread(struct machine *machine, struct thread *thread) +{ + if (thread->pid_ == thread->tid) + return thread__get(thread); + + if (thread->pid_ == -1) + return NULL; + + return machine__find_thread(machine, thread->pid_, thread->pid_); +} diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 45fba13..08fcb14 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -81,6 +81,8 @@ void thread__insert_map(struct thread *thread, struct map *map); int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); size_t thread__fprintf(struct thread *thread, FILE *fp); +struct thread *thread__main_thread(struct machine *machine, struct thread *thread); + void thread__find_addr_map(struct thread *thread, u8 cpumode, enum map_type type, u64 addr, struct addr_location *al);