tracing: Use linker magic instead of recasting ftrace_ops_list_func()
[linux-2.6-microblaze.git] / kernel / trace / ftrace.c
index 7efbc8a..8b58018 100644 (file)
@@ -119,14 +119,9 @@ struct ftrace_ops __rcu *ftrace_ops_list __read_mostly = &ftrace_list_end;
 ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
 struct ftrace_ops global_ops;
 
-#if ARCH_SUPPORTS_FTRACE_OPS
-static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
-                                struct ftrace_ops *op, struct ftrace_regs *fregs);
-#else
-/* See comment below, where ftrace_ops_list_func is defined */
-static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip);
-#define ftrace_ops_list_func ((ftrace_func_t)ftrace_ops_no_ops)
-#endif
+/* Defined by vmlinux.lds.h see the commment above arch_ftrace_ops_list_func for details */
+void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
+                         struct ftrace_ops *op, struct ftrace_regs *fregs);
 
 static inline void ftrace_ops_init(struct ftrace_ops *ops)
 {
@@ -988,8 +983,9 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
                }
        }
 
-       entry = tracefs_create_file("function_profile_enabled", 0644,
-                                   d_tracer, NULL, &ftrace_profile_fops);
+       entry = tracefs_create_file("function_profile_enabled",
+                                   TRACE_MODE_WRITE, d_tracer, NULL,
+                                   &ftrace_profile_fops);
        if (!entry)
                pr_warn("Could not create tracefs 'function_profile_enabled' entry\n");
 }
@@ -6109,10 +6105,10 @@ void ftrace_create_filter_files(struct ftrace_ops *ops,
                                struct dentry *parent)
 {
 
-       trace_create_file("set_ftrace_filter", 0644, parent,
+       trace_create_file("set_ftrace_filter", TRACE_MODE_WRITE, parent,
                          ops, &ftrace_filter_fops);
 
-       trace_create_file("set_ftrace_notrace", 0644, parent,
+       trace_create_file("set_ftrace_notrace", TRACE_MODE_WRITE, parent,
                          ops, &ftrace_notrace_fops);
 }
 
@@ -6139,19 +6135,19 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops)
 static __init int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
 {
 
-       trace_create_file("available_filter_functions", 0444,
+       trace_create_file("available_filter_functions", TRACE_MODE_READ,
                        d_tracer, NULL, &ftrace_avail_fops);
 
-       trace_create_file("enabled_functions", 0444,
+       trace_create_file("enabled_functions", TRACE_MODE_READ,
                        d_tracer, NULL, &ftrace_enabled_fops);
 
        ftrace_create_filter_files(&global_ops, d_tracer);
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       trace_create_file("set_graph_function", 0644, d_tracer,
+       trace_create_file("set_graph_function", TRACE_MODE_WRITE, d_tracer,
                                    NULL,
                                    &ftrace_graph_fops);
-       trace_create_file("set_graph_notrace", 0644, d_tracer,
+       trace_create_file("set_graph_notrace", TRACE_MODE_WRITE, d_tracer,
                                    NULL,
                                    &ftrace_graph_notrace_fops);
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
@@ -6846,6 +6842,11 @@ void __init ftrace_free_init_mem(void)
        ftrace_free_mem(NULL, start, end);
 }
 
+int __init __weak ftrace_dyn_arch_init(void)
+{
+       return 0;
+}
+
 void __init ftrace_init(void)
 {
        extern unsigned long __start_mcount_loc[];
@@ -7026,21 +7027,23 @@ out:
  * Note, CONFIG_DYNAMIC_FTRACE_WITH_REGS expects a full regs to be saved.
  * An architecture can pass partial regs with ftrace_ops and still
  * set the ARCH_SUPPORTS_FTRACE_OPS.
+ *
+ * In vmlinux.lds.h, ftrace_ops_list_func() is defined to be
+ * arch_ftrace_ops_list_func.
  */
 #if ARCH_SUPPORTS_FTRACE_OPS
-static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
-                                struct ftrace_ops *op, struct ftrace_regs *fregs)
+void arch_ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
+                              struct ftrace_ops *op, struct ftrace_regs *fregs)
 {
        __ftrace_ops_list_func(ip, parent_ip, NULL, fregs);
 }
-NOKPROBE_SYMBOL(ftrace_ops_list_func);
 #else
-static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip)
+void arch_ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip)
 {
        __ftrace_ops_list_func(ip, parent_ip, NULL, NULL);
 }
-NOKPROBE_SYMBOL(ftrace_ops_no_ops);
 #endif
+NOKPROBE_SYMBOL(arch_ftrace_ops_list_func);
 
 /*
  * If there's only one function registered but it does not support
@@ -7184,10 +7187,10 @@ static void clear_ftrace_pids(struct trace_array *tr, int type)
        synchronize_rcu();
 
        if ((type & TRACE_PIDS) && pid_list)
-               trace_free_pid_list(pid_list);
+               trace_pid_list_free(pid_list);
 
        if ((type & TRACE_NO_PIDS) && no_pid_list)
-               trace_free_pid_list(no_pid_list);
+               trace_pid_list_free(no_pid_list);
 }
 
 void ftrace_clear_pids(struct trace_array *tr)
@@ -7428,7 +7431,7 @@ pid_write(struct file *filp, const char __user *ubuf,
 
        if (filtered_pids) {
                synchronize_rcu();
-               trace_free_pid_list(filtered_pids);
+               trace_pid_list_free(filtered_pids);
        } else if (pid_list && !other_pids) {
                /* Register a probe to set whether to ignore the tracing of a task */
                register_trace_sched_switch(ftrace_filter_pid_sched_switch_probe, tr);
@@ -7494,10 +7497,10 @@ static const struct file_operations ftrace_no_pid_fops = {
 
 void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer)
 {
-       trace_create_file("set_ftrace_pid", 0644, d_tracer,
+       trace_create_file("set_ftrace_pid", TRACE_MODE_WRITE, d_tracer,
                            tr, &ftrace_pid_fops);
-       trace_create_file("set_ftrace_notrace_pid", 0644, d_tracer,
-                           tr, &ftrace_no_pid_fops);
+       trace_create_file("set_ftrace_notrace_pid", TRACE_MODE_WRITE,
+                         d_tracer, tr, &ftrace_no_pid_fops);
 }
 
 void __init ftrace_init_tracefs_toplevel(struct trace_array *tr,