perf session: Check for SIGINT in more loops

When processing big files we were not checking if session_done was set
by the SIGINT signal handler, for instance in 'perf report'. Fix it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-pyad42lgrtq7xhg2dpsoauq7@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e955d5c4
...@@ -321,8 +321,6 @@ static int perf_inject__sched_stat(struct perf_tool *tool, ...@@ -321,8 +321,6 @@ static int perf_inject__sched_stat(struct perf_tool *tool,
return perf_event__repipe(tool, event_sw, &sample_sw, machine); return perf_event__repipe(tool, event_sw, &sample_sw, machine);
} }
extern volatile int session_done;
static void sig_handler(int sig __maybe_unused) static void sig_handler(int sig __maybe_unused)
{ {
session_done = 1; session_done = 1;
......
...@@ -401,8 +401,6 @@ static int perf_report__setup_sample_type(struct perf_report *rep) ...@@ -401,8 +401,6 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
return 0; return 0;
} }
extern volatile int session_done;
static void sig_handler(int sig __maybe_unused) static void sig_handler(int sig __maybe_unused)
{ {
session_done = 1; session_done = 1;
...@@ -568,6 +566,9 @@ static int __cmd_report(struct perf_report *rep) ...@@ -568,6 +566,9 @@ static int __cmd_report(struct perf_report *rep)
} }
} }
if (session_done())
return 0;
if (nr_samples == 0) { if (nr_samples == 0) {
ui__error("The %s file has no samples!\n", session->filename); ui__error("The %s file has no samples!\n", session->filename);
return 0; return 0;
......
...@@ -553,8 +553,6 @@ static struct perf_tool perf_script = { ...@@ -553,8 +553,6 @@ static struct perf_tool perf_script = {
.ordering_requires_timestamps = true, .ordering_requires_timestamps = true,
}; };
extern volatile int session_done;
static void sig_handler(int sig __maybe_unused) static void sig_handler(int sig __maybe_unused)
{ {
session_done = 1; session_done = 1;
......
...@@ -611,6 +611,8 @@ void hists__collapse_resort(struct hists *hists) ...@@ -611,6 +611,8 @@ void hists__collapse_resort(struct hists *hists)
next = rb_first(root); next = rb_first(root);
while (next) { while (next) {
if (session_done())
break;
n = rb_entry(next, struct hist_entry, rb_node_in); n = rb_entry(next, struct hist_entry, rb_node_in);
next = rb_next(&n->rb_node_in); next = rb_next(&n->rb_node_in);
......
...@@ -531,6 +531,9 @@ static int flush_sample_queue(struct perf_session *s, ...@@ -531,6 +531,9 @@ static int flush_sample_queue(struct perf_session *s,
return 0; return 0;
list_for_each_entry_safe(iter, tmp, head, list) { list_for_each_entry_safe(iter, tmp, head, list) {
if (session_done())
return 0;
if (iter->timestamp > limit) if (iter->timestamp > limit)
break; break;
...@@ -1160,7 +1163,6 @@ static void perf_session__warn_about_errors(const struct perf_session *session, ...@@ -1160,7 +1163,6 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
} }
} }
#define session_done() (*(volatile int *)(&session_done))
volatile int session_done; volatile int session_done;
static int __perf_session__process_pipe_events(struct perf_session *self, static int __perf_session__process_pipe_events(struct perf_session *self,
...@@ -1372,10 +1374,13 @@ int __perf_session__process_events(struct perf_session *session, ...@@ -1372,10 +1374,13 @@ int __perf_session__process_events(struct perf_session *session,
"Processing events..."); "Processing events...");
} }
err = 0;
if (session_done())
goto out_err;
if (file_pos < file_size) if (file_pos < file_size)
goto more; goto more;
err = 0;
/* do the final flush for ordered samples */ /* do the final flush for ordered samples */
session->ordered_samples.next_flush = ULLONG_MAX; session->ordered_samples.next_flush = ULLONG_MAX;
err = flush_sample_queue(session, tool); err = flush_sample_queue(session, tool);
......
...@@ -124,4 +124,8 @@ int __perf_session__set_tracepoints_handlers(struct perf_session *session, ...@@ -124,4 +124,8 @@ int __perf_session__set_tracepoints_handlers(struct perf_session *session,
#define perf_session__set_tracepoints_handlers(session, array) \ #define perf_session__set_tracepoints_handlers(session, array) \
__perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array)) __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array))
extern volatile int session_done;
#define session_done() (*(volatile int *)(&session_done))
#endif /* __PERF_SESSION_H */ #endif /* __PERF_SESSION_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment