]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - kernel/trace/trace_syscalls.c
perf trace/scripting: Remove extraneous header read
[karo-tx-linux.git] / kernel / trace / trace_syscalls.c
index 57501d90096abbba5ee3a87de54476a794ba176e..4e332b9e449cf4b992fb4c8d44cfbbf27b21b605 100644 (file)
@@ -217,10 +217,6 @@ int syscall_enter_define_fields(struct ftrace_event_call *call)
        int i;
        int offset = offsetof(typeof(trace), args);
 
-       ret = trace_define_common_fields(call);
-       if (ret)
-               return ret;
-
        ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER);
        if (ret)
                return ret;
@@ -241,10 +237,6 @@ int syscall_exit_define_fields(struct ftrace_event_call *call)
        struct syscall_trace_exit trace;
        int ret;
 
-       ret = trace_define_common_fields(call);
-       if (ret)
-               return ret;
-
        ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER);
        if (ret)
                return ret;
@@ -333,10 +325,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
        mutex_lock(&syscall_trace_lock);
        if (!sys_refcount_enter)
                ret = register_trace_sys_enter(ftrace_syscall_enter);
-       if (ret) {
-               pr_info("event trace: Could not activate"
-                               "syscall entry trace point");
-       } else {
+       if (!ret) {
                set_bit(num, enabled_enter_syscalls);
                sys_refcount_enter++;
        }
@@ -370,10 +359,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
        mutex_lock(&syscall_trace_lock);
        if (!sys_refcount_exit)
                ret = register_trace_sys_exit(ftrace_syscall_exit);
-       if (ret) {
-               pr_info("event trace: Could not activate"
-                               "syscall exit trace point");
-       } else {
+       if (!ret) {
                set_bit(num, enabled_exit_syscalls);
                sys_refcount_exit++;
        }
@@ -435,7 +421,7 @@ int __init init_ftrace_syscalls(void)
 }
 core_initcall(init_ftrace_syscalls);
 
-#ifdef CONFIG_EVENT_PROFILE
+#ifdef CONFIG_PERF_EVENTS
 
 static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls);
 static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls);
@@ -447,12 +433,9 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
        struct syscall_metadata *sys_data;
        struct syscall_trace_enter *rec;
        unsigned long flags;
-       char *trace_buf;
-       char *raw_data;
        int syscall_nr;
        int rctx;
        int size;
-       int cpu;
 
        syscall_nr = syscall_get_nr(current, regs);
        if (!test_bit(syscall_nr, enabled_prof_enter_syscalls))
@@ -471,37 +454,15 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
                      "profile buffer not large enough"))
                return;
 
-       /* Protect the per cpu buffer, begin the rcu read side */
-       local_irq_save(flags);
-
-       rctx = perf_swevent_get_recursion_context();
-       if (rctx < 0)
-               goto end_recursion;
-
-       cpu = smp_processor_id();
-
-       trace_buf = rcu_dereference(perf_trace_buf);
-
-       if (!trace_buf)
-               goto end;
-
-       raw_data = per_cpu_ptr(trace_buf, cpu);
-
-       /* zero the dead bytes from align to not leak stack to user */
-       *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
+       rec = (struct syscall_trace_enter *)ftrace_perf_buf_prepare(size,
+                               sys_data->enter_event->id, &rctx, &flags);
+       if (!rec)
+               return;
 
-       rec = (struct syscall_trace_enter *) raw_data;
-       tracing_generic_entry_update(&rec->ent, 0, 0);
-       rec->ent.type = sys_data->enter_event->id;
        rec->nr = syscall_nr;
        syscall_get_arguments(current, regs, 0, sys_data->nb_args,
                               (unsigned long *)&rec->args);
-       perf_tp_event(sys_data->enter_event->id, 0, 1, rec, size);
-
-end:
-       perf_swevent_put_recursion_context(rctx);
-end_recursion:
-       local_irq_restore(flags);
+       ftrace_perf_buf_submit(rec, size, rctx, 0, 1, flags);
 }
 
 int prof_sysenter_enable(struct ftrace_event_call *call)
@@ -545,11 +506,8 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret)
        struct syscall_trace_exit *rec;
        unsigned long flags;
        int syscall_nr;
-       char *trace_buf;
-       char *raw_data;
        int rctx;
        int size;
-       int cpu;
 
        syscall_nr = syscall_get_nr(current, regs);
        if (!test_bit(syscall_nr, enabled_prof_exit_syscalls))
@@ -571,38 +529,15 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret)
                "exit event has grown above profile buffer size"))
                return;
 
-       /* Protect the per cpu buffer, begin the rcu read side */
-       local_irq_save(flags);
-
-       rctx = perf_swevent_get_recursion_context();
-       if (rctx < 0)
-               goto end_recursion;
-
-       cpu = smp_processor_id();
-
-       trace_buf = rcu_dereference(perf_trace_buf);
-
-       if (!trace_buf)
-               goto end;
-
-       raw_data = per_cpu_ptr(trace_buf, cpu);
-
-       /* zero the dead bytes from align to not leak stack to user */
-       *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
-
-       rec = (struct syscall_trace_exit *)raw_data;
+       rec = (struct syscall_trace_exit *)ftrace_perf_buf_prepare(size,
+                               sys_data->exit_event->id, &rctx, &flags);
+       if (!rec)
+               return;
 
-       tracing_generic_entry_update(&rec->ent, 0, 0);
-       rec->ent.type = sys_data->exit_event->id;
        rec->nr = syscall_nr;
        rec->ret = syscall_get_return_value(current, regs);
 
-       perf_tp_event(sys_data->exit_event->id, 0, 1, rec, size);
-
-end:
-       perf_swevent_put_recursion_context(rctx);
-end_recursion:
-       local_irq_restore(flags);
+       ftrace_perf_buf_submit(rec, size, rctx, 0, 1, flags);
 }
 
 int prof_sysexit_enable(struct ftrace_event_call *call)
@@ -640,6 +575,5 @@ void prof_sysexit_disable(struct ftrace_event_call *call)
        mutex_unlock(&syscall_trace_lock);
 }
 
-#endif
-
+#endif /* CONFIG_PERF_EVENTS */