summaryrefslogtreecommitdiff
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-05-29 13:33:30 (GMT)
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-19 19:03:33 (GMT)
commita5499b37197ab4b5fed101370df7ccadacbb4340 (patch)
tree6c7651403a51c38af7d62e5dadf04f106f4cf31a /tools/perf/util/session.c
parent79928928c5a27d58ae48285d2a3f7aa835db7547 (diff)
downloadlinux-a5499b37197ab4b5fed101370df7ccadacbb4340.tar.xz
perf tools: Ensure thread-stack is flushed
The thread-stack represents a thread's current stack. When a thread exits there can still be many functions on the stack e.g. exit() can be called many levels deep, so all the callers will never return. To get that information output, the thread-stack must be flushed. Previously it was assumed the thread-stack would be flushed when the struct thread was deleted. With thread ref-counting it is no longer clear when that will be, if ever. So instead explicitly flush all the thread-stacks at the end of a session. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1432906425-9911-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index e1cd17c..c371336 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -16,6 +16,7 @@
#include "perf_regs.h"
#include "asm/bug.h"
#include "auxtrace.h"
+#include "thread-stack.h"
static int perf_session__deliver_event(struct perf_session *session,
union perf_event *event,
@@ -1361,6 +1362,19 @@ static void perf_session__warn_about_errors(const struct perf_session *session)
events_stats__auxtrace_error_warn(stats);
}
+static int perf_session__flush_thread_stack(struct thread *thread,
+ void *p __maybe_unused)
+{
+ return thread_stack__flush(thread);
+}
+
+static int perf_session__flush_thread_stacks(struct perf_session *session)
+{
+ return machines__for_each_thread(&session->machines,
+ perf_session__flush_thread_stack,
+ NULL);
+}
+
volatile int session_done;
static int __perf_session__process_pipe_events(struct perf_session *session)
@@ -1450,6 +1464,9 @@ done:
if (err)
goto out_err;
err = auxtrace__flush_events(session, tool);
+ if (err)
+ goto out_err;
+ err = perf_session__flush_thread_stacks(session);
out_err:
free(buf);
perf_session__warn_about_errors(session);
@@ -1600,6 +1617,9 @@ out:
if (err)
goto out_err;
err = auxtrace__flush_events(session, tool);
+ if (err)
+ goto out_err;
+ err = perf_session__flush_thread_stacks(session);
out_err:
ui_progress__finish();
perf_session__warn_about_errors(session);