gator: Use for_each_kernel_tracepoint in Linux 3.15
authorDrew Richardson <drew.richardson@arm.com>
Thu, 24 Apr 2014 08:24:14 +0000 (09:24 +0100)
committerJon Medhurst <tixy@linaro.org>
Thu, 24 Apr 2014 14:23:19 +0000 (15:23 +0100)
Starting with Linux 3.15, unexported tracepoints can't be used
directly. Use for_each_kernel_tracepoint to iterate over all
tracepoints and save off the tracepoints we're interested in.

Signed-off-by: Drew Richardson <drew.richardson@arm.com>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
driver/gator.h
driver/gator_main.c

index 586cd9e742fb14bc2a6d2e8f808fe5539ec95919..58cb0a2a1f3abb0f3ad7c21228faca0aff061716 100644 (file)
@@ -82,13 +82,21 @@ int gatorfs_create_ro_ulong(struct super_block *sb, struct dentry *root,
                register_trace_##probe_name(probe_##probe_name)
 #      define GATOR_UNREGISTER_TRACE(probe_name) \
                unregister_trace_##probe_name(probe_##probe_name)
                register_trace_##probe_name(probe_##probe_name)
 #      define GATOR_UNREGISTER_TRACE(probe_name) \
                unregister_trace_##probe_name(probe_##probe_name)
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
 #      define GATOR_DEFINE_PROBE(probe_name, proto) \
                static void probe_##probe_name(void *data, PARAMS(proto))
 #      define GATOR_REGISTER_TRACE(probe_name) \
                register_trace_##probe_name(probe_##probe_name, NULL)
 #      define GATOR_UNREGISTER_TRACE(probe_name) \
                unregister_trace_##probe_name(probe_##probe_name, NULL)
 #      define GATOR_DEFINE_PROBE(probe_name, proto) \
                static void probe_##probe_name(void *data, PARAMS(proto))
 #      define GATOR_REGISTER_TRACE(probe_name) \
                register_trace_##probe_name(probe_##probe_name, NULL)
 #      define GATOR_UNREGISTER_TRACE(probe_name) \
                unregister_trace_##probe_name(probe_##probe_name, NULL)
+#else
+#      define GATOR_DEFINE_PROBE(probe_name, proto) \
+               extern struct tracepoint *gator_tracepoint_##probe_name; \
+               static void probe_##probe_name(void *data, PARAMS(proto))
+#      define GATOR_REGISTER_TRACE(probe_name) \
+               tracepoint_probe_register(gator_tracepoint_##probe_name, probe_##probe_name, NULL)
+#      define GATOR_UNREGISTER_TRACE(probe_name) \
+               tracepoint_probe_unregister(gator_tracepoint_##probe_name, probe_##probe_name, NULL)
 #endif
 
 /******************************************************************************
 #endif
 
 /******************************************************************************
index 4a1f0566fe1f97f0c9faadf006193fed945c1152..55772ef71d0d5ee683d704a1a40e091d2e593652 100644 (file)
@@ -1349,8 +1349,61 @@ static void gator_op_create_files(struct super_block *sb, struct dentry *root)
 /******************************************************************************
  * Module
  ******************************************************************************/
 /******************************************************************************
  * Module
  ******************************************************************************/
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
+
+#define GATOR_TRACEPOINTS \
+       GATOR_HANDLE_TRACEPOINT(block_rq_complete); \
+       GATOR_HANDLE_TRACEPOINT(cpu_frequency); \
+       GATOR_HANDLE_TRACEPOINT(cpu_idle); \
+       GATOR_HANDLE_TRACEPOINT(cpu_migrate_begin); \
+       GATOR_HANDLE_TRACEPOINT(cpu_migrate_current); \
+       GATOR_HANDLE_TRACEPOINT(cpu_migrate_finish); \
+       GATOR_HANDLE_TRACEPOINT(irq_handler_exit); \
+       GATOR_HANDLE_TRACEPOINT(mali_hw_counter); \
+       GATOR_HANDLE_TRACEPOINT(mali_job_slots_event); \
+       GATOR_HANDLE_TRACEPOINT(mali_mmu_as_in_use); \
+       GATOR_HANDLE_TRACEPOINT(mali_mmu_as_released); \
+       GATOR_HANDLE_TRACEPOINT(mali_page_fault_insert_pages); \
+       GATOR_HANDLE_TRACEPOINT(mali_pm_status); \
+       GATOR_HANDLE_TRACEPOINT(mali_sw_counter); \
+       GATOR_HANDLE_TRACEPOINT(mali_sw_counters); \
+       GATOR_HANDLE_TRACEPOINT(mali_timeline_event); \
+       GATOR_HANDLE_TRACEPOINT(mali_total_alloc_pages_change); \
+       GATOR_HANDLE_TRACEPOINT(mm_page_alloc); \
+       GATOR_HANDLE_TRACEPOINT(mm_page_free); \
+       GATOR_HANDLE_TRACEPOINT(mm_page_free_batched); \
+       GATOR_HANDLE_TRACEPOINT(sched_process_fork); \
+       GATOR_HANDLE_TRACEPOINT(sched_process_free); \
+       GATOR_HANDLE_TRACEPOINT(sched_switch); \
+       GATOR_HANDLE_TRACEPOINT(softirq_exit); \
+
+#define GATOR_HANDLE_TRACEPOINT(probe_name) \
+       struct tracepoint *gator_tracepoint_##probe_name
+GATOR_TRACEPOINTS;
+#undef GATOR_HANDLE_TRACEPOINT
+
+static void gator_fct(struct tracepoint *tp, void *priv)
+{
+#define GATOR_HANDLE_TRACEPOINT(probe_name) \
+       if (strcmp(tp->name, #probe_name) == 0) { \
+               gator_tracepoint_##probe_name = tp; \
+               return; \
+       }
+GATOR_TRACEPOINTS;
+#undef GATOR_HANDLE_TRACEPOINT
+}
+
+#else
+
+#define for_each_kernel_tracepoint(fct, priv)
+
+#endif
+
 static int __init gator_module_init(void)
 {
 static int __init gator_module_init(void)
 {
+       for_each_kernel_tracepoint(gator_fct, NULL);
+
        if (gatorfs_register()) {
                return -1;
        }
        if (gatorfs_register()) {
                return -1;
        }