diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-12-12 16:36:12 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-12 16:36:12 -0500 |
commit | 0d3108639ed717b2f2c9cf5e0868cdc2c2d19cd1 (patch) | |
tree | 0c25b9dac64447e3af9e74c3bf9ee02e7668f8d2 | |
parent | 295246ff194b941d48a303be6766b23251110ff5 (diff) |
Move page calculations to get_page
The get_page code shoud calculate the page calculations of the cpu
index, offset and size.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-input.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/trace-input.c b/trace-input.c index 681da4a..29b44c6 100644 --- a/trace-input.c +++ b/trace-input.c | |||
@@ -550,6 +550,11 @@ static int get_page(struct tracecmd_input *handle, int cpu, | |||
550 | return -1; | 550 | return -1; |
551 | } | 551 | } |
552 | 552 | ||
553 | handle->cpu_data[cpu].offset = offset; | ||
554 | handle->cpu_data[cpu].size = (handle->cpu_data[cpu].file_offset + | ||
555 | handle->cpu_data[cpu].file_size) - | ||
556 | offset; | ||
557 | |||
553 | if (handle->read_page) | 558 | if (handle->read_page) |
554 | return get_read_page(handle, cpu, offset); | 559 | return get_read_page(handle, cpu, offset); |
555 | 560 | ||
@@ -720,32 +725,8 @@ find_and_read_event(struct tracecmd_input *handle, unsigned long long offset, | |||
720 | /* Move this cpu index to point to this offest */ | 725 | /* Move this cpu index to point to this offest */ |
721 | page_offset = offset & ~(handle->page_size - 1); | 726 | page_offset = offset & ~(handle->page_size - 1); |
722 | 727 | ||
723 | if (handle->cpu_data[cpu].page) { | 728 | if (get_page(handle, cpu, page_offset)) |
724 | /* | 729 | return NULL; |
725 | * If a page already exists, then we need to reset | ||
726 | * it to point to the page with the data we want. | ||
727 | */ | ||
728 | |||
729 | handle->cpu_data[cpu].offset = page_offset; | ||
730 | handle->cpu_data[cpu].size = (handle->cpu_data[cpu].file_offset + | ||
731 | handle->cpu_data[cpu].file_size) - | ||
732 | page_offset; | ||
733 | |||
734 | if (get_page(handle, cpu, page_offset)) | ||
735 | return NULL; | ||
736 | } else { | ||
737 | /* | ||
738 | * We need to map a new page. Just set it up the cpu_data | ||
739 | * to the position we want. | ||
740 | */ | ||
741 | handle->cpu_data[cpu].offset = page_offset; | ||
742 | handle->cpu_data[cpu].size = (handle->cpu_data[cpu].file_offset + | ||
743 | handle->cpu_data[cpu].file_size) - | ||
744 | page_offset; | ||
745 | |||
746 | if (init_cpu(handle, cpu)) | ||
747 | return NULL; | ||
748 | } | ||
749 | 730 | ||
750 | if (pcpu) | 731 | if (pcpu) |
751 | *pcpu = cpu; | 732 | *pcpu = cpu; |