perf: Only record PC once
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 19 Jul 2016 21:58:27 +0000 (17:58 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 27 Jul 2016 16:52:43 +0000 (12:52 -0400)
This was recording PC in the backtrace, then PC would be included a second
time.  I don't know if that was having any adverse affects on perf, or if
it was just making me wonder what the heck was going on.

Btw, I see that it was trying to cover for cases where FP was 0
immediately.  It's best to let the helper functions do that.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/profiler.c

index 8ab9646..c85f45b 100644 (file)
@@ -513,13 +513,9 @@ void profiler_add_kernel_backtrace(uintptr_t pc, uintptr_t fp, uint64_t info)
 
                if (profiler_percpu_ctx && cpu_buf->tracing) {
                        uintptr_t trace[PROFILER_BT_DEPTH];
-                       size_t n = 1;
-
-                       trace[0] = pc;
-                       if (likely(fp))
-                               n = backtrace_list(pc, fp, trace + 1,
-                                                  PROFILER_BT_DEPTH - 1) + 1;
+                       size_t n;
 
+                       n = backtrace_list(pc, fp, trace, PROFILER_BT_DEPTH);
                        profiler_push_kernel_trace64(cpu_buf, trace, n, info);
                }
                kref_put(&profiler_kref);
@@ -534,13 +530,9 @@ void profiler_add_user_backtrace(uintptr_t pc, uintptr_t fp, uint64_t info)
 
                if (p && profiler_percpu_ctx && cpu_buf->tracing) {
                        uintptr_t trace[PROFILER_BT_DEPTH];
-                       size_t n = 1;
-
-                       trace[0] = pc;
-                       if (likely(fp))
-                               n = backtrace_user_list(pc, fp, trace + 1,
-                                                       PROFILER_BT_DEPTH - 1) + 1;
+                       size_t n;
 
+                       n = backtrace_user_list(pc, fp, trace, PROFILER_BT_DEPTH);
                        profiler_push_user_trace64(cpu_buf, p, trace, n, info);
                }
                kref_put(&profiler_kref);