Skip to content

Commit 480ca35

Browse files
Andi Kleenacmel
authored andcommitted
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 <[email protected]> Cc: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ Removed leftover bits from db-export.h ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 7114605 commit 480ca35

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

tools/perf/util/db-export.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,6 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym,
233233
return 0;
234234
}
235235

236-
static 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-
247236
static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
248237
u64 *dso_db_id, u64 *sym_db_id, u64 *offset)
249238
{
@@ -382,7 +371,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
382371
if (err)
383372
return err;
384373

385-
main_thread = get_main_thread(al->machine, thread);
374+
main_thread = thread__main_thread(al->machine, thread);
386375
if (main_thread)
387376
comm = machine__thread_exec_comm(al->machine, main_thread);
388377

tools/perf/util/thread.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,14 @@ void thread__find_cpumode_addr_location(struct thread *thread,
265265
break;
266266
}
267267
}
268+
269+
struct 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+
}

tools/perf/util/thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ void thread__insert_map(struct thread *thread, struct map *map);
8181
int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
8282
size_t thread__fprintf(struct thread *thread, FILE *fp);
8383

84+
struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
85+
8486
void thread__find_addr_map(struct thread *thread,
8587
u8 cpumode, enum map_type type, u64 addr,
8688
struct addr_location *al);

0 commit comments

Comments
 (0)