diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-12-18 11:21:07 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-18 11:47:30 -0500 |
commit | 3b1697097728ce78a19f1a09d4b1b725b3a3a18f (patch) | |
tree | af9dce85780a34e4eef9c73cd7987b9a0cde8927 | |
parent | 36f9ea18b58d7db2714651f324d95e841a8ef41c (diff) |
trace-cmd/pevent: Add cpu to struct record
Most routines that use a record also require a CPU number.
It just makes sense to move the CPU to the record.
This patch also renames some ambiguous "data" to "record"
variables.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | parse-events.h | 1 | ||||
-rw-r--r-- | trace-input.c | 53 |
2 files changed, 28 insertions, 26 deletions
diff --git a/parse-events.h b/parse-events.h index ba80efd..b4135a4 100644 --- a/parse-events.h +++ b/parse-events.h | |||
@@ -20,6 +20,7 @@ struct record { | |||
20 | int record_size; /* size of binary record */ | 20 | int record_size; /* size of binary record */ |
21 | int size; /* size of data */ | 21 | int size; /* size of data */ |
22 | void *data; | 22 | void *data; |
23 | int cpu; | ||
23 | }; | 24 | }; |
24 | 25 | ||
25 | /* | 26 | /* |
diff --git a/trace-input.c b/trace-input.c index ee9177f..1657b2a 100644 --- a/trace-input.c +++ b/trace-input.c | |||
@@ -1020,31 +1020,31 @@ struct record * | |||
1020 | tracecmd_translate_data(struct tracecmd_input *handle, | 1020 | tracecmd_translate_data(struct tracecmd_input *handle, |
1021 | void *ptr, int size) | 1021 | void *ptr, int size) |
1022 | { | 1022 | { |
1023 | struct record *data; | 1023 | struct record *record; |
1024 | unsigned int type_len; | 1024 | unsigned int type_len; |
1025 | 1025 | ||
1026 | /* minimum record read is 8, (warn?) (TODO: make 8 into macro) */ | 1026 | /* minimum record read is 8, (warn?) (TODO: make 8 into macro) */ |
1027 | if (size < 8) | 1027 | if (size < 8) |
1028 | return NULL; | 1028 | return NULL; |
1029 | 1029 | ||
1030 | data = malloc(sizeof(*data)); | 1030 | record = malloc(sizeof(*record)); |
1031 | if (!data) | 1031 | if (!record) |
1032 | return NULL; | 1032 | return NULL; |
1033 | memset(data, 0, sizeof(*data)); | 1033 | memset(record, 0, sizeof(*record)); |
1034 | 1034 | ||
1035 | data->data = ptr; | 1035 | record->data = ptr; |
1036 | type_len = translate_data(handle, &data->data, &data->ts, &data->size); | 1036 | type_len = translate_data(handle, &record->data, &record->ts, &record->size); |
1037 | switch (type_len) { | 1037 | switch (type_len) { |
1038 | case RINGBUF_TYPE_PADDING: | 1038 | case RINGBUF_TYPE_PADDING: |
1039 | case RINGBUF_TYPE_TIME_EXTEND: | 1039 | case RINGBUF_TYPE_TIME_EXTEND: |
1040 | case RINGBUF_TYPE_TIME_STAMP: | 1040 | case RINGBUF_TYPE_TIME_STAMP: |
1041 | data->data = NULL; | 1041 | record->data = NULL; |
1042 | break; | 1042 | break; |
1043 | default: | 1043 | default: |
1044 | break; | 1044 | break; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | return data; | 1047 | return record; |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | /** | 1050 | /** |
@@ -1061,7 +1061,7 @@ struct record * | |||
1061 | tracecmd_peek_data(struct tracecmd_input *handle, int cpu) | 1061 | tracecmd_peek_data(struct tracecmd_input *handle, int cpu) |
1062 | { | 1062 | { |
1063 | struct pevent *pevent = handle->pevent; | 1063 | struct pevent *pevent = handle->pevent; |
1064 | struct record *data; | 1064 | struct record *record; |
1065 | void *page = handle->cpu_data[cpu].page; | 1065 | void *page = handle->cpu_data[cpu].page; |
1066 | int index = handle->cpu_data[cpu].index; | 1066 | int index = handle->cpu_data[cpu].index; |
1067 | void *ptr = page + index; | 1067 | void *ptr = page + index; |
@@ -1091,14 +1091,14 @@ read_again: | |||
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | if (pevent->old_format) { | 1093 | if (pevent->old_format) { |
1094 | data = read_old_format(handle, &ptr, cpu); | 1094 | record = read_old_format(handle, &ptr, cpu); |
1095 | if (!data) { | 1095 | if (!record) { |
1096 | if (!ptr) | 1096 | if (!ptr) |
1097 | return NULL; | 1097 | return NULL; |
1098 | goto read_again; | 1098 | goto read_again; |
1099 | } | 1099 | } |
1100 | 1100 | record->cpu = cpu; | |
1101 | return data; | 1101 | return record; |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | type_len = translate_data(handle, &ptr, &extend, &length); | 1104 | type_len = translate_data(handle, &ptr, &extend, &length); |
@@ -1121,24 +1121,25 @@ read_again: | |||
1121 | 1121 | ||
1122 | handle->cpu_data[cpu].timestamp += extend; | 1122 | handle->cpu_data[cpu].timestamp += extend; |
1123 | 1123 | ||
1124 | data = malloc(sizeof(*data)); | 1124 | record = malloc(sizeof(*record)); |
1125 | if (!data) | 1125 | if (!record) |
1126 | return NULL; | 1126 | return NULL; |
1127 | memset(data, 0, sizeof(*data)); | 1127 | memset(record, 0, sizeof(*record)); |
1128 | 1128 | ||
1129 | data->ts = handle->cpu_data[cpu].timestamp; | 1129 | record->ts = handle->cpu_data[cpu].timestamp; |
1130 | data->size = length; | 1130 | record->size = length; |
1131 | data->data = ptr; | 1131 | record->cpu = cpu; |
1132 | data->offset = handle->cpu_data[cpu].offset + index; | 1132 | record->data = ptr; |
1133 | record->offset = handle->cpu_data[cpu].offset + index; | ||
1133 | 1134 | ||
1134 | ptr += length; | 1135 | ptr += length; |
1135 | 1136 | ||
1136 | handle->cpu_data[cpu].index = calc_index(handle, ptr, cpu); | 1137 | handle->cpu_data[cpu].index = calc_index(handle, ptr, cpu); |
1137 | handle->cpu_data[cpu].next = data; | 1138 | handle->cpu_data[cpu].next = record; |
1138 | 1139 | ||
1139 | data->record_size = handle->cpu_data[cpu].index - index; | 1140 | record->record_size = handle->cpu_data[cpu].index - index; |
1140 | 1141 | ||
1141 | return data; | 1142 | return record; |
1142 | } | 1143 | } |
1143 | 1144 | ||
1144 | /** | 1145 | /** |
@@ -1154,12 +1155,12 @@ read_again: | |||
1154 | struct record * | 1155 | struct record * |
1155 | tracecmd_read_data(struct tracecmd_input *handle, int cpu) | 1156 | tracecmd_read_data(struct tracecmd_input *handle, int cpu) |
1156 | { | 1157 | { |
1157 | struct record *data; | 1158 | struct record *record; |
1158 | 1159 | ||
1159 | data = tracecmd_peek_data(handle, cpu); | 1160 | record = tracecmd_peek_data(handle, cpu); |
1160 | handle->cpu_data[cpu].next = NULL; | 1161 | handle->cpu_data[cpu].next = NULL; |
1161 | 1162 | ||
1162 | return data; | 1163 | return record; |
1163 | } | 1164 | } |
1164 | 1165 | ||
1165 | static int init_read(struct tracecmd_input *handle, int cpu) | 1166 | static int init_read(struct tracecmd_input *handle, int cpu) |