diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-09-17 15:34:28 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-09-19 10:32:17 -0400 |
commit | 33e940a25daaea71be054e8a4bdb61730cc9ebbc (patch) | |
tree | e8d2f1f31f631290eb11da1c2b5a609b09a360be | |
parent | e955d5c434009b661dbb200c601254b0c2d9940a (diff) |
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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-inject.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-script.c | 2 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 2 | ||||
-rw-r--r-- | tools/perf/util/session.c | 9 | ||||
-rw-r--r-- | tools/perf/util/session.h | 4 |
6 files changed, 16 insertions, 8 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 423875c999b2..afe377b2884f 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -321,8 +321,6 @@ found: | |||
321 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); | 321 | return perf_event__repipe(tool, event_sw, &sample_sw, machine); |
322 | } | 322 | } |
323 | 323 | ||
324 | extern volatile int session_done; | ||
325 | |||
326 | static void sig_handler(int sig __maybe_unused) | 324 | static void sig_handler(int sig __maybe_unused) |
327 | { | 325 | { |
328 | session_done = 1; | 326 | session_done = 1; |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 8e50d8d77419..72eae7498c09 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -401,8 +401,6 @@ static int perf_report__setup_sample_type(struct perf_report *rep) | |||
401 | return 0; | 401 | return 0; |
402 | } | 402 | } |
403 | 403 | ||
404 | extern volatile int session_done; | ||
405 | |||
406 | static void sig_handler(int sig __maybe_unused) | 404 | static void sig_handler(int sig __maybe_unused) |
407 | { | 405 | { |
408 | session_done = 1; | 406 | session_done = 1; |
@@ -568,6 +566,9 @@ static int __cmd_report(struct perf_report *rep) | |||
568 | } | 566 | } |
569 | } | 567 | } |
570 | 568 | ||
569 | if (session_done()) | ||
570 | return 0; | ||
571 | |||
571 | if (nr_samples == 0) { | 572 | if (nr_samples == 0) { |
572 | ui__error("The %s file has no samples!\n", session->filename); | 573 | ui__error("The %s file has no samples!\n", session->filename); |
573 | return 0; | 574 | return 0; |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 7f31a3ded1b6..9c333ff3dfeb 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -553,8 +553,6 @@ static struct perf_tool perf_script = { | |||
553 | .ordering_requires_timestamps = true, | 553 | .ordering_requires_timestamps = true, |
554 | }; | 554 | }; |
555 | 555 | ||
556 | extern volatile int session_done; | ||
557 | |||
558 | static void sig_handler(int sig __maybe_unused) | 556 | static void sig_handler(int sig __maybe_unused) |
559 | { | 557 | { |
560 | session_done = 1; | 558 | session_done = 1; |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 46a0d35a05e1..9ff6cf3e9a99 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -611,6 +611,8 @@ void hists__collapse_resort(struct hists *hists) | |||
611 | next = rb_first(root); | 611 | next = rb_first(root); |
612 | 612 | ||
613 | while (next) { | 613 | while (next) { |
614 | if (session_done()) | ||
615 | break; | ||
614 | n = rb_entry(next, struct hist_entry, rb_node_in); | 616 | n = rb_entry(next, struct hist_entry, rb_node_in); |
615 | next = rb_next(&n->rb_node_in); | 617 | next = rb_next(&n->rb_node_in); |
616 | 618 | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 51f5edf2a6d0..70ffa41518f3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -531,6 +531,9 @@ static int flush_sample_queue(struct perf_session *s, | |||
531 | return 0; | 531 | return 0; |
532 | 532 | ||
533 | list_for_each_entry_safe(iter, tmp, head, list) { | 533 | list_for_each_entry_safe(iter, tmp, head, list) { |
534 | if (session_done()) | ||
535 | return 0; | ||
536 | |||
534 | if (iter->timestamp > limit) | 537 | if (iter->timestamp > limit) |
535 | break; | 538 | break; |
536 | 539 | ||
@@ -1160,7 +1163,6 @@ static void perf_session__warn_about_errors(const struct perf_session *session, | |||
1160 | } | 1163 | } |
1161 | } | 1164 | } |
1162 | 1165 | ||
1163 | #define session_done() (*(volatile int *)(&session_done)) | ||
1164 | volatile int session_done; | 1166 | volatile int session_done; |
1165 | 1167 | ||
1166 | static int __perf_session__process_pipe_events(struct perf_session *self, | 1168 | static int __perf_session__process_pipe_events(struct perf_session *self, |
@@ -1372,10 +1374,13 @@ more: | |||
1372 | "Processing events..."); | 1374 | "Processing events..."); |
1373 | } | 1375 | } |
1374 | 1376 | ||
1377 | err = 0; | ||
1378 | if (session_done()) | ||
1379 | goto out_err; | ||
1380 | |||
1375 | if (file_pos < file_size) | 1381 | if (file_pos < file_size) |
1376 | goto more; | 1382 | goto more; |
1377 | 1383 | ||
1378 | err = 0; | ||
1379 | /* do the final flush for ordered samples */ | 1384 | /* do the final flush for ordered samples */ |
1380 | session->ordered_samples.next_flush = ULLONG_MAX; | 1385 | session->ordered_samples.next_flush = ULLONG_MAX; |
1381 | err = flush_sample_queue(session, tool); | 1386 | err = flush_sample_queue(session, tool); |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 3aa75fb2225f..04bf7373a7e5 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -124,4 +124,8 @@ int __perf_session__set_tracepoints_handlers(struct perf_session *session, | |||
124 | 124 | ||
125 | #define perf_session__set_tracepoints_handlers(session, array) \ | 125 | #define perf_session__set_tracepoints_handlers(session, array) \ |
126 | __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array)) | 126 | __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array)) |
127 | |||
128 | extern volatile int session_done; | ||
129 | |||
130 | #define session_done() (*(volatile int *)(&session_done)) | ||
127 | #endif /* __PERF_SESSION_H */ | 131 | #endif /* __PERF_SESSION_H */ |