diff options
author | Robert Richter <robert.richter@amd.com> | 2012-06-14 16:38:37 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-29 12:31:27 -0400 |
commit | 9bc8f9fe2c6e3778202c76ef85ef291567c00cb8 (patch) | |
tree | 26c483617ef9bbb10d352347df0d7fe1b80a0b20 | |
parent | 287e74aa3db097469bdca401f33f00ef20dc710d (diff) |
perf tools: Fix generation of pmu list
The internal pmu list was never used. With each perf_pmu__find() call
the pmu structure was created new by parsing sysfs. Beside this it
caused memory leaks. We now keep all pmus by adding them to the list.
Also, pmu_lookup() should return pmus that do not expose the format
specifier in sysfs.
We need a valid internal pmu list in a later patch to iterate over all
pmus that exist in the system.
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1339706321-8802-3-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/pmu.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 74d0948ec368..67715a42cd6d 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -72,7 +72,7 @@ static int pmu_format(char *name, struct list_head *format) | |||
72 | "%s/bus/event_source/devices/%s/format", sysfs, name); | 72 | "%s/bus/event_source/devices/%s/format", sysfs, name); |
73 | 73 | ||
74 | if (stat(path, &st) < 0) | 74 | if (stat(path, &st) < 0) |
75 | return -1; | 75 | return 0; /* no error if format does not exist */ |
76 | 76 | ||
77 | if (pmu_format_parse(path, format)) | 77 | if (pmu_format_parse(path, format)) |
78 | return -1; | 78 | return -1; |
@@ -252,6 +252,7 @@ static struct perf_pmu *pmu_lookup(char *name) | |||
252 | list_splice(&aliases, &pmu->aliases); | 252 | list_splice(&aliases, &pmu->aliases); |
253 | pmu->name = strdup(name); | 253 | pmu->name = strdup(name); |
254 | pmu->type = type; | 254 | pmu->type = type; |
255 | list_add_tail(&pmu->list, &pmus); | ||
255 | return pmu; | 256 | return pmu; |
256 | } | 257 | } |
257 | 258 | ||