diff options
Diffstat (limited to 'driver/gator_main.c')
-rw-r--r-- | driver/gator_main.c | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/driver/gator_main.c b/driver/gator_main.c index 0d867f2..55772ef 100644 --- a/driver/gator_main.c +++ b/driver/gator_main.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | // This version must match the gator daemon version | 10 | // This version must match the gator daemon version |
11 | #define PROTOCOL_VERSION 19 | 11 | #define PROTOCOL_VERSION 18 |
12 | static unsigned long gator_protocol_version = PROTOCOL_VERSION; | 12 | static unsigned long gator_protocol_version = PROTOCOL_VERSION; |
13 | 13 | ||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
@@ -55,9 +55,9 @@ static unsigned long gator_protocol_version = PROTOCOL_VERSION; | |||
55 | 55 | ||
56 | #if (GATOR_PERF_SUPPORT) && (!(GATOR_PERF_PMU_SUPPORT)) | 56 | #if (GATOR_PERF_SUPPORT) && (!(GATOR_PERF_PMU_SUPPORT)) |
57 | #ifndef CONFIG_PERF_EVENTS | 57 | #ifndef CONFIG_PERF_EVENTS |
58 | #error gator requires the kernel to have CONFIG_PERF_EVENTS defined to support pmu hardware counters | 58 | #warning gator requires the kernel to have CONFIG_PERF_EVENTS defined to support pmu hardware counters |
59 | #elif !defined CONFIG_HW_PERF_EVENTS | 59 | #elif !defined CONFIG_HW_PERF_EVENTS |
60 | #error gator requires the kernel to have CONFIG_HW_PERF_EVENTS defined to support pmu hardware counters | 60 | #warning gator requires the kernel to have CONFIG_HW_PERF_EVENTS defined to support pmu hardware counters |
61 | #endif | 61 | #endif |
62 | #endif | 62 | #endif |
63 | 63 | ||
@@ -71,8 +71,8 @@ static unsigned long gator_protocol_version = PROTOCOL_VERSION; | |||
71 | #define BLOCK_COUNTER_BUFFER_SIZE (128*1024) | 71 | #define BLOCK_COUNTER_BUFFER_SIZE (128*1024) |
72 | #define ANNOTATE_BUFFER_SIZE (128*1024) // annotate counters have the core as part of the data and the core value in the frame header may be discarded | 72 | #define ANNOTATE_BUFFER_SIZE (128*1024) // annotate counters have the core as part of the data and the core value in the frame header may be discarded |
73 | #define SCHED_TRACE_BUFFER_SIZE (128*1024) | 73 | #define SCHED_TRACE_BUFFER_SIZE (128*1024) |
74 | #define GPU_TRACE_BUFFER_SIZE (64*1024) // gpu trace counters have the core as part of the data and the core value in the frame header may be discarded | ||
74 | #define IDLE_BUFFER_SIZE (32*1024) // idle counters have the core as part of the data and the core value in the frame header may be discarded | 75 | #define IDLE_BUFFER_SIZE (32*1024) // idle counters have the core as part of the data and the core value in the frame header may be discarded |
75 | #define ACTIVITY_BUFFER_SIZE (128*1024) | ||
76 | 76 | ||
77 | #define NO_COOKIE 0U | 77 | #define NO_COOKIE 0U |
78 | #define UNRESOLVED_COOKIE ~0U | 78 | #define UNRESOLVED_COOKIE ~0U |
@@ -84,8 +84,8 @@ static unsigned long gator_protocol_version = PROTOCOL_VERSION; | |||
84 | #define FRAME_BLOCK_COUNTER 5 | 84 | #define FRAME_BLOCK_COUNTER 5 |
85 | #define FRAME_ANNOTATE 6 | 85 | #define FRAME_ANNOTATE 6 |
86 | #define FRAME_SCHED_TRACE 7 | 86 | #define FRAME_SCHED_TRACE 7 |
87 | #define FRAME_GPU_TRACE 8 | ||
87 | #define FRAME_IDLE 9 | 88 | #define FRAME_IDLE 9 |
88 | #define FRAME_ACTIVITY 13 | ||
89 | 89 | ||
90 | #define MESSAGE_END_BACKTRACE 1 | 90 | #define MESSAGE_END_BACKTRACE 1 |
91 | 91 | ||
@@ -94,9 +94,14 @@ static unsigned long gator_protocol_version = PROTOCOL_VERSION; | |||
94 | #define MESSAGE_THREAD_NAME 2 | 94 | #define MESSAGE_THREAD_NAME 2 |
95 | #define MESSAGE_LINK 4 | 95 | #define MESSAGE_LINK 4 |
96 | 96 | ||
97 | // GPU Trace Frame Messages | ||
98 | #define MESSAGE_GPU_START 1 | ||
99 | #define MESSAGE_GPU_STOP 2 | ||
100 | |||
97 | // Scheduler Trace Frame Messages | 101 | // Scheduler Trace Frame Messages |
98 | #define MESSAGE_SCHED_SWITCH 1 | 102 | #define MESSAGE_SCHED_SWITCH 1 |
99 | #define MESSAGE_SCHED_EXIT 2 | 103 | #define MESSAGE_SCHED_EXIT 2 |
104 | #define MESSAGE_SCHED_START 3 | ||
100 | 105 | ||
101 | // Idle Frame Messages | 106 | // Idle Frame Messages |
102 | #define MESSAGE_IDLE_ENTER 1 | 107 | #define MESSAGE_IDLE_ENTER 1 |
@@ -106,10 +111,6 @@ static unsigned long gator_protocol_version = PROTOCOL_VERSION; | |||
106 | #define MESSAGE_SUMMARY 1 | 111 | #define MESSAGE_SUMMARY 1 |
107 | #define MESSAGE_CORE_NAME 3 | 112 | #define MESSAGE_CORE_NAME 3 |
108 | 113 | ||
109 | // Activity Frame Messages | ||
110 | #define MESSAGE_SWITCH 2 | ||
111 | #define MESSAGE_EXIT 3 | ||
112 | |||
113 | #define MAXSIZE_PACK32 5 | 114 | #define MAXSIZE_PACK32 5 |
114 | #define MAXSIZE_PACK64 10 | 115 | #define MAXSIZE_PACK64 10 |
115 | 116 | ||
@@ -131,8 +132,8 @@ enum { | |||
131 | BLOCK_COUNTER_BUF, | 132 | BLOCK_COUNTER_BUF, |
132 | ANNOTATE_BUF, | 133 | ANNOTATE_BUF, |
133 | SCHED_TRACE_BUF, | 134 | SCHED_TRACE_BUF, |
135 | GPU_TRACE_BUF, | ||
134 | IDLE_BUF, | 136 | IDLE_BUF, |
135 | ACTIVITY_BUF, | ||
136 | NUM_GATOR_BUFS | 137 | NUM_GATOR_BUFS |
137 | }; | 138 | }; |
138 | 139 | ||
@@ -174,7 +175,6 @@ static DEFINE_PER_CPU(u64, last_timestamp); | |||
174 | 175 | ||
175 | static bool printed_monotonic_warning; | 176 | static bool printed_monotonic_warning; |
176 | 177 | ||
177 | static u32 gator_cpuids[NR_CPUS]; | ||
178 | static bool sent_core_name[NR_CPUS]; | 178 | static bool sent_core_name[NR_CPUS]; |
179 | 179 | ||
180 | static DEFINE_PER_CPU(bool, in_scheduler_context); | 180 | static DEFINE_PER_CPU(bool, in_scheduler_context); |
@@ -226,7 +226,6 @@ static DEFINE_PER_CPU(u64, gator_buffer_commit_time); | |||
226 | GATOR_EVENT(gator_events_perf_pmu_init) \ | 226 | GATOR_EVENT(gator_events_perf_pmu_init) \ |
227 | GATOR_EVENT(gator_events_sched_init) \ | 227 | GATOR_EVENT(gator_events_sched_init) \ |
228 | GATOR_EVENT(gator_events_scorpion_init) \ | 228 | GATOR_EVENT(gator_events_scorpion_init) \ |
229 | GATOR_EVENT(gator_events_threads_init) \ | ||
230 | 229 | ||
231 | #define GATOR_EVENT(EVENT_INIT) __weak int EVENT_INIT(void); | 230 | #define GATOR_EVENT(EVENT_INIT) __weak int EVENT_INIT(void); |
232 | GATOR_EVENTS_LIST | 231 | GATOR_EVENTS_LIST |
@@ -571,37 +570,25 @@ static void gator_timer_stop(void) | |||
571 | } | 570 | } |
572 | } | 571 | } |
573 | 572 | ||
574 | static void gator_send_core_name(const int cpu, const u32 cpuid) | ||
575 | { | ||
576 | #if defined(__arm__) || defined(__aarch64__) | 573 | #if defined(__arm__) || defined(__aarch64__) |
577 | if (!sent_core_name[cpu] || (cpuid != gator_cpuids[cpu])) { | 574 | static void gator_send_core_name(int cpu, const u32 cpuid, const struct gator_cpu *const gator_cpu) |
578 | const struct gator_cpu *const gator_cpu = gator_find_cpu_by_cpuid(cpuid); | 575 | { |
579 | const char *core_name = NULL; | 576 | const char *core_name = NULL; |
580 | char core_name_buf[32]; | 577 | char core_name_buf[32]; |
581 | 578 | ||
582 | // Save off this cpuid | 579 | if (!sent_core_name[cpu]) { |
583 | gator_cpuids[cpu] = cpuid; | ||
584 | if (gator_cpu != NULL) { | 580 | if (gator_cpu != NULL) { |
585 | core_name = gator_cpu->core_name; | 581 | core_name = gator_cpu->core_name; |
586 | } else { | 582 | } else { |
587 | if (cpuid == -1) { | 583 | snprintf(core_name_buf, sizeof(core_name_buf), "Unknown (0x%.3x)", cpuid); |
588 | snprintf(core_name_buf, sizeof(core_name_buf), "Unknown"); | ||
589 | } else { | ||
590 | snprintf(core_name_buf, sizeof(core_name_buf), "Unknown (0x%.3x)", cpuid); | ||
591 | } | ||
592 | core_name = core_name_buf; | 584 | core_name = core_name_buf; |
593 | } | 585 | } |
594 | 586 | ||
595 | marshal_core_name(cpu, cpuid, core_name); | 587 | marshal_core_name(cpu, cpuid, core_name); |
596 | sent_core_name[cpu] = true; | 588 | sent_core_name[cpu] = true; |
597 | } | 589 | } |
598 | #endif | ||
599 | } | ||
600 | |||
601 | static void gator_read_cpuid(void * arg) | ||
602 | { | ||
603 | gator_cpuids[get_physical_cpu()] = gator_cpuid(); | ||
604 | } | 590 | } |
591 | #endif | ||
605 | 592 | ||
606 | // This function runs in interrupt context and on the appropriate core | 593 | // This function runs in interrupt context and on the appropriate core |
607 | static void gator_timer_online(void *migrate) | 594 | static void gator_timer_online(void *migrate) |
@@ -611,9 +598,6 @@ static void gator_timer_online(void *migrate) | |||
611 | int *buffer; | 598 | int *buffer; |
612 | u64 time; | 599 | u64 time; |
613 | 600 | ||
614 | // Send what is currently running on this core | ||
615 | marshal_sched_trace_switch(current->pid, 0); | ||
616 | |||
617 | gator_trace_power_online(); | 601 | gator_trace_power_online(); |
618 | 602 | ||
619 | // online any events and output counters | 603 | // online any events and output counters |
@@ -633,7 +617,12 @@ static void gator_timer_online(void *migrate) | |||
633 | gator_hrtimer_online(); | 617 | gator_hrtimer_online(); |
634 | } | 618 | } |
635 | 619 | ||
636 | gator_send_core_name(cpu, gator_cpuid()); | 620 | #if defined(__arm__) || defined(__aarch64__) |
621 | if (!sent_core_name[cpu]) { | ||
622 | const u32 cpuid = gator_cpuid(); | ||
623 | gator_send_core_name(cpu, cpuid, gator_find_cpu_by_cpuid(cpuid)); | ||
624 | } | ||
625 | #endif | ||
637 | } | 626 | } |
638 | 627 | ||
639 | // This function runs in interrupt context and may be running on a core other than core 'cpu' | 628 | // This function runs in interrupt context and may be running on a core other than core 'cpu' |
@@ -669,13 +658,6 @@ static int gator_timer_start(unsigned long sample_rate) | |||
669 | if (gator_hrtimer_init(sample_rate, gator_timer_interrupt) == -1) | 658 | if (gator_hrtimer_init(sample_rate, gator_timer_interrupt) == -1) |
670 | return -1; | 659 | return -1; |
671 | 660 | ||
672 | // Send off the previously saved cpuids | ||
673 | for_each_present_cpu(cpu) { | ||
674 | preempt_disable(); | ||
675 | gator_send_core_name(cpu, gator_cpuids[cpu]); | ||
676 | preempt_enable(); | ||
677 | } | ||
678 | |||
679 | gator_send_iks_core_names(); | 661 | gator_send_iks_core_names(); |
680 | for_each_online_cpu(cpu) { | 662 | for_each_online_cpu(cpu) { |
681 | gator_timer_online_dispatch(lcpu_to_pcpu(cpu), false); | 663 | gator_timer_online_dispatch(lcpu_to_pcpu(cpu), false); |
@@ -1027,12 +1009,12 @@ static int gator_op_setup(void) | |||
1027 | gator_buffer_size[SCHED_TRACE_BUF] = SCHED_TRACE_BUFFER_SIZE; | 1009 | gator_buffer_size[SCHED_TRACE_BUF] = SCHED_TRACE_BUFFER_SIZE; |
1028 | gator_buffer_mask[SCHED_TRACE_BUF] = SCHED_TRACE_BUFFER_SIZE - 1; | 1010 | gator_buffer_mask[SCHED_TRACE_BUF] = SCHED_TRACE_BUFFER_SIZE - 1; |
1029 | 1011 | ||
1012 | gator_buffer_size[GPU_TRACE_BUF] = GPU_TRACE_BUFFER_SIZE; | ||
1013 | gator_buffer_mask[GPU_TRACE_BUF] = GPU_TRACE_BUFFER_SIZE - 1; | ||
1014 | |||
1030 | gator_buffer_size[IDLE_BUF] = IDLE_BUFFER_SIZE; | 1015 | gator_buffer_size[IDLE_BUF] = IDLE_BUFFER_SIZE; |
1031 | gator_buffer_mask[IDLE_BUF] = IDLE_BUFFER_SIZE - 1; | 1016 | gator_buffer_mask[IDLE_BUF] = IDLE_BUFFER_SIZE - 1; |
1032 | 1017 | ||
1033 | gator_buffer_size[ACTIVITY_BUF] = ACTIVITY_BUFFER_SIZE; | ||
1034 | gator_buffer_mask[ACTIVITY_BUF] = ACTIVITY_BUFFER_SIZE - 1; | ||
1035 | |||
1036 | // Initialize percpu per buffer variables | 1018 | // Initialize percpu per buffer variables |
1037 | for (i = 0; i < NUM_GATOR_BUFS; i++) { | 1019 | for (i = 0; i < NUM_GATOR_BUFS; i++) { |
1038 | // Verify buffers are a power of 2 | 1020 | // Verify buffers are a power of 2 |
@@ -1391,7 +1373,6 @@ static void gator_op_create_files(struct super_block *sb, struct dentry *root) | |||
1391 | GATOR_HANDLE_TRACEPOINT(mm_page_alloc); \ | 1373 | GATOR_HANDLE_TRACEPOINT(mm_page_alloc); \ |
1392 | GATOR_HANDLE_TRACEPOINT(mm_page_free); \ | 1374 | GATOR_HANDLE_TRACEPOINT(mm_page_free); \ |
1393 | GATOR_HANDLE_TRACEPOINT(mm_page_free_batched); \ | 1375 | GATOR_HANDLE_TRACEPOINT(mm_page_free_batched); \ |
1394 | GATOR_HANDLE_TRACEPOINT(sched_process_exec); \ | ||
1395 | GATOR_HANDLE_TRACEPOINT(sched_process_fork); \ | 1376 | GATOR_HANDLE_TRACEPOINT(sched_process_fork); \ |
1396 | GATOR_HANDLE_TRACEPOINT(sched_process_free); \ | 1377 | GATOR_HANDLE_TRACEPOINT(sched_process_free); \ |
1397 | GATOR_HANDLE_TRACEPOINT(sched_switch); \ | 1378 | GATOR_HANDLE_TRACEPOINT(sched_switch); \ |
@@ -1434,10 +1415,6 @@ static int __init gator_module_init(void) | |||
1434 | 1415 | ||
1435 | setup_timer(&gator_buffer_wake_up_timer, gator_buffer_wake_up, 0); | 1416 | setup_timer(&gator_buffer_wake_up_timer, gator_buffer_wake_up, 0); |
1436 | 1417 | ||
1437 | // Initialize the list of cpuids | ||
1438 | memset(gator_cpuids, -1, sizeof(gator_cpuids)); | ||
1439 | on_each_cpu(gator_read_cpuid, NULL, 1); | ||
1440 | |||
1441 | return 0; | 1418 | return 0; |
1442 | } | 1419 | } |
1443 | 1420 | ||