diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
commit | da3789628f88684d3f0fb4e6a6bc086c395ac3cb (patch) | |
tree | f1573d6b2c8fa4e46f47c5558135a0a56d4397ef /tools/perf/builtin-sched.c | |
parent | 7a25b2d32b9cb0b813d56ee6109acf90f3c9f1e5 (diff) |
perf tools: Stop using a global trace events description list
The pevent thing is per perf.data file, so I made it stop being static
and become a perf_session member, so tools processing perf.data files
use perf_session and _there_ we read the trace events description into
session->pevent and then change everywhere to stop using that single
global pevent variable and use the per session one.
Note that it _doesn't_ fall backs to trace__event_id, as we're not
interested at all in what is present in the
/sys/kernel/debug/tracing/events in the workstation doing the analysis,
just in what is in the perf.data file.
This patch also introduces perf_session__set_tracepoints_handlers that
is the perf perf.data/session way to associate handlers to tracepoint
events by resolving their IDs using the events descriptions stored in a
perf.data file. Make 'perf sched' use it.
Reported-by: Dmitry Antipov <dmitry.antipov@linaro.org>
Tested-by: Dmitry Antipov <dmitry.antipov@linaro.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linaro-dev@lists.linaro.org
Cc: patches@linaro.org
Link: http://lkml.kernel.org/r/20120625232016.GA28525@infradead.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r-- | tools/perf/builtin-sched.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 9fe77b185338..7a9ad2b1ee76 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -43,6 +43,11 @@ static u64 sleep_measurement_overhead; | |||
43 | 43 | ||
44 | static unsigned long nr_tasks; | 44 | static unsigned long nr_tasks; |
45 | 45 | ||
46 | struct perf_sched { | ||
47 | struct perf_tool tool; | ||
48 | struct perf_session *session; | ||
49 | }; | ||
50 | |||
46 | struct sched_atom; | 51 | struct sched_atom; |
47 | 52 | ||
48 | struct task_desc { | 53 | struct task_desc { |
@@ -1597,6 +1602,8 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool, | |||
1597 | struct perf_evsel *evsel, | 1602 | struct perf_evsel *evsel, |
1598 | struct machine *machine) | 1603 | struct machine *machine) |
1599 | { | 1604 | { |
1605 | struct perf_sched *sched = container_of(tool, struct perf_sched, tool); | ||
1606 | struct pevent *pevent = sched->session->pevent; | ||
1600 | struct thread *thread = machine__findnew_thread(machine, sample->pid); | 1607 | struct thread *thread = machine__findnew_thread(machine, sample->pid); |
1601 | 1608 | ||
1602 | if (thread == NULL) { | 1609 | if (thread == NULL) { |
@@ -1612,7 +1619,8 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool, | |||
1612 | tracepoint_handler f = evsel->handler.func; | 1619 | tracepoint_handler f = evsel->handler.func; |
1613 | 1620 | ||
1614 | if (evsel->handler.data == NULL) | 1621 | if (evsel->handler.data == NULL) |
1615 | evsel->handler.data = trace_find_event(evsel->attr.config); | 1622 | evsel->handler.data = pevent_find_event(pevent, |
1623 | evsel->attr.config); | ||
1616 | 1624 | ||
1617 | f(tool, evsel->handler.data, sample, machine, thread); | 1625 | f(tool, evsel->handler.data, sample, machine, thread); |
1618 | } | 1626 | } |
@@ -1620,12 +1628,14 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool, | |||
1620 | return 0; | 1628 | return 0; |
1621 | } | 1629 | } |
1622 | 1630 | ||
1623 | static struct perf_tool perf_sched = { | 1631 | static struct perf_sched perf_sched = { |
1624 | .sample = perf_sched__process_tracepoint_sample, | 1632 | .tool = { |
1625 | .comm = perf_event__process_comm, | 1633 | .sample = perf_sched__process_tracepoint_sample, |
1626 | .lost = perf_event__process_lost, | 1634 | .comm = perf_event__process_comm, |
1627 | .fork = perf_event__process_task, | 1635 | .lost = perf_event__process_lost, |
1628 | .ordered_samples = true, | 1636 | .fork = perf_event__process_task, |
1637 | .ordered_samples = true, | ||
1638 | }, | ||
1629 | }; | 1639 | }; |
1630 | 1640 | ||
1631 | static void read_events(bool destroy, struct perf_session **psession) | 1641 | static void read_events(bool destroy, struct perf_session **psession) |
@@ -1640,16 +1650,20 @@ static void read_events(bool destroy, struct perf_session **psession) | |||
1640 | { "sched:sched_process_exit", process_sched_exit_event, }, | 1650 | { "sched:sched_process_exit", process_sched_exit_event, }, |
1641 | { "sched:sched_migrate_task", process_sched_migrate_task_event, }, | 1651 | { "sched:sched_migrate_task", process_sched_migrate_task_event, }, |
1642 | }; | 1652 | }; |
1643 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, | 1653 | struct perf_session *session; |
1644 | 0, false, &perf_sched); | 1654 | |
1655 | session = perf_session__new(input_name, O_RDONLY, 0, false, | ||
1656 | &perf_sched.tool); | ||
1645 | if (session == NULL) | 1657 | if (session == NULL) |
1646 | die("No Memory"); | 1658 | die("No Memory"); |
1647 | 1659 | ||
1648 | err = perf_evlist__set_tracepoints_handlers_array(session->evlist, handlers); | 1660 | perf_sched.session = session; |
1661 | |||
1662 | err = perf_session__set_tracepoints_handlers(session, handlers); | ||
1649 | assert(err == 0); | 1663 | assert(err == 0); |
1650 | 1664 | ||
1651 | if (perf_session__has_traces(session, "record -R")) { | 1665 | if (perf_session__has_traces(session, "record -R")) { |
1652 | err = perf_session__process_events(session, &perf_sched); | 1666 | err = perf_session__process_events(session, &perf_sched.tool); |
1653 | if (err) | 1667 | if (err) |
1654 | die("Failed to process events, error %d", err); | 1668 | die("Failed to process events, error %d", err); |
1655 | 1669 | ||