aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2016-05-23 20:52:24 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-05-30 11:41:43 -0400
commit480ca357fd7f86a381a5b35a8157aa176eddbed4 (patch)
treebd17401551a8cec3f0ebd7a496b298742865492b
parent711460514b1c80494f14001bdf30dd70fd401a8f (diff)
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 <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>
-rw-r--r--tools/perf/util/db-export.c13
-rw-r--r--tools/perf/util/thread.c11
-rw-r--r--tools/perf/util/thread.h2
3 files changed, 14 insertions, 12 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index c9a6dc173e74..b0c2b5c5d337 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,
233 return 0; 233 return 0;
234} 234}
235 235
236static struct thread *get_main_thread(struct machine *machine, struct thread *thread)
237{
238 if (thread->pid_ == thread->tid)
239 return thread__get(thread);
240
241 if (thread->pid_ == -1)
242 return NULL;
243
244 return machine__find_thread(machine, thread->pid_, thread->pid_);
245}
246
247static int db_ids_from_al(struct db_export *dbe, struct addr_location *al, 236static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
248 u64 *dso_db_id, u64 *sym_db_id, u64 *offset) 237 u64 *dso_db_id, u64 *sym_db_id, u64 *offset)
249{ 238{
@@ -382,7 +371,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
382 if (err) 371 if (err)
383 return err; 372 return err;
384 373
385 main_thread = get_main_thread(al->machine, thread); 374 main_thread = thread__main_thread(al->machine, thread);
386 if (main_thread) 375 if (main_thread)
387 comm = machine__thread_exec_comm(al->machine, main_thread); 376 comm = machine__thread_exec_comm(al->machine, main_thread);
388 377
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,
265 break; 265 break;
266 } 266 }
267} 267}
268
269struct thread *thread__main_thread(struct machine *machine, struct thread *thread)
270{
271 if (thread->pid_ == thread->tid)
272 return thread__get(thread);
273
274 if (thread->pid_ == -1)
275 return NULL;
276
277 return machine__find_thread(machine, thread->pid_, thread->pid_);
278}
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);
81int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); 81int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
82size_t thread__fprintf(struct thread *thread, FILE *fp); 82size_t thread__fprintf(struct thread *thread, FILE *fp);
83 83
84struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
85
84void thread__find_addr_map(struct thread *thread, 86void thread__find_addr_map(struct thread *thread,
85 u8 cpumode, enum map_type type, u64 addr, 87 u8 cpumode, enum map_type type, u64 addr,
86 struct addr_location *al); 88 struct addr_location *al);