]> git.karo-electronics.de Git - linux-beck.git/commitdiff
perf evsel: Delete the event selectors at exit
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 3 Jan 2011 18:51:39 +0000 (16:51 -0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 3 Jan 2011 18:51:39 +0000 (16:51 -0200)
Freeing all the possibly allocated resources, reducing complexity
on each tool exit path.

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>
tools/perf/builtin-record.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/perf.c
tools/perf/util/parse-events.c
tools/perf/util/parse-events.h

index e68aee33bc1917b36e62537cf0d7f2c67c49cd2e..052de1780f766c26ae2b28524ce32ad29fbb2220 100644 (file)
@@ -965,8 +965,6 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
 out_free_event_array:
        free(event_array);
 out_free_fd:
-       list_for_each_entry(pos, &evsel_list, node)
-               perf_evsel__free_fd(pos);
        free(all_tids);
        all_tids = NULL;
 out_symbol_exit:
index 3e5f356a5241ca9fc414b4a2da4fcee4248f87c3..589ba3a92423a247943c5a5b78d10357c9567e81 100644 (file)
@@ -844,10 +844,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
        if (status != -1)
                print_stat(argc, argv);
 out_free_fd:
-       list_for_each_entry(pos, &evsel_list, node) {
-               perf_evsel__free_fd(pos);
+       list_for_each_entry(pos, &evsel_list, node)
                perf_evsel__free_stat_priv(pos);
-       }
 out:
        return status;
 }
index 13a836efa1e1e9ae7d64087b0a317d85874895e0..27b9c14a0a071e34c3573150d5fceaad0a58b94f 100644 (file)
@@ -1495,10 +1495,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
 
        status = __cmd_top();
 out_free_fd:
-       list_for_each_entry(pos, &evsel_list, node) {
-               perf_evsel__free_fd(pos);
+       list_for_each_entry(pos, &evsel_list, node)
                perf_evsel__free_mmap(pos);
-       }
 
        return status;
 }
index 595d0f4a7103eb45ccac7b5ad47fd3ebfee8ab0d..5b1ecd66bb36a053b6427020f9aa3361d4ec1265 100644 (file)
@@ -286,6 +286,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
        status = p->fn(argc, argv, prefix);
        exit_browser(status);
 
+       perf_evsel_list__delete();
+
        if (status)
                return status & 0xff;
 
index 2d948ad471f46ff2dadd3632984d3054c1ef713c..3a142e90d60937250c33b9bc7158d6465d7850cc 100644 (file)
@@ -982,3 +982,14 @@ int perf_evsel_list__create_default(void)
        ++nr_counters;
        return 0;
 }
+
+void perf_evsel_list__delete(void)
+{
+       struct perf_evsel *pos, *n;
+
+       list_for_each_entry_safe(pos, n, &evsel_list, node) {
+               list_del_init(&pos->node);
+               perf_evsel__delete(pos);
+       }
+       nr_counters = 0;
+}
index 0f915a01a3f732525a9e3f467971aa11dfe8eb45..0a0abc1d10eb2e838997ec69422fc74f76bb80c8 100644 (file)
@@ -12,6 +12,7 @@ struct perf_evsel;
 extern struct list_head evsel_list;
 
 int perf_evsel_list__create_default(void);
+void perf_evsel_list__delete(void);
 
 struct option;