summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2019-07-10 04:57:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-07-10 11:12:05 -0400
commit19207d86940db9dad5f2e0a270a2490f7da451e3 (patch)
tree03c2c6b83397d2a18fcf2627cd1246771ad36ea8 /tools/perf
parented5c0a16feb9f1a4347f109d5e9607f6f38688a0 (diff)
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: 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>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/db-export.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index 14501236c046..63f9edf65eee 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -71,16 +71,10 @@ int db_export__thread(struct db_export *dbe, struct thread *thread,
71 thread->db_id = ++dbe->thread_last_db_id; 71 thread->db_id = ++dbe->thread_last_db_id;
72 72
73 if (main_thread) { 73 if (main_thread) {
74 if (main_thread != thread) { 74 if (main_thread != thread && comm) {
75 err = db_export__thread(dbe, main_thread, machine, 75 err = db_export__comm_thread(dbe, comm, thread);
76 comm, main_thread);
77 if (err) 76 if (err)
78 return err; 77 return err;
79 if (comm) {
80 err = db_export__comm_thread(dbe, comm, thread);
81 if (err)
82 return err;
83 }
84 } 78 }
85 main_thread_db_id = main_thread->db_id; 79 main_thread_db_id = main_thread->db_id;
86 } 80 }
@@ -308,12 +302,24 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
308 return err; 302 return err;
309 303
310 main_thread = thread__main_thread(al->machine, thread); 304 main_thread = thread__main_thread(al->machine, thread);
311 if (main_thread) 305 if (main_thread) {
312 comm = machine__thread_exec_comm(al->machine, main_thread); 306 comm = machine__thread_exec_comm(al->machine, main_thread);
307 /*
308 * A thread has a reference to the main thread, so export the
309 * main thread first.
310 */
311 err = db_export__thread(dbe, main_thread, al->machine, comm,
312 main_thread);
313 if (err)
314 goto out_put;
315 }
313 316
314 err = db_export__thread(dbe, thread, al->machine, comm, main_thread); 317 if (thread != main_thread) {
315 if (err) 318 err = db_export__thread(dbe, thread, al->machine, comm,
316 goto out_put; 319 main_thread);
320 if (err)
321 goto out_put;
322 }
317 323
318 if (comm) { 324 if (comm) {
319 err = db_export__exec_comm(dbe, comm, main_thread); 325 err = db_export__exec_comm(dbe, comm, main_thread);