diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2010-11-30 12:49:46 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-11-30 16:59:34 -0500 |
commit | 55b44629f599a2305265ae9c77f9d9bcfd6ddc17 (patch) | |
tree | 2f6f0cacdb78c09b7fc90152bf0e2b89a47ee0d3 /tools/perf/util/session.c | |
parent | d6513281c5f728d138ba895d600b9788e51508b1 (diff) |
perf session: Use sensible mmap size
On 64bit we can map the whole file in one go, on 32bit we can at least map
32MB and not map/unmap tiny chunks of the file.
Base the progress bar on 1/16 of the data size.
Preparatory patch to get rid of the malloc/memcpy/free of trace data.
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20101130163820.213687773@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
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 | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 9c806ab565ea..752577fdb16e 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -101,7 +101,15 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc | |||
101 | INIT_LIST_HEAD(&self->dead_threads); | 101 | INIT_LIST_HEAD(&self->dead_threads); |
102 | self->hists_tree = RB_ROOT; | 102 | self->hists_tree = RB_ROOT; |
103 | self->last_match = NULL; | 103 | self->last_match = NULL; |
104 | self->mmap_window = 32; | 104 | /* |
105 | * On 64bit we can mmap the data file in one go. No need for tiny mmap | ||
106 | * slices. On 32bit we use 32MB. | ||
107 | */ | ||
108 | #if BITS_PER_LONG == 64 | ||
109 | self->mmap_window = ULLONG_MAX; | ||
110 | #else | ||
111 | self->mmap_window = 32 * 1024 * 1024ULL; | ||
112 | #endif | ||
105 | self->machines = RB_ROOT; | 113 | self->machines = RB_ROOT; |
106 | self->repipe = repipe; | 114 | self->repipe = repipe; |
107 | INIT_LIST_HEAD(&self->ordered_samples.samples); | 115 | INIT_LIST_HEAD(&self->ordered_samples.samples); |
@@ -738,18 +746,14 @@ int __perf_session__process_events(struct perf_session *session, | |||
738 | u64 data_offset, u64 data_size, | 746 | u64 data_offset, u64 data_size, |
739 | u64 file_size, struct perf_event_ops *ops) | 747 | u64 file_size, struct perf_event_ops *ops) |
740 | { | 748 | { |
741 | u64 head, page_offset, file_offset, file_pos; | 749 | u64 head, page_offset, file_offset, file_pos, progress_next; |
742 | int err, mmap_prot, mmap_flags; | 750 | int err, mmap_prot, mmap_flags; |
743 | struct ui_progress *progress; | 751 | struct ui_progress *progress; |
744 | size_t page_size; | 752 | size_t page_size, mmap_size; |
745 | event_t *event; | 753 | event_t *event; |
746 | uint32_t size; | 754 | uint32_t size; |
747 | char *buf; | 755 | char *buf; |
748 | 756 | ||
749 | progress = ui_progress__new("Processing events...", session->size); | ||
750 | if (progress == NULL) | ||
751 | return -1; | ||
752 | |||
753 | perf_event_ops__fill_defaults(ops); | 757 | perf_event_ops__fill_defaults(ops); |
754 | 758 | ||
755 | page_size = sysconf(_SC_PAGESIZE); | 759 | page_size = sysconf(_SC_PAGESIZE); |
@@ -761,6 +765,15 @@ int __perf_session__process_events(struct perf_session *session, | |||
761 | if (data_offset + data_size < file_size) | 765 | if (data_offset + data_size < file_size) |
762 | file_size = data_offset + data_size; | 766 | file_size = data_offset + data_size; |
763 | 767 | ||
768 | progress_next = file_size / 16; | ||
769 | progress = ui_progress__new("Processing events...", file_size); | ||
770 | if (progress == NULL) | ||
771 | return -1; | ||
772 | |||
773 | mmap_size = session->mmap_window; | ||
774 | if (mmap_size > file_size) | ||
775 | mmap_size = file_size; | ||
776 | |||
764 | mmap_prot = PROT_READ; | 777 | mmap_prot = PROT_READ; |
765 | mmap_flags = MAP_SHARED; | 778 | mmap_flags = MAP_SHARED; |
766 | 779 | ||
@@ -769,15 +782,14 @@ int __perf_session__process_events(struct perf_session *session, | |||
769 | mmap_flags = MAP_PRIVATE; | 782 | mmap_flags = MAP_PRIVATE; |
770 | } | 783 | } |
771 | remap: | 784 | remap: |
772 | buf = mmap(NULL, page_size * session->mmap_window, mmap_prot, | 785 | buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, session->fd, |
773 | mmap_flags, session->fd, file_offset); | 786 | file_offset); |
774 | if (buf == MAP_FAILED) { | 787 | if (buf == MAP_FAILED) { |
775 | pr_err("failed to mmap file\n"); | 788 | pr_err("failed to mmap file\n"); |
776 | err = -errno; | 789 | err = -errno; |
777 | goto out_err; | 790 | goto out_err; |
778 | } | 791 | } |
779 | file_pos = file_offset + head; | 792 | file_pos = file_offset + head; |
780 | ui_progress__update(progress, file_offset); | ||
781 | 793 | ||
782 | more: | 794 | more: |
783 | event = (event_t *)(buf + head); | 795 | event = (event_t *)(buf + head); |
@@ -788,10 +800,10 @@ more: | |||
788 | if (size == 0) | 800 | if (size == 0) |
789 | size = 8; | 801 | size = 8; |
790 | 802 | ||
791 | if (head + event->header.size >= page_size * session->mmap_window) { | 803 | if (head + event->header.size >= mmap_size) { |
792 | int munmap_ret; | 804 | int munmap_ret; |
793 | 805 | ||
794 | munmap_ret = munmap(buf, page_size * session->mmap_window); | 806 | munmap_ret = munmap(buf, mmap_size); |
795 | assert(munmap_ret == 0); | 807 | assert(munmap_ret == 0); |
796 | 808 | ||
797 | page_offset = page_size * (head / page_size); | 809 | page_offset = page_size * (head / page_size); |
@@ -823,6 +835,11 @@ more: | |||
823 | head += size; | 835 | head += size; |
824 | file_pos += size; | 836 | file_pos += size; |
825 | 837 | ||
838 | if (file_pos >= progress_next) { | ||
839 | progress_next += file_size / 16; | ||
840 | ui_progress__update(progress, file_pos); | ||
841 | } | ||
842 | |||
826 | if (file_pos < file_size) | 843 | if (file_pos < file_size) |
827 | goto more; | 844 | goto more; |
828 | 845 | ||