aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-sched.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-27 13:29:22 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-27 14:22:01 -0500
commit62daacb51a2bf8480e6f6b3696b03f102fc15eb0 (patch)
tree5b9ed87005a5e59bcc95dd9a42e3d09d6481362d /tools/perf/builtin-sched.c
parent1de8e24520ffdcf2a90c842eed937f59079a2abd (diff)
perf tools: Reorganize event processing routines, lotsa dups killed
While implementing event__preprocess_sample, that will do all of the symbol lookup in one convenient function, I noticed that util/process_event.[ch] were not being used at all, then started looking if there were other functions that could be shared and... All those functions really don't need to receive offset + head, the only thing they did was common to all of them, so do it at one place instead. Stats about number of each type of event processed now is done in a central place. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: John Kacur <jkacur@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1259346563-12568-11-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r--tools/perf/builtin-sched.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 19eb708a706b..26b782f26ee1 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -22,8 +22,6 @@
22 22
23static char const *input_name = "perf.data"; 23static char const *input_name = "perf.data";
24 24
25static unsigned long total_comm = 0;
26
27static struct perf_header *header; 25static struct perf_header *header;
28static u64 sample_type; 26static u64 sample_type;
29 27
@@ -32,9 +30,6 @@ static char *sort_order = default_sort_order;
32 30
33static int profile_cpu = -1; 31static int profile_cpu = -1;
34 32
35static char *cwd;
36static int cwdlen;
37
38#define PR_SET_NAME 15 /* Set process name */ 33#define PR_SET_NAME 15 /* Set process name */
39#define MAX_CPUS 4096 34#define MAX_CPUS 4096
40 35
@@ -633,27 +628,6 @@ static void test_calibrations(void)
633 printf("the sleep test took %Ld nsecs\n", T1-T0); 628 printf("the sleep test took %Ld nsecs\n", T1-T0);
634} 629}
635 630
636static int
637process_comm_event(event_t *event, unsigned long offset, unsigned long head)
638{
639 struct thread *thread = threads__findnew(event->comm.tid);
640
641 dump_printf("%p [%p]: perf_event_comm: %s:%d\n",
642 (void *)(offset + head),
643 (void *)(long)(event->header.size),
644 event->comm.comm, event->comm.pid);
645
646 if (thread == NULL ||
647 thread__set_comm(thread, event->comm.comm)) {
648 dump_printf("problem processing perf_event_comm, skipping event.\n");
649 return -1;
650 }
651 total_comm++;
652
653 return 0;
654}
655
656
657struct raw_event_sample { 631struct raw_event_sample {
658 u32 size; 632 u32 size;
659 char data[0]; 633 char data[0];
@@ -1622,8 +1596,7 @@ process_raw_event(event_t *raw_event __used, void *more_data,
1622 process_sched_migrate_task_event(raw, event, cpu, timestamp, thread); 1596 process_sched_migrate_task_event(raw, event, cpu, timestamp, thread);
1623} 1597}
1624 1598
1625static int 1599static int process_sample_event(event_t *event)
1626process_sample_event(event_t *event, unsigned long offset, unsigned long head)
1627{ 1600{
1628 struct thread *thread; 1601 struct thread *thread;
1629 u64 ip = event->ip.ip; 1602 u64 ip = event->ip.ip;
@@ -1653,9 +1626,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
1653 more_data += sizeof(u64); 1626 more_data += sizeof(u64);
1654 } 1627 }
1655 1628
1656 dump_printf("%p [%p]: PERF_RECORD_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n", 1629 dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
1657 (void *)(offset + head),
1658 (void *)(long)(event->header.size),
1659 event->header.misc, 1630 event->header.misc,
1660 event->ip.pid, event->ip.tid, 1631 event->ip.pid, event->ip.tid,
1661 (void *)(long)ip, 1632 (void *)(long)ip,
@@ -1677,10 +1648,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
1677 return 0; 1648 return 0;
1678} 1649}
1679 1650
1680static int 1651static int process_lost_event(event_t *event __used)
1681process_lost_event(event_t *event __used,
1682 unsigned long offset __used,
1683 unsigned long head __used)
1684{ 1652{
1685 nr_lost_chunks++; 1653 nr_lost_chunks++;
1686 nr_lost_events += event->lost.lost; 1654 nr_lost_events += event->lost.lost;
@@ -1704,7 +1672,7 @@ static int sample_type_check(u64 type)
1704 1672
1705static struct perf_file_handler file_handler = { 1673static struct perf_file_handler file_handler = {
1706 .process_sample_event = process_sample_event, 1674 .process_sample_event = process_sample_event,
1707 .process_comm_event = process_comm_event, 1675 .process_comm_event = event__process_comm,
1708 .process_lost_event = process_lost_event, 1676 .process_lost_event = process_lost_event,
1709 .sample_type_check = sample_type_check, 1677 .sample_type_check = sample_type_check,
1710}; 1678};
@@ -1715,7 +1683,7 @@ static int read_events(void)
1715 register_perf_file_handler(&file_handler); 1683 register_perf_file_handler(&file_handler);
1716 1684
1717 return mmap_dispatch_perf_file(&header, input_name, 0, 0, 1685 return mmap_dispatch_perf_file(&header, input_name, 0, 0,
1718 &cwdlen, &cwd); 1686 &event__cwdlen, &event__cwd);
1719} 1687}
1720 1688
1721static void print_bad_events(void) 1689static void print_bad_events(void)