Handle newer 3.1+ perf API
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 27 Sep 2011 15:52:53 +0000 (11:52 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 27 Sep 2011 15:52:53 +0000 (11:52 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-context-perf-counters.c
wrapper/perf.h [new file with mode: 0644]

index 2f131d61e32f2cdbd4f7b152b478f7c60e3be6c2..0b3668ae2ae46f6b523c7f9a7dfbc3aef608c1cb 100644 (file)
@@ -15,6 +15,7 @@
 #include "ltt-events.h"
 #include "wrapper/ringbuffer/frontend_types.h"
 #include "wrapper/vmalloc.h"
+#include "wrapper/perf.h"
 #include "ltt-tracer.h"
 
 static
@@ -57,12 +58,21 @@ void perf_counter_record(struct lttng_ctx_field *field,
        chan->ops->event_write(ctx, &value, sizeof(value));
 }
 
+#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99))
+static
+void overflow_callback(struct perf_event *event,
+                      struct perf_sample_data *data,
+                      struct pt_regs *regs)
+{
+}
+#else
 static
 void overflow_callback(struct perf_event *event, int nmi,
                       struct perf_sample_data *data,
                       struct pt_regs *regs)
 {
 }
+#endif
 
 static
 void lttng_destroy_perf_counter_field(struct lttng_ctx_field *field)
@@ -114,7 +124,7 @@ int __cpuinit lttng_perf_counter_cpu_hp_callback(struct notifier_block *nb,
        switch (action) {
        case CPU_ONLINE:
        case CPU_ONLINE_FROZEN:
-               pevent = perf_event_create_kernel_counter(attr,
+               pevent = wrapper_perf_event_create_kernel_counter(attr,
                                cpu, NULL, overflow_callback);
                if (!pevent || IS_ERR(pevent))
                        return NOTIFY_BAD;
@@ -202,7 +212,7 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
 
        get_online_cpus();
        for_each_online_cpu(cpu) {
-               events[cpu] = perf_event_create_kernel_counter(attr,
+               events[cpu] = wrapper_perf_event_create_kernel_counter(attr,
                                        cpu, NULL, overflow_callback);
                if (!events[cpu] || IS_ERR(events[cpu])) {
                        ret = -EINVAL;
diff --git a/wrapper/perf.h b/wrapper/perf.h
new file mode 100644 (file)
index 0000000..9a6dbfc
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef _LTT_WRAPPER_PERF_H
+#define _LTT_WRAPPER_PERF_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/perf_event.h>
+
+#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99))
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+                               int cpu,
+                               struct task_struct *task,
+                               perf_overflow_handler_t callback)
+{
+       return perf_event_create_kernel_counter(attr, cpu, task, callback, NULL);
+}
+#else
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+                               int cpu,
+                               struct task_struct *task,
+                               perf_overflow_handler_t callback)
+{
+       return perf_event_create_kernel_counter(attr, cpu, task, callback);
+}
+#endif
+
+#endif /* _LTT_WRAPPER_PERF_H */
This page took 0.027214 seconds and 4 git commands to generate.