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>
This commit is contained in:
Arnaldo Carvalho de Melo
2010-07-30 18:28:42 -03:00
parent 0e60836bbd
commit 591765fdaf
5 changed files with 61 additions and 0 deletions

View File

@@ -228,6 +228,39 @@ void map_groups__init(struct map_groups *self)
self->machine = NULL;
}
static void maps__delete(struct rb_root *self)
{
struct rb_node *next = rb_first(self);
while (next) {
struct map *pos = rb_entry(next, struct map, rb_node);
next = rb_next(&pos->rb_node);
rb_erase(&pos->rb_node, self);
map__delete(pos);
}
}
static void maps__delete_removed(struct list_head *self)
{
struct map *pos, *n;
list_for_each_entry_safe(pos, n, self, node) {
list_del(&pos->node);
map__delete(pos);
}
}
void map_groups__exit(struct map_groups *self)
{
int i;
for (i = 0; i < MAP__NR_TYPES; ++i) {
maps__delete(&self->maps[i]);
maps__delete_removed(&self->removed_maps[i]);
}
}
void map_groups__flush(struct map_groups *self)
{
int type;