aboutsummaryrefslogtreecommitdiff
path: root/driver/gator_ebs.c
diff options
context:
space:
mode:
authorJon Medhurst <tixy@linaro.org>2012-05-10 14:15:56 +0100
committerJon Medhurst <tixy@linaro.org>2012-05-16 14:22:59 +0100
commitd18974d3f05535eda819f2d0b92a9d49719b0f26 (patch)
treeee0d02ac702b3802b0f002a0f8edf2171d7e58c3 /driver/gator_ebs.c
parent970700feed8c3523b06476ae340bf46f6d262550 (diff)
gator: Version 5.10DS-5.10
New gator release (build 1385) for ARM DS-5 v5.10 Signed-off-by: Jon Medhurst <tixy@linaro.org>
Diffstat (limited to 'driver/gator_ebs.c')
-rw-r--r--driver/gator_ebs.c64
1 files changed, 15 insertions, 49 deletions
diff --git a/driver/gator_ebs.c b/driver/gator_ebs.c
index 8c2997c..1208d69 100644
--- a/driver/gator_ebs.c
+++ b/driver/gator_ebs.c
@@ -14,6 +14,8 @@
#include <asm/pmu.h>
+static DEFINE_MUTEX(perf_mutex);
+
extern int pmnc_counters;
extern int ccnt;
extern unsigned long pmnc_enabled[];
@@ -32,59 +34,16 @@ static void ebs_overflow_handler(struct perf_event *event, int unused, struct pe
static void ebs_overflow_handler(struct perf_event *event, struct perf_sample_data *data, struct pt_regs *regs)
#endif
{
- unsigned int value, delta, cpu = smp_processor_id(), buftype = EVENT_BUF;
+ int cpu = smp_processor_id();
if (event != per_cpu(pevent, cpu))
return;
- if (buffer_check_space(cpu, buftype, 5 * MAXSIZE_PACK32 + MAXSIZE_PACK64)) {
- value = local64_read(&event->count);
- delta = value - per_cpu(prev_value, cpu);
- per_cpu(prev_value, cpu) = value;
-
- // Counters header
- gator_buffer_write_packed_int(cpu, buftype, MESSAGE_COUNTERS); // type
- gator_buffer_write_packed_int64(cpu, buftype, gator_get_time()); // time
-
- // Output counter
- gator_buffer_write_packed_int(cpu, buftype, 2); // length
- gator_buffer_write_packed_int(cpu, buftype, per_cpu(key, cpu)); // key
- gator_buffer_write_packed_int(cpu, buftype, delta); // delta
-
- // End Counters, length of zero
- gator_buffer_write_packed_int(cpu, buftype, 0);
- }
-
// Output backtrace
- if (buffer_check_space(cpu, buftype, gator_backtrace_depth * 2 * MAXSIZE_PACK32))
- gator_add_sample(cpu, buftype, regs);
+ gator_add_sample(cpu, BACKTRACE_BUF, regs);
- // Check and commit; commit is set to occur once buffer is 3/4 full
- buffer_check(cpu, buftype);
-}
-
-static void gator_event_sampling_online(void)
-{
- int cpu = smp_processor_id(), buftype = EVENT_BUF;
-
- // read the counter and toss the invalid data, return zero instead
- struct perf_event * ev = per_cpu(pevent, cpu);
- if (ev != NULL && ev->state == PERF_EVENT_STATE_ACTIVE) {
- ev->pmu->read(ev);
- per_cpu(prev_value, cpu) = local64_read(&ev->count);
-
- // Counters header
- gator_buffer_write_packed_int(cpu, buftype, MESSAGE_COUNTERS); // type
- gator_buffer_write_packed_int64(cpu, buftype, gator_get_time()); // time
-
- // Output counter
- gator_buffer_write_packed_int(cpu, buftype, 2); // length
- gator_buffer_write_packed_int(cpu, buftype, per_cpu(key, cpu)); // key
- gator_buffer_write_packed_int(cpu, buftype, 0); // delta - zero for initialization
-
- // End Counters, length of zero
- gator_buffer_write_packed_int(cpu, buftype, 0);
- }
+ // Collect counters
+ collect_counters();
}
static void gator_event_sampling_online_dispatch(int cpu)
@@ -117,10 +76,18 @@ static void gator_event_sampling_online_dispatch(int cpu)
static void gator_event_sampling_offline_dispatch(int cpu)
{
+ struct perf_event * pe = NULL;
+
+ mutex_lock(&perf_mutex);
if (per_cpu(pevent, cpu)) {
- perf_event_release_kernel(per_cpu(pevent, cpu));
+ pe = per_cpu(pevent, cpu);
per_cpu(pevent, cpu) = NULL;
}
+ mutex_unlock(&perf_mutex);
+
+ if (pe) {
+ perf_event_release_kernel(pe);
+ }
}
static int gator_event_sampling_start(void)
@@ -184,7 +151,6 @@ static void gator_event_sampling_stop(void)
}
#else
-static void gator_event_sampling_online(void) {}
static void gator_event_sampling_online_dispatch(int cpu) {}
static void gator_event_sampling_offline_dispatch(int cpu) {}
static int gator_event_sampling_start(void) {return 0;}