perf thread: Adopt get_main_thread from db-export.c
authorAndi Kleen <ak@linux.intel.com>
Tue, 24 May 2016 00:52:24 +0000 (17:52 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 30 May 2016 15:41:43 +0000 (12:41 -0300)
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 <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
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 <acme@redhat.com>
tools/perf/util/db-export.c
tools/perf/util/thread.c
tools/perf/util/thread.h

index c9a6dc173e74eb77f56673c6a609a5a92c788498..b0c2b5c5d3375fc919f24f92a9e4b7eba11c084d 100644 (file)
@@ -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);
 
index 45fcb715a36b3f6a975600d41eb877b387b78417..ada58e6070bfb66a0f8770196cdba275e9d03a6f 100644 (file)
@@ -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_);
+}
index 45fba13c800bd36150248d4ade2b9f0b4b053329..08fcb14cf637132ad8dd88240dcfec223ca560fa 100644 (file)
@@ -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);