aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evlist.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-13 10:20:11 +0900
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-13 10:20:11 +0900
commitade0899b298ba2c43bfd6abd8cbc2545944cde0c (patch)
treea448dfb440b3b958b6306bb43620cd5d76f504bf /tools/perf/util/evlist.c
parentperf: Handle new rbtree implementation (diff)
parentperf: Fix perf_cgroup_switch for sw-events (diff)
downloadlinux-dev-ade0899b298ba2c43bfd6abd8cbc2545944cde0c.tar.xz
linux-dev-ade0899b298ba2c43bfd6abd8cbc2545944cde0c.zip
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "This tree includes some late late perf items that missed the first round: tools: - Bash auto completion improvements, now we can auto complete the tools long options, tracepoint event names, etc, from Namhyung Kim. - Look up thread using tid instead of pid in 'perf sched'. - Move global variables into a perf_kvm struct, from David Ahern. - Hists refactorings, preparatory for improved 'diff' command, from Jiri Olsa. - Hists refactorings, preparatory for event group viewieng work, from Namhyung Kim. - Remove double negation on optional feature macro definitions, from Namhyung Kim. - Remove several cases of needless global variables, on most builtins. - misc fixes kernel: - sysfs support for IBS on AMD CPUs, from Robert Richter. - Support for an upcoming Intel CPU, the Xeon-Phi / Knights Corner HPC blade PMU, from Vince Weaver. - misc fixes" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits) perf: Fix perf_cgroup_switch for sw-events perf: Clarify perf_cpu_context::active_pmu usage by renaming it to ::unique_pmu perf/AMD/IBS: Add sysfs support perf hists: Add more helpers for hist entry stat perf hists: Move he->stat.nr_events initialization to a template perf hists: Introduce struct he_stat perf diff: Removing the total_period argument from output code perf tool: Add hpp interface to enable/disable hpp column perf tools: Removing hists pair argument from output path perf hists: Separate overhead and baseline columns perf diff: Refactor diff displacement possition info perf hists: Add struct hists pointer to struct hist_entry perf tools: Complete tracepoint event names perf/x86: Add support for Intel Xeon-Phi Knights Corner PMU perf evlist: Remove some unused methods perf evlist: Introduce add_newtp method perf kvm: Move global variables into a perf_kvm struct perf tools: Convert to BACKTRACE_SUPPORT perf tools: Long option completion support for each subcommands perf tools: Complete long option names of perf command ...
Diffstat (limited to 'tools/perf/util/evlist.c')
-rw-r--r--tools/perf/util/evlist.c88
1 files changed, 10 insertions, 78 deletions
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ae89686102f4..186b87730396 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -154,8 +154,8 @@ error:
return -ENOMEM;
}
-int perf_evlist__add_attrs(struct perf_evlist *evlist,
- struct perf_event_attr *attrs, size_t nr_attrs)
+static int perf_evlist__add_attrs(struct perf_evlist *evlist,
+ struct perf_event_attr *attrs, size_t nr_attrs)
{
struct perf_evsel *evsel, *n;
LIST_HEAD(head);
@@ -189,60 +189,6 @@ int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
return perf_evlist__add_attrs(evlist, attrs, nr_attrs);
}
-static int trace_event__id(const char *evname)
-{
- char *filename, *colon;
- int err = -1, fd;
-
- if (asprintf(&filename, "%s/%s/id", tracing_events_path, evname) < 0)
- return -1;
-
- colon = strrchr(filename, ':');
- if (colon != NULL)
- *colon = '/';
-
- fd = open(filename, O_RDONLY);
- if (fd >= 0) {
- char id[16];
- if (read(fd, id, sizeof(id)) > 0)
- err = atoi(id);
- close(fd);
- }
-
- free(filename);
- return err;
-}
-
-int perf_evlist__add_tracepoints(struct perf_evlist *evlist,
- const char *tracepoints[],
- size_t nr_tracepoints)
-{
- int err;
- size_t i;
- struct perf_event_attr *attrs = zalloc(nr_tracepoints * sizeof(*attrs));
-
- if (attrs == NULL)
- return -1;
-
- for (i = 0; i < nr_tracepoints; i++) {
- err = trace_event__id(tracepoints[i]);
-
- if (err < 0)
- goto out_free_attrs;
-
- attrs[i].type = PERF_TYPE_TRACEPOINT;
- attrs[i].config = err;
- attrs[i].sample_type = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
- PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD);
- attrs[i].sample_period = 1;
- }
-
- err = perf_evlist__add_attrs(evlist, attrs, nr_tracepoints);
-out_free_attrs:
- free(attrs);
- return err;
-}
-
struct perf_evsel *
perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id)
{
@@ -257,32 +203,18 @@ perf_evlist__find_tracepoint_by_id(struct perf_evlist *evlist, int id)
return NULL;
}
-int perf_evlist__set_tracepoints_handlers(struct perf_evlist *evlist,
- const struct perf_evsel_str_handler *assocs,
- size_t nr_assocs)
+int perf_evlist__add_newtp(struct perf_evlist *evlist,
+ const char *sys, const char *name, void *handler)
{
struct perf_evsel *evsel;
- int err;
- size_t i;
-
- for (i = 0; i < nr_assocs; i++) {
- err = trace_event__id(assocs[i].name);
- if (err < 0)
- goto out;
-
- evsel = perf_evlist__find_tracepoint_by_id(evlist, err);
- if (evsel == NULL)
- continue;
- err = -EEXIST;
- if (evsel->handler.func != NULL)
- goto out;
- evsel->handler.func = assocs[i].handler;
- }
+ evsel = perf_evsel__newtp(sys, name, evlist->nr_entries);
+ if (evsel == NULL)
+ return -1;
- err = 0;
-out:
- return err;
+ evsel->handler.func = handler;
+ perf_evlist__add(evlist, evsel);
+ return 0;
}
void perf_evlist__disable(struct perf_evlist *evlist)