diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2009-12-14 19:27:58 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-14 19:41:02 -0500 |
| commit | 5c45bd2c0f7bbc7fd97e7e7e8825012b7ab069ac (patch) | |
| tree | 5b1a74b2dceeea5d8f94b1029521cd9fe3e9bf9f | |
| parent | 37250afc820f712eb0de4340d25c9625ef6fa634 (diff) | |
The reading of page info belongs in the mapping of the page
We need to read the page info when a page is mapped, not when
the first element is read.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-input.c | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/trace-input.c b/trace-input.c index f37fb6a..7051709 100644 --- a/trace-input.c +++ b/trace-input.c | |||
| @@ -514,6 +514,39 @@ static void free_page(struct tracecmd_input *handle, int cpu) | |||
| 514 | handle->cpu_data[cpu].page = NULL; | 514 | handle->cpu_data[cpu].page = NULL; |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | /* | ||
| 518 | * Page is mapped, now read in the page header info. | ||
| 519 | */ | ||
| 520 | static int update_page_info(struct tracecmd_input *handle, int cpu) | ||
| 521 | { | ||
| 522 | struct pevent *pevent = handle->pevent; | ||
| 523 | void *ptr = handle->cpu_data[cpu].page; | ||
| 524 | |||
| 525 | /* FIXME: handle header page */ | ||
| 526 | if (pevent->header_page_ts_size != 8) { | ||
| 527 | warning("expected a long long type for timestamp"); | ||
| 528 | return -1; | ||
| 529 | } | ||
| 530 | |||
| 531 | handle->cpu_data[cpu].timestamp = data2host8(pevent, ptr); | ||
| 532 | ptr += 8; | ||
| 533 | switch (pevent->header_page_size_size) { | ||
| 534 | case 4: | ||
| 535 | handle->cpu_data[cpu].page_size = data2host4(pevent, ptr); | ||
| 536 | break; | ||
| 537 | case 8: | ||
| 538 | handle->cpu_data[cpu].page_size = data2host8(pevent, ptr); | ||
| 539 | break; | ||
| 540 | default: | ||
| 541 | warning("bad long size"); | ||
| 542 | return -1; | ||
| 543 | } | ||
| 544 | |||
| 545 | handle->cpu_data[cpu].index = 0; | ||
| 546 | |||
| 547 | return 0; | ||
| 548 | } | ||
| 549 | |||
| 517 | static int get_read_page(struct tracecmd_input *handle, int cpu, | 550 | static int get_read_page(struct tracecmd_input *handle, int cpu, |
| 518 | off64_t offset) | 551 | off64_t offset) |
| 519 | { | 552 | { |
| @@ -537,8 +570,8 @@ static int get_read_page(struct tracecmd_input *handle, int cpu, | |||
| 537 | /* reset the file pointer back */ | 570 | /* reset the file pointer back */ |
| 538 | lseek64(handle->fd, save_seek, SEEK_SET); | 571 | lseek64(handle->fd, save_seek, SEEK_SET); |
| 539 | 572 | ||
| 540 | handle->cpu_data[cpu].timestamp = | 573 | if (update_page_info(handle, cpu)) |
| 541 | data2host8(handle->pevent, handle->cpu_data[cpu].page); | 574 | return -1; |
| 542 | 575 | ||
| 543 | return 0; | 576 | return 0; |
| 544 | } | 577 | } |
| @@ -570,8 +603,8 @@ static int get_page(struct tracecmd_input *handle, int cpu, | |||
| 570 | if (handle->cpu_data[cpu].page == MAP_FAILED) | 603 | if (handle->cpu_data[cpu].page == MAP_FAILED) |
| 571 | return -1; | 604 | return -1; |
| 572 | 605 | ||
| 573 | handle->cpu_data[cpu].timestamp = | 606 | if (update_page_info(handle, cpu)) |
| 574 | data2host8(handle->pevent, handle->cpu_data[cpu].page); | 607 | return -1; |
| 575 | 608 | ||
| 576 | return 0; | 609 | return 0; |
| 577 | } | 610 | } |
| @@ -928,29 +961,8 @@ tracecmd_peek_data(struct tracecmd_input *handle, int cpu) | |||
| 928 | if (!page) | 961 | if (!page) |
| 929 | return NULL; | 962 | return NULL; |
| 930 | 963 | ||
| 931 | if (!index) { | 964 | if (!index) |
| 932 | /* FIXME: handle header page */ | ||
| 933 | if (pevent->header_page_ts_size != 8) { | ||
| 934 | warning("expected a long long type for timestamp"); | ||
| 935 | return NULL; | ||
| 936 | } | ||
| 937 | handle->cpu_data[cpu].timestamp = data2host8(pevent, ptr); | ||
| 938 | ptr += 8; | ||
| 939 | switch (pevent->header_page_size_size) { | ||
| 940 | case 4: | ||
| 941 | handle->cpu_data[cpu].page_size = data2host4(pevent,ptr); | ||
| 942 | ptr += 4; | ||
| 943 | break; | ||
| 944 | case 8: | ||
| 945 | handle->cpu_data[cpu].page_size = data2host8(pevent, ptr); | ||
| 946 | ptr += 8; | ||
| 947 | break; | ||
| 948 | default: | ||
| 949 | warning("bad long size"); | ||
| 950 | return NULL; | ||
| 951 | } | ||
| 952 | ptr = handle->cpu_data[cpu].page + pevent->header_page_data_offset; | 965 | ptr = handle->cpu_data[cpu].page + pevent->header_page_data_offset; |
| 953 | } | ||
| 954 | 966 | ||
| 955 | read_again: | 967 | read_again: |
| 956 | index = calc_index(handle, ptr, cpu); | 968 | index = calc_index(handle, ptr, cpu); |
| @@ -1078,8 +1090,11 @@ static int init_cpu(struct tracecmd_input *handle, int cpu) | |||
| 1078 | 1090 | ||
| 1079 | return init_read(handle, cpu); | 1091 | return init_read(handle, cpu); |
| 1080 | } | 1092 | } |
| 1081 | handle->cpu_data[cpu].timestamp = | 1093 | |
| 1082 | data2host8(handle->pevent, handle->cpu_data[cpu].page); | 1094 | |
| 1095 | if (update_page_info(handle, cpu)) | ||
| 1096 | return -1; | ||
| 1097 | |||
| 1083 | return 0; | 1098 | return 0; |
| 1084 | } | 1099 | } |
| 1085 | 1100 | ||
