Skip to content

Commit

Permalink
perf db-export: Factor out db_export__comm()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jul 10, 2019
1 parent 8534b5d commit 80859c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 23 additions & 7 deletions tools/perf/util/db-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@ int db_export__thread(struct db_export *dbe, struct thread *thread,
return 0;
}

static int __db_export__comm(struct db_export *dbe, struct comm *comm,
struct thread *thread)
{
comm->db_id = ++dbe->comm_last_db_id;

if (dbe->export_comm)
return dbe->export_comm(dbe, comm, thread);

return 0;
}

int db_export__comm(struct db_export *dbe, struct comm *comm,
struct thread *thread)
{
if (comm->db_id)
return 0;

return __db_export__comm(dbe, comm, thread);
}

/*
* Export the "exec" comm. The "exec" comm is the program / application command
* name at the time it first executes. It is used to group threads for the same
Expand All @@ -92,13 +112,9 @@ int db_export__exec_comm(struct db_export *dbe, struct comm *comm,
if (comm->db_id)
return 0;

comm->db_id = ++dbe->comm_last_db_id;

if (dbe->export_comm) {
err = dbe->export_comm(dbe, comm, main_thread);
if (err)
return err;
}
err = __db_export__comm(dbe, comm, main_thread);
if (err)
return err;

/*
* Record the main thread for this comm. Note that the main thread can
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/db-export.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel);
int db_export__machine(struct db_export *dbe, struct machine *machine);
int db_export__thread(struct db_export *dbe, struct thread *thread,
struct machine *machine, struct thread *main_thread);
int db_export__comm(struct db_export *dbe, struct comm *comm,
struct thread *thread);
int db_export__exec_comm(struct db_export *dbe, struct comm *comm,
struct thread *main_thread);
int db_export__comm_thread(struct db_export *dbe, struct comm *comm,
Expand Down

0 comments on commit 80859c9

Please sign in to comment.