diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-07-06 08:23:03 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-12 11:02:55 -0400 |
commit | 37e39aa8a8a42ad2fd72b7c7349115dad8297d9c (patch) | |
tree | 7b95aae4e7b16661a4d25da00637a8189496ac04 /tools/perf/util/session.c | |
parent | 0a8cb85c200c4082ed7e57efd90dd9d18c8d40b6 (diff) |
perf tools: Rename ordered_samples struct to ordered_events
Following up with ordered_samples rename for ordered_samples and
sample_queue structs to ordered_events and ordered_event structs
respectively.
Also changing flush_sample_queue function name to ordered_events_flush.
No functional change was intended.
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-2dkrdvh0bbmzxdse437fcgls@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.c | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index a2c97ff1aa6a..6570282a7625 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -75,9 +75,9 @@ struct perf_session *perf_session__new(struct perf_data_file *file, | |||
75 | goto out; | 75 | goto out; |
76 | 76 | ||
77 | session->repipe = repipe; | 77 | session->repipe = repipe; |
78 | INIT_LIST_HEAD(&session->ordered_samples.samples); | 78 | INIT_LIST_HEAD(&session->ordered_events.samples); |
79 | INIT_LIST_HEAD(&session->ordered_samples.sample_cache); | 79 | INIT_LIST_HEAD(&session->ordered_events.sample_cache); |
80 | INIT_LIST_HEAD(&session->ordered_samples.to_free); | 80 | INIT_LIST_HEAD(&session->ordered_events.to_free); |
81 | machines__init(&session->machines); | 81 | machines__init(&session->machines); |
82 | 82 | ||
83 | if (file) { | 83 | if (file) { |
@@ -444,7 +444,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { | |||
444 | [PERF_RECORD_HEADER_MAX] = NULL, | 444 | [PERF_RECORD_HEADER_MAX] = NULL, |
445 | }; | 445 | }; |
446 | 446 | ||
447 | struct sample_queue { | 447 | struct ordered_event { |
448 | u64 timestamp; | 448 | u64 timestamp; |
449 | u64 file_offset; | 449 | u64 file_offset; |
450 | union perf_event *event; | 450 | union perf_event *event; |
@@ -453,14 +453,14 @@ struct sample_queue { | |||
453 | 453 | ||
454 | static void perf_session_free_sample_buffers(struct perf_session *session) | 454 | static void perf_session_free_sample_buffers(struct perf_session *session) |
455 | { | 455 | { |
456 | struct ordered_samples *os = &session->ordered_samples; | 456 | struct ordered_events *oe = &session->ordered_events; |
457 | 457 | ||
458 | while (!list_empty(&os->to_free)) { | 458 | while (!list_empty(&oe->to_free)) { |
459 | struct sample_queue *sq; | 459 | struct ordered_event *event; |
460 | 460 | ||
461 | sq = list_entry(os->to_free.next, struct sample_queue, list); | 461 | event = list_entry(oe->to_free.next, struct ordered_event, list); |
462 | list_del(&sq->list); | 462 | list_del(&event->list); |
463 | free(sq); | 463 | free(event); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
@@ -470,15 +470,15 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
470 | struct perf_tool *tool, | 470 | struct perf_tool *tool, |
471 | u64 file_offset); | 471 | u64 file_offset); |
472 | 472 | ||
473 | static int flush_sample_queue(struct perf_session *s, | 473 | static int ordered_events__flush(struct perf_session *s, |
474 | struct perf_tool *tool) | 474 | struct perf_tool *tool) |
475 | { | 475 | { |
476 | struct ordered_samples *os = &s->ordered_samples; | 476 | struct ordered_events *oe = &s->ordered_events; |
477 | struct list_head *head = &os->samples; | 477 | struct list_head *head = &oe->samples; |
478 | struct sample_queue *tmp, *iter; | 478 | struct ordered_event *tmp, *iter; |
479 | struct perf_sample sample; | 479 | struct perf_sample sample; |
480 | u64 limit = os->next_flush; | 480 | u64 limit = oe->next_flush; |
481 | u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL; | 481 | u64 last_ts = oe->last_sample ? oe->last_sample->timestamp : 0ULL; |
482 | bool show_progress = limit == ULLONG_MAX; | 482 | bool show_progress = limit == ULLONG_MAX; |
483 | struct ui_progress prog; | 483 | struct ui_progress prog; |
484 | int ret; | 484 | int ret; |
@@ -487,7 +487,7 @@ static int flush_sample_queue(struct perf_session *s, | |||
487 | return 0; | 487 | return 0; |
488 | 488 | ||
489 | if (show_progress) | 489 | if (show_progress) |
490 | ui_progress__init(&prog, os->nr_samples, "Processing time ordered events..."); | 490 | ui_progress__init(&prog, oe->nr_samples, "Processing time ordered events..."); |
491 | 491 | ||
492 | list_for_each_entry_safe(iter, tmp, head, list) { | 492 | list_for_each_entry_safe(iter, tmp, head, list) { |
493 | if (session_done()) | 493 | if (session_done()) |
@@ -506,20 +506,20 @@ static int flush_sample_queue(struct perf_session *s, | |||
506 | return ret; | 506 | return ret; |
507 | } | 507 | } |
508 | 508 | ||
509 | os->last_flush = iter->timestamp; | 509 | oe->last_flush = iter->timestamp; |
510 | list_del(&iter->list); | 510 | list_del(&iter->list); |
511 | list_add(&iter->list, &os->sample_cache); | 511 | list_add(&iter->list, &oe->sample_cache); |
512 | os->nr_samples--; | 512 | oe->nr_samples--; |
513 | 513 | ||
514 | if (show_progress) | 514 | if (show_progress) |
515 | ui_progress__update(&prog, 1); | 515 | ui_progress__update(&prog, 1); |
516 | } | 516 | } |
517 | 517 | ||
518 | if (list_empty(head)) { | 518 | if (list_empty(head)) { |
519 | os->last_sample = NULL; | 519 | oe->last_sample = NULL; |
520 | } else if (last_ts <= limit) { | 520 | } else if (last_ts <= limit) { |
521 | os->last_sample = | 521 | oe->last_sample = |
522 | list_entry(head->prev, struct sample_queue, list); | 522 | list_entry(head->prev, struct ordered_event, list); |
523 | } | 523 | } |
524 | 524 | ||
525 | return 0; | 525 | return 0; |
@@ -568,27 +568,27 @@ static int process_finished_round(struct perf_tool *tool, | |||
568 | union perf_event *event __maybe_unused, | 568 | union perf_event *event __maybe_unused, |
569 | struct perf_session *session) | 569 | struct perf_session *session) |
570 | { | 570 | { |
571 | int ret = flush_sample_queue(session, tool); | 571 | int ret = ordered_events__flush(session, tool); |
572 | if (!ret) | 572 | if (!ret) |
573 | session->ordered_samples.next_flush = session->ordered_samples.max_timestamp; | 573 | session->ordered_events.next_flush = session->ordered_events.max_timestamp; |
574 | 574 | ||
575 | return ret; | 575 | return ret; |
576 | } | 576 | } |
577 | 577 | ||
578 | /* The queue is ordered by time */ | 578 | /* The queue is ordered by time */ |
579 | static void __queue_event(struct sample_queue *new, struct perf_session *s) | 579 | static void __queue_event(struct ordered_event *new, struct perf_session *s) |
580 | { | 580 | { |
581 | struct ordered_samples *os = &s->ordered_samples; | 581 | struct ordered_events *oe = &s->ordered_events; |
582 | struct sample_queue *sample = os->last_sample; | 582 | struct ordered_event *sample = oe->last_sample; |
583 | u64 timestamp = new->timestamp; | 583 | u64 timestamp = new->timestamp; |
584 | struct list_head *p; | 584 | struct list_head *p; |
585 | 585 | ||
586 | ++os->nr_samples; | 586 | ++oe->nr_samples; |
587 | os->last_sample = new; | 587 | oe->last_sample = new; |
588 | 588 | ||
589 | if (!sample) { | 589 | if (!sample) { |
590 | list_add(&new->list, &os->samples); | 590 | list_add(&new->list, &oe->samples); |
591 | os->max_timestamp = timestamp; | 591 | oe->max_timestamp = timestamp; |
592 | return; | 592 | return; |
593 | } | 593 | } |
594 | 594 | ||
@@ -600,59 +600,59 @@ static void __queue_event(struct sample_queue *new, struct perf_session *s) | |||
600 | if (sample->timestamp <= timestamp) { | 600 | if (sample->timestamp <= timestamp) { |
601 | while (sample->timestamp <= timestamp) { | 601 | while (sample->timestamp <= timestamp) { |
602 | p = sample->list.next; | 602 | p = sample->list.next; |
603 | if (p == &os->samples) { | 603 | if (p == &oe->samples) { |
604 | list_add_tail(&new->list, &os->samples); | 604 | list_add_tail(&new->list, &oe->samples); |
605 | os->max_timestamp = timestamp; | 605 | oe->max_timestamp = timestamp; |
606 | return; | 606 | return; |
607 | } | 607 | } |
608 | sample = list_entry(p, struct sample_queue, list); | 608 | sample = list_entry(p, struct ordered_event, list); |
609 | } | 609 | } |
610 | list_add_tail(&new->list, &sample->list); | 610 | list_add_tail(&new->list, &sample->list); |
611 | } else { | 611 | } else { |
612 | while (sample->timestamp > timestamp) { | 612 | while (sample->timestamp > timestamp) { |
613 | p = sample->list.prev; | 613 | p = sample->list.prev; |
614 | if (p == &os->samples) { | 614 | if (p == &oe->samples) { |
615 | list_add(&new->list, &os->samples); | 615 | list_add(&new->list, &oe->samples); |
616 | return; | 616 | return; |
617 | } | 617 | } |
618 | sample = list_entry(p, struct sample_queue, list); | 618 | sample = list_entry(p, struct ordered_event, list); |
619 | } | 619 | } |
620 | list_add(&new->list, &sample->list); | 620 | list_add(&new->list, &sample->list); |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct sample_queue)) | 624 | #define MAX_SAMPLE_BUFFER (64 * 1024 / sizeof(struct ordered_event)) |
625 | 625 | ||
626 | int perf_session_queue_event(struct perf_session *s, union perf_event *event, | 626 | int perf_session_queue_event(struct perf_session *s, union perf_event *event, |
627 | struct perf_sample *sample, u64 file_offset) | 627 | struct perf_sample *sample, u64 file_offset) |
628 | { | 628 | { |
629 | struct ordered_samples *os = &s->ordered_samples; | 629 | struct ordered_events *oe = &s->ordered_events; |
630 | struct list_head *sc = &os->sample_cache; | 630 | struct list_head *sc = &oe->sample_cache; |
631 | u64 timestamp = sample->time; | 631 | u64 timestamp = sample->time; |
632 | struct sample_queue *new; | 632 | struct ordered_event *new; |
633 | 633 | ||
634 | if (!timestamp || timestamp == ~0ULL) | 634 | if (!timestamp || timestamp == ~0ULL) |
635 | return -ETIME; | 635 | return -ETIME; |
636 | 636 | ||
637 | if (timestamp < s->ordered_samples.last_flush) { | 637 | if (timestamp < s->ordered_events.last_flush) { |
638 | printf("Warning: Timestamp below last timeslice flush\n"); | 638 | printf("Warning: Timestamp below last timeslice flush\n"); |
639 | return -EINVAL; | 639 | return -EINVAL; |
640 | } | 640 | } |
641 | 641 | ||
642 | if (!list_empty(sc)) { | 642 | if (!list_empty(sc)) { |
643 | new = list_entry(sc->next, struct sample_queue, list); | 643 | new = list_entry(sc->next, struct ordered_event, list); |
644 | list_del(&new->list); | 644 | list_del(&new->list); |
645 | } else if (os->sample_buffer) { | 645 | } else if (oe->sample_buffer) { |
646 | new = os->sample_buffer + os->sample_buffer_idx; | 646 | new = oe->sample_buffer + oe->sample_buffer_idx; |
647 | if (++os->sample_buffer_idx == MAX_SAMPLE_BUFFER) | 647 | if (++oe->sample_buffer_idx == MAX_SAMPLE_BUFFER) |
648 | os->sample_buffer = NULL; | 648 | oe->sample_buffer = NULL; |
649 | } else { | 649 | } else { |
650 | os->sample_buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new)); | 650 | oe->sample_buffer = malloc(MAX_SAMPLE_BUFFER * sizeof(*new)); |
651 | if (!os->sample_buffer) | 651 | if (!oe->sample_buffer) |
652 | return -ENOMEM; | 652 | return -ENOMEM; |
653 | list_add(&os->sample_buffer->list, &os->to_free); | 653 | list_add(&oe->sample_buffer->list, &oe->to_free); |
654 | os->sample_buffer_idx = 2; | 654 | oe->sample_buffer_idx = 2; |
655 | new = os->sample_buffer + 1; | 655 | new = oe->sample_buffer + 1; |
656 | } | 656 | } |
657 | 657 | ||
658 | new->timestamp = timestamp; | 658 | new->timestamp = timestamp; |
@@ -1222,8 +1222,8 @@ more: | |||
1222 | goto more; | 1222 | goto more; |
1223 | done: | 1223 | done: |
1224 | /* do the final flush for ordered samples */ | 1224 | /* do the final flush for ordered samples */ |
1225 | session->ordered_samples.next_flush = ULLONG_MAX; | 1225 | session->ordered_events.next_flush = ULLONG_MAX; |
1226 | err = flush_sample_queue(session, tool); | 1226 | err = ordered_events__flush(session, tool); |
1227 | out_err: | 1227 | out_err: |
1228 | free(buf); | 1228 | free(buf); |
1229 | perf_session__warn_about_errors(session, tool); | 1229 | perf_session__warn_about_errors(session, tool); |
@@ -1368,8 +1368,8 @@ more: | |||
1368 | 1368 | ||
1369 | out: | 1369 | out: |
1370 | /* do the final flush for ordered samples */ | 1370 | /* do the final flush for ordered samples */ |
1371 | session->ordered_samples.next_flush = ULLONG_MAX; | 1371 | session->ordered_events.next_flush = ULLONG_MAX; |
1372 | err = flush_sample_queue(session, tool); | 1372 | err = ordered_events__flush(session, tool); |
1373 | out_err: | 1373 | out_err: |
1374 | ui_progress__finish(); | 1374 | ui_progress__finish(); |
1375 | perf_session__warn_about_errors(session, tool); | 1375 | perf_session__warn_about_errors(session, tool); |