diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-07-30 17:28:42 -0400 | 
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-07-30 17:28:42 -0400 | 
| commit | 591765fdaf7ea1888157f342b67b0461f2e5ed9b (patch) | |
| tree | 278c5c7e219830596b03bc9ca1aa2a38e69e458e /tools/perf/util/map.c | |
| parent | 0e60836bbd392300198c5c2d918c18845428a1fe (diff) | |
perf tools: Release thread resources on PERF_RECORD_EXIT
For long running sessions with many threads with short lifetimes the
amount of memory that the buildid process takes is too much.
Since we don't have hist_entries that may be pointing to them, we can
just release the resources associated with each thread when the exit
(PERF_RECORD_EXIT) event is received.
For normal processing we need to annotate maps with hits, and thus
hist_entries pointing to it and drop the ones that had none. Will be
done in a followup patch.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/map.c')
| -rw-r--r-- | tools/perf/util/map.c | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 37cab9038538..2ddbae319de5 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
| @@ -228,6 +228,39 @@ void map_groups__init(struct map_groups *self) | |||
| 228 | self->machine = NULL; | 228 | self->machine = NULL; | 
| 229 | } | 229 | } | 
| 230 | 230 | ||
| 231 | static void maps__delete(struct rb_root *self) | ||
| 232 | { | ||
| 233 | struct rb_node *next = rb_first(self); | ||
| 234 | |||
| 235 | while (next) { | ||
| 236 | struct map *pos = rb_entry(next, struct map, rb_node); | ||
| 237 | |||
| 238 | next = rb_next(&pos->rb_node); | ||
| 239 | rb_erase(&pos->rb_node, self); | ||
| 240 | map__delete(pos); | ||
| 241 | } | ||
| 242 | } | ||
| 243 | |||
| 244 | static void maps__delete_removed(struct list_head *self) | ||
| 245 | { | ||
| 246 | struct map *pos, *n; | ||
| 247 | |||
| 248 | list_for_each_entry_safe(pos, n, self, node) { | ||
| 249 | list_del(&pos->node); | ||
| 250 | map__delete(pos); | ||
| 251 | } | ||
| 252 | } | ||
| 253 | |||
| 254 | void map_groups__exit(struct map_groups *self) | ||
| 255 | { | ||
| 256 | int i; | ||
| 257 | |||
| 258 | for (i = 0; i < MAP__NR_TYPES; ++i) { | ||
| 259 | maps__delete(&self->maps[i]); | ||
| 260 | maps__delete_removed(&self->removed_maps[i]); | ||
| 261 | } | ||
| 262 | } | ||
| 263 | |||
| 231 | void map_groups__flush(struct map_groups *self) | 264 | void map_groups__flush(struct map_groups *self) | 
| 232 | { | 265 | { | 
| 233 | int type; | 266 | int type; | 
