]> Pileus Git - ~andy/linux/blobdiff - kernel/trace/trace_functions.c
tracing: Consolidate ftrace_trace_onoff_unreg() into callback
[~andy/linux] / kernel / trace / trace_functions.c
index 60115252332668f2b39c4c868304b9187017b879..a88a3e0b0cc2a21b05b25d5d9bc89aaea067c35f 100644 (file)
@@ -28,7 +28,7 @@ static void tracing_stop_function_trace(void);
 static int function_trace_init(struct trace_array *tr)
 {
        func_trace = tr;
-       tr->cpu = get_cpu();
+       tr->trace_buffer.cpu = get_cpu();
        put_cpu();
 
        tracing_start_cmdline_record();
@@ -44,7 +44,7 @@ static void function_trace_reset(struct trace_array *tr)
 
 static void function_trace_start(struct trace_array *tr)
 {
-       tracing_reset_online_cpus(tr);
+       tracing_reset_online_cpus(&tr->trace_buffer);
 }
 
 /* Our option */
@@ -76,7 +76,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
                goto out;
 
        cpu = smp_processor_id();
-       data = tr->data[cpu];
+       data = per_cpu_ptr(tr->trace_buffer.data, cpu);
        if (!atomic_read(&data->disabled)) {
                local_save_flags(flags);
                trace_function(tr, ip, parent_ip, flags, pc);
@@ -107,7 +107,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
         */
        local_irq_save(flags);
        cpu = raw_smp_processor_id();
-       data = tr->data[cpu];
+       data = per_cpu_ptr(tr->trace_buffer.data, cpu);
        disabled = atomic_inc_return(&data->disabled);
 
        if (likely(disabled == 1)) {
@@ -214,38 +214,37 @@ static struct tracer function_trace __read_mostly =
 };
 
 #ifdef CONFIG_DYNAMIC_FTRACE
-static void
-ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
+static int update_count(void **data)
 {
-       long *count = (long *)data;
-
-       if (tracing_is_on())
-               return;
+       unsigned long *count = (long *)data;
 
        if (!*count)
-               return;
+               return 0;
 
        if (*count != -1)
                (*count)--;
 
-       tracing_on();
+       return 1;
 }
 
 static void
-ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
+ftrace_traceon(unsigned long ip, unsigned long parent_ip, void **data)
 {
-       long *count = (long *)data;
-
-       if (!tracing_is_on())
+       if (tracing_is_on())
                return;
 
-       if (!*count)
-               return;
+       if (update_count(data))
+               tracing_on();
+}
 
-       if (*count != -1)
-               (*count)--;
+static void
+ftrace_traceoff(unsigned long ip, unsigned long parent_ip, void **data)
+{
+       if (!tracing_is_on())
+               return;
 
-       tracing_off();
+       if (update_count(data))
+               tracing_off();
 }
 
 static int
@@ -283,22 +282,6 @@ ftrace_trace_onoff_print(struct seq_file *m, unsigned long ip,
        return 0;
 }
 
-static int
-ftrace_trace_onoff_unreg(char *glob, char *cmd, char *param)
-{
-       struct ftrace_probe_ops *ops;
-
-       /* we register both traceon and traceoff to this callback */
-       if (strcmp(cmd, "traceon") == 0)
-               ops = &traceon_probe_ops;
-       else
-               ops = &traceoff_probe_ops;
-
-       unregister_ftrace_function_probe_func(glob, ops);
-
-       return 0;
-}
-
 static int
 ftrace_trace_onoff_callback(struct ftrace_hash *hash,
                            char *glob, char *cmd, char *param, int enable)
@@ -312,15 +295,17 @@ ftrace_trace_onoff_callback(struct ftrace_hash *hash,
        if (!enable)
                return -EINVAL;
 
-       if (glob[0] == '!')
-               return ftrace_trace_onoff_unreg(glob+1, cmd, param);
-
        /* we register both traceon and traceoff to this callback */
        if (strcmp(cmd, "traceon") == 0)
                ops = &traceon_probe_ops;
        else
                ops = &traceoff_probe_ops;
 
+       if (glob[0] == '!') {
+               unregister_ftrace_function_probe_func(glob+1, ops);
+               return 0;
+       }
+
        if (!param)
                goto out_reg;