Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
480ca357 71146051

+14 -12
+1 -12
tools/perf/util/db-export.c
··· 233 233 return 0; 234 234 } 235 235 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 - 247 236 static int db_ids_from_al(struct db_export *dbe, struct addr_location *al, 248 237 u64 *dso_db_id, u64 *sym_db_id, u64 *offset) 249 238 { ··· 371 382 if (err) 372 383 return err; 373 384 374 - main_thread = get_main_thread(al->machine, thread); 385 + main_thread = thread__main_thread(al->machine, thread); 375 386 if (main_thread) 376 387 comm = machine__thread_exec_comm(al->machine, main_thread); 377 388
+11
tools/perf/util/thread.c
··· 265 265 break; 266 266 } 267 267 } 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 + }
+2
tools/perf/util/thread.h
··· 81 81 int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); 82 82 size_t thread__fprintf(struct thread *thread, FILE *fp); 83 83 84 + struct thread *thread__main_thread(struct machine *machine, struct thread *thread); 85 + 84 86 void thread__find_addr_map(struct thread *thread, 85 87 u8 cpumode, enum map_type type, u64 addr, 86 88 struct addr_location *al);