Skip to content

Commit

Permalink
perf db-export: Export main_thread in db_export__sample()
Browse files Browse the repository at this point in the history
Export main_thread in db_export__sample() because it makes the code
easier to understand, and prepares db_export__thread() for further
simplification.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190710085810.1650-5-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jul 10, 2019
1 parent ed5c0a1 commit 19207d8
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tools/perf/util/db-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,10 @@ int db_export__thread(struct db_export *dbe, struct thread *thread,
thread->db_id = ++dbe->thread_last_db_id;

if (main_thread) {
if (main_thread != thread) {
err = db_export__thread(dbe, main_thread, machine,
comm, main_thread);
if (main_thread != thread && comm) {
err = db_export__comm_thread(dbe, comm, thread);
if (err)
return err;
if (comm) {
err = db_export__comm_thread(dbe, comm, thread);
if (err)
return err;
}
}
main_thread_db_id = main_thread->db_id;
}
Expand Down Expand Up @@ -308,12 +302,24 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
return err;

main_thread = thread__main_thread(al->machine, thread);
if (main_thread)
if (main_thread) {
comm = machine__thread_exec_comm(al->machine, main_thread);
/*
* A thread has a reference to the main thread, so export the
* main thread first.
*/
err = db_export__thread(dbe, main_thread, al->machine, comm,
main_thread);
if (err)
goto out_put;
}

err = db_export__thread(dbe, thread, al->machine, comm, main_thread);
if (err)
goto out_put;
if (thread != main_thread) {
err = db_export__thread(dbe, thread, al->machine, comm,
main_thread);
if (err)
goto out_put;
}

if (comm) {
err = db_export__exec_comm(dbe, comm, main_thread);
Expand Down

0 comments on commit 19207d8

Please sign in to comment.