diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2009-12-06 06:08:24 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-06 12:15:01 -0500 |
commit | 180f95e29aa8782c019caa64ede2a28d8ab62564 (patch) | |
tree | eefd1631820b00992f4495cc8cdba66a9155ee6c /tools/perf/builtin-sched.c | |
parent | 028c515253761084c6594bf9ac9b194b51d87065 (diff) |
perf: Make common SAMPLE_EVENT parser
Currently, sample event data is parsed for each commands, and it
is assuming that the data is not including other data. (E.g.
timechart, trace, etc. can't parse the event if it has
PERF_SAMPLE_CALLCHAIN)
So, even if we record the superset data for multiple commands at
a time, commands can't parse. etc.
To fix it, this makes common sample event parser, and use it to
parse sample event correctly. (PERF_SAMPLE_READ is unsupported
for now though, it seems to be not using.)
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <87hbs48imv.fsf@devron.myhome.or.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r-- | tools/perf/builtin-sched.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 26b782f26ee1..45c46c790493 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1598,40 +1598,26 @@ process_raw_event(event_t *raw_event __used, void *more_data, | |||
1598 | 1598 | ||
1599 | static int process_sample_event(event_t *event) | 1599 | static int process_sample_event(event_t *event) |
1600 | { | 1600 | { |
1601 | struct sample_data data; | ||
1601 | struct thread *thread; | 1602 | struct thread *thread; |
1602 | u64 ip = event->ip.ip; | ||
1603 | u64 timestamp = -1; | ||
1604 | u32 cpu = -1; | ||
1605 | u64 period = 1; | ||
1606 | void *more_data = event->ip.__more_data; | ||
1607 | 1603 | ||
1608 | if (!(sample_type & PERF_SAMPLE_RAW)) | 1604 | if (!(sample_type & PERF_SAMPLE_RAW)) |
1609 | return 0; | 1605 | return 0; |
1610 | 1606 | ||
1611 | thread = threads__findnew(event->ip.pid); | 1607 | memset(&data, 0, sizeof(data)); |
1608 | data.time = -1; | ||
1609 | data.cpu = -1; | ||
1610 | data.period = -1; | ||
1612 | 1611 | ||
1613 | if (sample_type & PERF_SAMPLE_TIME) { | 1612 | event__parse_sample(event, sample_type, &data); |
1614 | timestamp = *(u64 *)more_data; | ||
1615 | more_data += sizeof(u64); | ||
1616 | } | ||
1617 | |||
1618 | if (sample_type & PERF_SAMPLE_CPU) { | ||
1619 | cpu = *(u32 *)more_data; | ||
1620 | more_data += sizeof(u32); | ||
1621 | more_data += sizeof(u32); /* reserved */ | ||
1622 | } | ||
1623 | |||
1624 | if (sample_type & PERF_SAMPLE_PERIOD) { | ||
1625 | period = *(u64 *)more_data; | ||
1626 | more_data += sizeof(u64); | ||
1627 | } | ||
1628 | 1613 | ||
1629 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", | 1614 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
1630 | event->header.misc, | 1615 | event->header.misc, |
1631 | event->ip.pid, event->ip.tid, | 1616 | data.pid, data.tid, |
1632 | (void *)(long)ip, | 1617 | (void *)(long)data.ip, |
1633 | (long long)period); | 1618 | (long long)data.period); |
1634 | 1619 | ||
1620 | thread = threads__findnew(data.pid); | ||
1635 | if (thread == NULL) { | 1621 | if (thread == NULL) { |
1636 | pr_debug("problem processing %d event, skipping it.\n", | 1622 | pr_debug("problem processing %d event, skipping it.\n", |
1637 | event->header.type); | 1623 | event->header.type); |
@@ -1640,10 +1626,10 @@ static int process_sample_event(event_t *event) | |||
1640 | 1626 | ||
1641 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 1627 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
1642 | 1628 | ||
1643 | if (profile_cpu != -1 && profile_cpu != (int) cpu) | 1629 | if (profile_cpu != -1 && profile_cpu != (int)data.cpu) |
1644 | return 0; | 1630 | return 0; |
1645 | 1631 | ||
1646 | process_raw_event(event, more_data, cpu, timestamp, thread); | 1632 | process_raw_event(event, data.raw_data, data.cpu, data.time, thread); |
1647 | 1633 | ||
1648 | return 0; | 1634 | return 0; |
1649 | } | 1635 | } |