diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2014-04-30 09:00:59 -0400 |
|---|---|---|
| committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-12 10:53:20 -0400 |
| commit | eba5102d2f0b4117edd089f2d882d9386025c829 (patch) | |
| tree | 2b00f1b26aa9c4f1d34f5f0b81baa8d3fc688f8d | |
| parent | 53fa8eaa093ad87eb59379de059e76d735a5de45 (diff) | |
perf tools: Add global list of opened dso objects
Adding global list of opened dso objects, so we can
track them and use the list for caching dso data file
descriptors.
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1401892622-30848-5-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
| -rw-r--r-- | tools/perf/util/dso.c | 41 | ||||
| -rw-r--r-- | tools/perf/util/dso.h | 1 |
2 files changed, 40 insertions, 2 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 5acb4b8b35d7..5d7c7bcc6276 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
| @@ -136,7 +136,22 @@ int dso__read_binary_type_filename(const struct dso *dso, | |||
| 136 | return ret; | 136 | return ret; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | static int open_dso(struct dso *dso, struct machine *machine) | 139 | /* |
| 140 | * Global list of open DSOs. | ||
| 141 | */ | ||
| 142 | static LIST_HEAD(dso__data_open); | ||
| 143 | |||
| 144 | static void dso__list_add(struct dso *dso) | ||
| 145 | { | ||
| 146 | list_add_tail(&dso->data.open_entry, &dso__data_open); | ||
| 147 | } | ||
| 148 | |||
| 149 | static void dso__list_del(struct dso *dso) | ||
| 150 | { | ||
| 151 | list_del(&dso->data.open_entry); | ||
| 152 | } | ||
| 153 | |||
| 154 | static int __open_dso(struct dso *dso, struct machine *machine) | ||
| 140 | { | 155 | { |
| 141 | int fd; | 156 | int fd; |
| 142 | char *root_dir = (char *)""; | 157 | char *root_dir = (char *)""; |
| @@ -159,14 +174,35 @@ static int open_dso(struct dso *dso, struct machine *machine) | |||
| 159 | return fd; | 174 | return fd; |
| 160 | } | 175 | } |
| 161 | 176 | ||
| 162 | void dso__data_close(struct dso *dso) | 177 | static int open_dso(struct dso *dso, struct machine *machine) |
| 178 | { | ||
| 179 | int fd = __open_dso(dso, machine); | ||
| 180 | |||
| 181 | if (fd > 0) | ||
| 182 | dso__list_add(dso); | ||
| 183 | |||
| 184 | return fd; | ||
| 185 | } | ||
| 186 | |||
| 187 | static void close_data_fd(struct dso *dso) | ||
| 163 | { | 188 | { |
| 164 | if (dso->data.fd >= 0) { | 189 | if (dso->data.fd >= 0) { |
| 165 | close(dso->data.fd); | 190 | close(dso->data.fd); |
| 166 | dso->data.fd = -1; | 191 | dso->data.fd = -1; |
| 192 | dso__list_del(dso); | ||
| 167 | } | 193 | } |
| 168 | } | 194 | } |
| 169 | 195 | ||
| 196 | static void close_dso(struct dso *dso) | ||
| 197 | { | ||
| 198 | close_data_fd(dso); | ||
| 199 | } | ||
| 200 | |||
| 201 | void dso__data_close(struct dso *dso) | ||
| 202 | { | ||
| 203 | close_dso(dso); | ||
| 204 | } | ||
| 205 | |||
| 170 | int dso__data_fd(struct dso *dso, struct machine *machine) | 206 | int dso__data_fd(struct dso *dso, struct machine *machine) |
| 171 | { | 207 | { |
| 172 | enum dso_binary_type binary_type_data[] = { | 208 | enum dso_binary_type binary_type_data[] = { |
| @@ -499,6 +535,7 @@ struct dso *dso__new(const char *name) | |||
| 499 | dso->kernel = DSO_TYPE_USER; | 535 | dso->kernel = DSO_TYPE_USER; |
| 500 | dso->needs_swap = DSO_SWAP__UNSET; | 536 | dso->needs_swap = DSO_SWAP__UNSET; |
| 501 | INIT_LIST_HEAD(&dso->node); | 537 | INIT_LIST_HEAD(&dso->node); |
| 538 | INIT_LIST_HEAD(&dso->data.open_entry); | ||
| 502 | } | 539 | } |
| 503 | 540 | ||
| 504 | return dso; | 541 | return dso; |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index e48dcf59b570..90988bf06641 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
| @@ -103,6 +103,7 @@ struct dso { | |||
| 103 | struct { | 103 | struct { |
| 104 | struct rb_root cache; | 104 | struct rb_root cache; |
| 105 | int fd; | 105 | int fd; |
| 106 | struct list_head open_entry; | ||
| 106 | } data; | 107 | } data; |
| 107 | 108 | ||
| 108 | char name[0]; | 109 | char name[0]; |
