From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756180AbcEXO4T (ORCPT ); Tue, 24 May 2016 10:56:19 -0400 Received: from mail.kernel.org ([198.145.29.136]:44392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752692AbcEXO4Q (ORCPT ); Tue, 24 May 2016 10:56:16 -0400 Date: Tue, 24 May 2016 11:56:11 -0300 From: Arnaldo Carvalho de Melo To: Andi Kleen Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH 2/3] perf util: Move get_main_thread to thread.c Message-ID: <20160524145611.GS8897@kernel.org> References: <1464051145-19968-1-git-send-email-andi@firstfloor.org> <1464051145-19968-2-git-send-email-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464051145-19968-2-git-send-email-andi@firstfloor.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, May 23, 2016 at 05:52:24PM -0700, Andi Kleen escreveu: > From: Andi Kleen > > Move the get_main_thread function from db-export.c to thread.c > so that it can be used elsewhere. After removing the db-export.h leftover junk, applied. - Arnaldo > Signed-off-by: Andi Kleen > --- > tools/perf/util/db-export.c | 13 +------------ > tools/perf/util/db-export.h | 2 ++ > tools/perf/util/thread.c | 11 +++++++++++ > tools/perf/util/thread.h | 2 ++ > 4 files changed, 16 insertions(+), 12 deletions(-) > > diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c > index 8d96c80cc67e..0fb0aeb0b09b 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) > { > @@ -383,7 +372,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/db-export.h b/tools/perf/util/db-export.h > index 67bc6b8ad2d6..1241e5773e13 100644 > --- a/tools/perf/util/db-export.h > +++ b/tools/perf/util/db-export.h > @@ -106,4 +106,6 @@ int db_export__branch_types(struct db_export *dbe); > int db_export__call_path(struct db_export *dbe, struct call_path *cp); > int db_export__call_return(struct db_export *dbe, struct call_return *cr); > > +struct thread *db_export__main_thread(struct machine *machine, struct thread *thread); > + > #endif > diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c > index 45fcb715a36b..ada58e6070bf 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 45fba13c800b..08fcb14cf637 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); > -- > 2.5.5