diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2019-07-10 04:58:00 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-07-10 11:13:51 -0400 |
commit | 80859c947a1eb170927d03e713abf7550a3d8766 (patch) | |
tree | 940bdd39f27541ec918f6a85d49e8a64475fb959 /tools | |
parent | 8534b5de81802a82b13fe05acc3e749e3baf980e (diff) |
perf db-export: Factor out db_export__comm()
In preparation for exporting the current comm for a thread, factor out
db_export__comm().
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190710085810.1650-12-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/db-export.c | 30 | ||||
-rw-r--r-- | tools/perf/util/db-export.h | 2 |
2 files changed, 25 insertions, 7 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index b0504d3eb130..b1e581c13963 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c | |||
@@ -78,6 +78,26 @@ int db_export__thread(struct db_export *dbe, struct thread *thread, | |||
78 | return 0; | 78 | return 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | static int __db_export__comm(struct db_export *dbe, struct comm *comm, | ||
82 | struct thread *thread) | ||
83 | { | ||
84 | comm->db_id = ++dbe->comm_last_db_id; | ||
85 | |||
86 | if (dbe->export_comm) | ||
87 | return dbe->export_comm(dbe, comm, thread); | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | int db_export__comm(struct db_export *dbe, struct comm *comm, | ||
93 | struct thread *thread) | ||
94 | { | ||
95 | if (comm->db_id) | ||
96 | return 0; | ||
97 | |||
98 | return __db_export__comm(dbe, comm, thread); | ||
99 | } | ||
100 | |||
81 | /* | 101 | /* |
82 | * Export the "exec" comm. The "exec" comm is the program / application command | 102 | * Export the "exec" comm. The "exec" comm is the program / application command |
83 | * name at the time it first executes. It is used to group threads for the same | 103 | * name at the time it first executes. It is used to group threads for the same |
@@ -92,13 +112,9 @@ int db_export__exec_comm(struct db_export *dbe, struct comm *comm, | |||
92 | if (comm->db_id) | 112 | if (comm->db_id) |
93 | return 0; | 113 | return 0; |
94 | 114 | ||
95 | comm->db_id = ++dbe->comm_last_db_id; | 115 | err = __db_export__comm(dbe, comm, main_thread); |
96 | 116 | if (err) | |
97 | if (dbe->export_comm) { | 117 | return err; |
98 | err = dbe->export_comm(dbe, comm, main_thread); | ||
99 | if (err) | ||
100 | return err; | ||
101 | } | ||
102 | 118 | ||
103 | /* | 119 | /* |
104 | * Record the main thread for this comm. Note that the main thread can | 120 | * Record the main thread for this comm. Note that the main thread can |
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h index 29f7c3b035a7..f5f0865f07e1 100644 --- a/tools/perf/util/db-export.h +++ b/tools/perf/util/db-export.h | |||
@@ -77,6 +77,8 @@ int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel); | |||
77 | int db_export__machine(struct db_export *dbe, struct machine *machine); | 77 | int db_export__machine(struct db_export *dbe, struct machine *machine); |
78 | int db_export__thread(struct db_export *dbe, struct thread *thread, | 78 | int db_export__thread(struct db_export *dbe, struct thread *thread, |
79 | struct machine *machine, struct thread *main_thread); | 79 | struct machine *machine, struct thread *main_thread); |
80 | int db_export__comm(struct db_export *dbe, struct comm *comm, | ||
81 | struct thread *thread); | ||
80 | int db_export__exec_comm(struct db_export *dbe, struct comm *comm, | 82 | int db_export__exec_comm(struct db_export *dbe, struct comm *comm, |
81 | struct thread *main_thread); | 83 | struct thread *main_thread); |
82 | int db_export__comm_thread(struct db_export *dbe, struct comm *comm, | 84 | int db_export__comm_thread(struct db_export *dbe, struct comm *comm, |