Commit 19207d86 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf db-export: Export main_thread in db_export__sample()

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: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190710085810.1650-5-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ed5c0a16
...@@ -71,17 +71,11 @@ int db_export__thread(struct db_export *dbe, struct thread *thread, ...@@ -71,17 +71,11 @@ int db_export__thread(struct db_export *dbe, struct thread *thread,
thread->db_id = ++dbe->thread_last_db_id; thread->db_id = ++dbe->thread_last_db_id;
if (main_thread) { if (main_thread) {
if (main_thread != thread) { if (main_thread != thread && comm) {
err = db_export__thread(dbe, main_thread, machine,
comm, main_thread);
if (err)
return err;
if (comm) {
err = db_export__comm_thread(dbe, comm, thread); err = db_export__comm_thread(dbe, comm, thread);
if (err) if (err)
return err; return err;
} }
}
main_thread_db_id = main_thread->db_id; main_thread_db_id = main_thread->db_id;
} }
...@@ -308,12 +302,24 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, ...@@ -308,12 +302,24 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
return err; return err;
main_thread = thread__main_thread(al->machine, thread); main_thread = thread__main_thread(al->machine, thread);
if (main_thread) if (main_thread) {
comm = machine__thread_exec_comm(al->machine, 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 (thread != main_thread) {
err = db_export__thread(dbe, thread, al->machine, comm,
main_thread);
if (err) if (err)
goto out_put; goto out_put;
}
if (comm) { if (comm) {
err = db_export__exec_comm(dbe, comm, main_thread); err = db_export__exec_comm(dbe, comm, main_thread);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment