diff options
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 75d016768021..6227dc4cb2cf 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -229,10 +229,9 @@ static int dsos__write_buildid_table(struct perf_header *header, int fd) | |||
229 | int err = 0; | 229 | int err = 0; |
230 | u16 kmisc, umisc; | 230 | u16 kmisc, umisc; |
231 | 231 | ||
232 | for (nd = rb_first(&session->kerninfo_root); nd; nd = rb_next(nd)) { | 232 | for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { |
233 | struct kernel_info *pos = rb_entry(nd, struct kernel_info, | 233 | struct machine *pos = rb_entry(nd, struct machine, rb_node); |
234 | rb_node); | 234 | if (machine__is_host(pos)) { |
235 | if (is_host_kernel(pos)) { | ||
236 | kmisc = PERF_RECORD_MISC_KERNEL; | 235 | kmisc = PERF_RECORD_MISC_KERNEL; |
237 | umisc = PERF_RECORD_MISC_USER; | 236 | umisc = PERF_RECORD_MISC_USER; |
238 | } else { | 237 | } else { |
@@ -240,11 +239,11 @@ static int dsos__write_buildid_table(struct perf_header *header, int fd) | |||
240 | umisc = PERF_RECORD_MISC_GUEST_USER; | 239 | umisc = PERF_RECORD_MISC_GUEST_USER; |
241 | } | 240 | } |
242 | 241 | ||
243 | err = __dsos__write_buildid_table(&pos->dsos__kernel, pos->pid, | 242 | err = __dsos__write_buildid_table(&pos->kernel_dsos, pos->pid, |
244 | kmisc, fd); | 243 | kmisc, fd); |
245 | if (err == 0) | 244 | if (err == 0) |
246 | err = __dsos__write_buildid_table(&pos->dsos__user, | 245 | err = __dsos__write_buildid_table(&pos->user_dsos, |
247 | pos->pid, umisc, fd); | 246 | pos->pid, umisc, fd); |
248 | if (err) | 247 | if (err) |
249 | break; | 248 | break; |
250 | } | 249 | } |
@@ -378,11 +377,10 @@ static int dsos__cache_build_ids(struct perf_header *self) | |||
378 | if (mkdir(debugdir, 0755) != 0 && errno != EEXIST) | 377 | if (mkdir(debugdir, 0755) != 0 && errno != EEXIST) |
379 | return -1; | 378 | return -1; |
380 | 379 | ||
381 | for (nd = rb_first(&session->kerninfo_root); nd; nd = rb_next(nd)) { | 380 | for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { |
382 | struct kernel_info *pos = rb_entry(nd, struct kernel_info, | 381 | struct machine *pos = rb_entry(nd, struct machine, rb_node); |
383 | rb_node); | 382 | ret |= __dsos__cache_build_ids(&pos->kernel_dsos, debugdir); |
384 | ret |= __dsos__cache_build_ids(&pos->dsos__kernel, debugdir); | 383 | ret |= __dsos__cache_build_ids(&pos->user_dsos, debugdir); |
385 | ret |= __dsos__cache_build_ids(&pos->dsos__user, debugdir); | ||
386 | } | 384 | } |
387 | return ret ? -1 : 0; | 385 | return ret ? -1 : 0; |
388 | } | 386 | } |
@@ -394,11 +392,10 @@ static bool dsos__read_build_ids(struct perf_header *self, bool with_hits) | |||
394 | struct perf_session, header); | 392 | struct perf_session, header); |
395 | struct rb_node *nd; | 393 | struct rb_node *nd; |
396 | 394 | ||
397 | for (nd = rb_first(&session->kerninfo_root); nd; nd = rb_next(nd)) { | 395 | for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { |
398 | struct kernel_info *pos = rb_entry(nd, struct kernel_info, | 396 | struct machine *pos = rb_entry(nd, struct machine, rb_node); |
399 | rb_node); | 397 | ret |= __dsos__read_build_ids(&pos->kernel_dsos, with_hits); |
400 | ret |= __dsos__read_build_ids(&pos->dsos__kernel, with_hits); | 398 | ret |= __dsos__read_build_ids(&pos->user_dsos, with_hits); |
401 | ret |= __dsos__read_build_ids(&pos->dsos__user, with_hits); | ||
402 | } | 399 | } |
403 | 400 | ||
404 | return ret; | 401 | return ret; |
@@ -685,13 +682,13 @@ static int __event_process_build_id(struct build_id_event *bev, | |||
685 | { | 682 | { |
686 | int err = -1; | 683 | int err = -1; |
687 | struct list_head *head; | 684 | struct list_head *head; |
688 | struct kernel_info *kerninfo; | 685 | struct machine *machine; |
689 | u16 misc; | 686 | u16 misc; |
690 | struct dso *dso; | 687 | struct dso *dso; |
691 | enum dso_kernel_type dso_type; | 688 | enum dso_kernel_type dso_type; |
692 | 689 | ||
693 | kerninfo = kerninfo__findnew(&session->kerninfo_root, bev->pid); | 690 | machine = perf_session__findnew_machine(session, bev->pid); |
694 | if (!kerninfo) | 691 | if (!machine) |
695 | goto out; | 692 | goto out; |
696 | 693 | ||
697 | misc = bev->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 694 | misc = bev->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
@@ -699,16 +696,16 @@ static int __event_process_build_id(struct build_id_event *bev, | |||
699 | switch (misc) { | 696 | switch (misc) { |
700 | case PERF_RECORD_MISC_KERNEL: | 697 | case PERF_RECORD_MISC_KERNEL: |
701 | dso_type = DSO_TYPE_KERNEL; | 698 | dso_type = DSO_TYPE_KERNEL; |
702 | head = &kerninfo->dsos__kernel; | 699 | head = &machine->kernel_dsos; |
703 | break; | 700 | break; |
704 | case PERF_RECORD_MISC_GUEST_KERNEL: | 701 | case PERF_RECORD_MISC_GUEST_KERNEL: |
705 | dso_type = DSO_TYPE_GUEST_KERNEL; | 702 | dso_type = DSO_TYPE_GUEST_KERNEL; |
706 | head = &kerninfo->dsos__kernel; | 703 | head = &machine->kernel_dsos; |
707 | break; | 704 | break; |
708 | case PERF_RECORD_MISC_USER: | 705 | case PERF_RECORD_MISC_USER: |
709 | case PERF_RECORD_MISC_GUEST_USER: | 706 | case PERF_RECORD_MISC_GUEST_USER: |
710 | dso_type = DSO_TYPE_USER; | 707 | dso_type = DSO_TYPE_USER; |
711 | head = &kerninfo->dsos__user; | 708 | head = &machine->user_dsos; |
712 | break; | 709 | break; |
713 | default: | 710 | default: |
714 | goto out; | 711 | goto out; |
@@ -1113,8 +1110,7 @@ int event__process_tracing_data(event_t *self, | |||
1113 | } | 1110 | } |
1114 | 1111 | ||
1115 | int event__synthesize_build_id(struct dso *pos, u16 misc, | 1112 | int event__synthesize_build_id(struct dso *pos, u16 misc, |
1116 | event__handler_t process, | 1113 | event__handler_t process, struct machine *machine, |
1117 | struct kernel_info *kerninfo, | ||
1118 | struct perf_session *session) | 1114 | struct perf_session *session) |
1119 | { | 1115 | { |
1120 | event_t ev; | 1116 | event_t ev; |
@@ -1131,7 +1127,7 @@ int event__synthesize_build_id(struct dso *pos, u16 misc, | |||
1131 | memcpy(&ev.build_id.build_id, pos->build_id, sizeof(pos->build_id)); | 1127 | memcpy(&ev.build_id.build_id, pos->build_id, sizeof(pos->build_id)); |
1132 | ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID; | 1128 | ev.build_id.header.type = PERF_RECORD_HEADER_BUILD_ID; |
1133 | ev.build_id.header.misc = misc; | 1129 | ev.build_id.header.misc = misc; |
1134 | ev.build_id.pid = kerninfo->pid; | 1130 | ev.build_id.pid = machine->pid; |
1135 | ev.build_id.header.size = sizeof(ev.build_id) + len; | 1131 | ev.build_id.header.size = sizeof(ev.build_id) + len; |
1136 | memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len); | 1132 | memcpy(&ev.build_id.filename, pos->long_name, pos->long_name_len); |
1137 | 1133 | ||
@@ -1142,7 +1138,7 @@ int event__synthesize_build_id(struct dso *pos, u16 misc, | |||
1142 | 1138 | ||
1143 | static int __event_synthesize_build_ids(struct list_head *head, u16 misc, | 1139 | static int __event_synthesize_build_ids(struct list_head *head, u16 misc, |
1144 | event__handler_t process, | 1140 | event__handler_t process, |
1145 | struct kernel_info *kerninfo, | 1141 | struct machine *machine, |
1146 | struct perf_session *session) | 1142 | struct perf_session *session) |
1147 | { | 1143 | { |
1148 | struct dso *pos; | 1144 | struct dso *pos; |
@@ -1153,7 +1149,7 @@ static int __event_synthesize_build_ids(struct list_head *head, u16 misc, | |||
1153 | continue; | 1149 | continue; |
1154 | 1150 | ||
1155 | err = event__synthesize_build_id(pos, misc, process, | 1151 | err = event__synthesize_build_id(pos, misc, process, |
1156 | kerninfo, session); | 1152 | machine, session); |
1157 | if (err < 0) | 1153 | if (err < 0) |
1158 | return err; | 1154 | return err; |
1159 | } | 1155 | } |
@@ -1166,15 +1162,15 @@ int event__synthesize_build_ids(event__handler_t process, | |||
1166 | { | 1162 | { |
1167 | int err = 0; | 1163 | int err = 0; |
1168 | u16 kmisc, umisc; | 1164 | u16 kmisc, umisc; |
1169 | struct kernel_info *pos; | 1165 | struct machine *pos; |
1170 | struct rb_node *nd; | 1166 | struct rb_node *nd; |
1171 | 1167 | ||
1172 | if (!dsos__read_build_ids(&session->header, true)) | 1168 | if (!dsos__read_build_ids(&session->header, true)) |
1173 | return 0; | 1169 | return 0; |
1174 | 1170 | ||
1175 | for (nd = rb_first(&session->kerninfo_root); nd; nd = rb_next(nd)) { | 1171 | for (nd = rb_first(&session->machines); nd; nd = rb_next(nd)) { |
1176 | pos = rb_entry(nd, struct kernel_info, rb_node); | 1172 | pos = rb_entry(nd, struct machine, rb_node); |
1177 | if (is_host_kernel(pos)) { | 1173 | if (machine__is_host(pos)) { |
1178 | kmisc = PERF_RECORD_MISC_KERNEL; | 1174 | kmisc = PERF_RECORD_MISC_KERNEL; |
1179 | umisc = PERF_RECORD_MISC_USER; | 1175 | umisc = PERF_RECORD_MISC_USER; |
1180 | } else { | 1176 | } else { |
@@ -1182,11 +1178,11 @@ int event__synthesize_build_ids(event__handler_t process, | |||
1182 | umisc = PERF_RECORD_MISC_GUEST_USER; | 1178 | umisc = PERF_RECORD_MISC_GUEST_USER; |
1183 | } | 1179 | } |
1184 | 1180 | ||
1185 | err = __event_synthesize_build_ids(&pos->dsos__kernel, | 1181 | err = __event_synthesize_build_ids(&pos->kernel_dsos, kmisc, |
1186 | kmisc, process, pos, session); | 1182 | process, pos, session); |
1187 | if (err == 0) | 1183 | if (err == 0) |
1188 | err = __event_synthesize_build_ids(&pos->dsos__user, | 1184 | err = __event_synthesize_build_ids(&pos->user_dsos, umisc, |
1189 | umisc, process, pos, session); | 1185 | process, pos, session); |
1190 | if (err) | 1186 | if (err) |
1191 | break; | 1187 | break; |
1192 | } | 1188 | } |