aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2014-06-05 04:29:45 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-08-12 11:02:56 -0400
commitd8836b5d1736632aa1a38a8ed0c9361c96d7c95a (patch)
tree1371f0e513c28426da4e2800f1420368e0f7c293 /tools/perf/util/session.c
parentc64c7e1a5addf93b7dec98a27b8c48457506aa06 (diff)
perf tools: Factor ordered_events__flush to be more generic
Centralizing the next_flush calculation under the ordered_events__flush function. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: David Ahern <dsahern@gmail.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jean Pihet <jean.pihet@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-srwunsy7o5wl17vpt4a10oxp@git.kernel.org 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.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ff0188c65783..72c7b0d3d0dc 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -451,6 +451,11 @@ struct ordered_event {
451 struct list_head list; 451 struct list_head list;
452}; 452};
453 453
454enum oe_flush {
455 OE_FLUSH__FINAL,
456 OE_FLUSH__ROUND,
457};
458
454static void perf_session_free_sample_buffers(struct perf_session *session) 459static void perf_session_free_sample_buffers(struct perf_session *session)
455{ 460{
456 struct ordered_events *oe = &session->ordered_events; 461 struct ordered_events *oe = &session->ordered_events;
@@ -564,8 +569,8 @@ static int perf_session_deliver_event(struct perf_session *session,
564 struct perf_tool *tool, 569 struct perf_tool *tool,
565 u64 file_offset); 570 u64 file_offset);
566 571
567static int ordered_events__flush(struct perf_session *s, 572static int __ordered_events__flush(struct perf_session *s,
568 struct perf_tool *tool) 573 struct perf_tool *tool)
569{ 574{
570 struct ordered_events *oe = &s->ordered_events; 575 struct ordered_events *oe = &s->ordered_events;
571 struct list_head *head = &oe->events; 576 struct list_head *head = &oe->events;
@@ -615,6 +620,32 @@ static int ordered_events__flush(struct perf_session *s,
615 return 0; 620 return 0;
616} 621}
617 622
623static int ordered_events__flush(struct perf_session *s, struct perf_tool *tool,
624 enum oe_flush how)
625{
626 struct ordered_events *oe = &s->ordered_events;
627 int err;
628
629 switch (how) {
630 case OE_FLUSH__FINAL:
631 oe->next_flush = ULLONG_MAX;
632 break;
633
634 case OE_FLUSH__ROUND:
635 default:
636 break;
637 };
638
639 err = __ordered_events__flush(s, tool);
640
641 if (!err) {
642 if (how == OE_FLUSH__ROUND)
643 oe->next_flush = oe->max_timestamp;
644 }
645
646 return err;
647}
648
618/* 649/*
619 * When perf record finishes a pass on every buffers, it records this pseudo 650 * When perf record finishes a pass on every buffers, it records this pseudo
620 * event. 651 * event.
@@ -658,11 +689,7 @@ static int process_finished_round(struct perf_tool *tool,
658 union perf_event *event __maybe_unused, 689 union perf_event *event __maybe_unused,
659 struct perf_session *session) 690 struct perf_session *session)
660{ 691{
661 int ret = ordered_events__flush(session, tool); 692 return ordered_events__flush(session, tool, OE_FLUSH__ROUND);
662 if (!ret)
663 session->ordered_events.next_flush = session->ordered_events.max_timestamp;
664
665 return ret;
666} 693}
667 694
668int perf_session_queue_event(struct perf_session *s, union perf_event *event, 695int perf_session_queue_event(struct perf_session *s, union perf_event *event,
@@ -1247,8 +1274,7 @@ more:
1247 goto more; 1274 goto more;
1248done: 1275done:
1249 /* do the final flush for ordered samples */ 1276 /* do the final flush for ordered samples */
1250 session->ordered_events.next_flush = ULLONG_MAX; 1277 err = ordered_events__flush(session, tool, OE_FLUSH__FINAL);
1251 err = ordered_events__flush(session, tool);
1252out_err: 1278out_err:
1253 free(buf); 1279 free(buf);
1254 perf_session__warn_about_errors(session, tool); 1280 perf_session__warn_about_errors(session, tool);
@@ -1393,8 +1419,7 @@ more:
1393 1419
1394out: 1420out:
1395 /* do the final flush for ordered samples */ 1421 /* do the final flush for ordered samples */
1396 session->ordered_events.next_flush = ULLONG_MAX; 1422 err = ordered_events__flush(session, tool, OE_FLUSH__FINAL);
1397 err = ordered_events__flush(session, tool);
1398out_err: 1423out_err:
1399 ui_progress__finish(); 1424 ui_progress__finish();
1400 perf_session__warn_about_errors(session, tool); 1425 perf_session__warn_about_errors(session, tool);