diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-04-30 03:58:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-04-30 03:58:05 -0400 |
commit | bc4b473f1aa2ef785ccfd890a24a1de5a6660f98 (patch) | |
tree | 77bbea692517ae4723b575631222bf715b4a1eb1 /tools/perf/util/event.c | |
parent | 3ca50496c2677a2b3fdd3ede86660fd1433beac6 (diff) | |
parent | 1c6a800cde3b818fd8320b5d402f2d77d2948c00 (diff) |
Merge branch 'perf' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/core
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r-- | tools/perf/util/event.c | 89 |
1 files changed, 42 insertions, 47 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index e3fa8d3d11b4..1757b0ffeaa9 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -172,17 +172,17 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid, | |||
172 | 172 | ||
173 | int event__synthesize_modules(event__handler_t process, | 173 | int event__synthesize_modules(event__handler_t process, |
174 | struct perf_session *session, | 174 | struct perf_session *session, |
175 | struct kernel_info *kerninfo) | 175 | struct machine *machine) |
176 | { | 176 | { |
177 | struct rb_node *nd; | 177 | struct rb_node *nd; |
178 | struct map_groups *kmaps = &kerninfo->kmaps; | 178 | struct map_groups *kmaps = &machine->kmaps; |
179 | u16 misc; | 179 | u16 misc; |
180 | 180 | ||
181 | /* | 181 | /* |
182 | * kernel uses 0 for user space maps, see kernel/perf_event.c | 182 | * kernel uses 0 for user space maps, see kernel/perf_event.c |
183 | * __perf_event_mmap | 183 | * __perf_event_mmap |
184 | */ | 184 | */ |
185 | if (is_host_kernel(kerninfo)) | 185 | if (machine__is_host(machine)) |
186 | misc = PERF_RECORD_MISC_KERNEL; | 186 | misc = PERF_RECORD_MISC_KERNEL; |
187 | else | 187 | else |
188 | misc = PERF_RECORD_MISC_GUEST_KERNEL; | 188 | misc = PERF_RECORD_MISC_GUEST_KERNEL; |
@@ -204,7 +204,7 @@ int event__synthesize_modules(event__handler_t process, | |||
204 | (sizeof(ev.mmap.filename) - size)); | 204 | (sizeof(ev.mmap.filename) - size)); |
205 | ev.mmap.start = pos->start; | 205 | ev.mmap.start = pos->start; |
206 | ev.mmap.len = pos->end - pos->start; | 206 | ev.mmap.len = pos->end - pos->start; |
207 | ev.mmap.pid = kerninfo->pid; | 207 | ev.mmap.pid = machine->pid; |
208 | 208 | ||
209 | memcpy(ev.mmap.filename, pos->dso->long_name, | 209 | memcpy(ev.mmap.filename, pos->dso->long_name, |
210 | pos->dso->long_name_len + 1); | 210 | pos->dso->long_name_len + 1); |
@@ -267,7 +267,7 @@ static int find_symbol_cb(void *arg, const char *name, char type, u64 start) | |||
267 | 267 | ||
268 | int event__synthesize_kernel_mmap(event__handler_t process, | 268 | int event__synthesize_kernel_mmap(event__handler_t process, |
269 | struct perf_session *session, | 269 | struct perf_session *session, |
270 | struct kernel_info *kerninfo, | 270 | struct machine *machine, |
271 | const char *symbol_name) | 271 | const char *symbol_name) |
272 | { | 272 | { |
273 | size_t size; | 273 | size_t size; |
@@ -288,8 +288,8 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
288 | */ | 288 | */ |
289 | struct process_symbol_args args = { .name = symbol_name, }; | 289 | struct process_symbol_args args = { .name = symbol_name, }; |
290 | 290 | ||
291 | mmap_name = kern_mmap_name(kerninfo, name_buff); | 291 | mmap_name = machine__mmap_name(machine, name_buff, sizeof(name_buff)); |
292 | if (is_host_kernel(kerninfo)) { | 292 | if (machine__is_host(machine)) { |
293 | /* | 293 | /* |
294 | * kernel uses PERF_RECORD_MISC_USER for user space maps, | 294 | * kernel uses PERF_RECORD_MISC_USER for user space maps, |
295 | * see kernel/perf_event.c __perf_event_mmap | 295 | * see kernel/perf_event.c __perf_event_mmap |
@@ -298,10 +298,10 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
298 | filename = "/proc/kallsyms"; | 298 | filename = "/proc/kallsyms"; |
299 | } else { | 299 | } else { |
300 | ev.header.misc = PERF_RECORD_MISC_GUEST_KERNEL; | 300 | ev.header.misc = PERF_RECORD_MISC_GUEST_KERNEL; |
301 | if (is_default_guest(kerninfo)) | 301 | if (machine__is_default_guest(machine)) |
302 | filename = (char *) symbol_conf.default_guest_kallsyms; | 302 | filename = (char *) symbol_conf.default_guest_kallsyms; |
303 | else { | 303 | else { |
304 | sprintf(path, "%s/proc/kallsyms", kerninfo->root_dir); | 304 | sprintf(path, "%s/proc/kallsyms", machine->root_dir); |
305 | filename = path; | 305 | filename = path; |
306 | } | 306 | } |
307 | } | 307 | } |
@@ -309,7 +309,7 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
309 | if (kallsyms__parse(filename, &args, find_symbol_cb) <= 0) | 309 | if (kallsyms__parse(filename, &args, find_symbol_cb) <= 0) |
310 | return -ENOENT; | 310 | return -ENOENT; |
311 | 311 | ||
312 | map = kerninfo->vmlinux_maps[MAP__FUNCTION]; | 312 | map = machine->vmlinux_maps[MAP__FUNCTION]; |
313 | size = snprintf(ev.mmap.filename, sizeof(ev.mmap.filename), | 313 | size = snprintf(ev.mmap.filename, sizeof(ev.mmap.filename), |
314 | "%s%s", mmap_name, symbol_name) + 1; | 314 | "%s%s", mmap_name, symbol_name) + 1; |
315 | size = ALIGN(size, sizeof(u64)); | 315 | size = ALIGN(size, sizeof(u64)); |
@@ -318,7 +318,7 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
318 | ev.mmap.pgoff = args.start; | 318 | ev.mmap.pgoff = args.start; |
319 | ev.mmap.start = map->start; | 319 | ev.mmap.start = map->start; |
320 | ev.mmap.len = map->end - ev.mmap.start; | 320 | ev.mmap.len = map->end - ev.mmap.start; |
321 | ev.mmap.pid = kerninfo->pid; | 321 | ev.mmap.pid = machine->pid; |
322 | 322 | ||
323 | return process(&ev, session); | 323 | return process(&ev, session); |
324 | } | 324 | } |
@@ -389,18 +389,18 @@ static int event__process_kernel_mmap(event_t *self, | |||
389 | { | 389 | { |
390 | struct map *map; | 390 | struct map *map; |
391 | char kmmap_prefix[PATH_MAX]; | 391 | char kmmap_prefix[PATH_MAX]; |
392 | struct kernel_info *kerninfo; | 392 | struct machine *machine; |
393 | enum dso_kernel_type kernel_type; | 393 | enum dso_kernel_type kernel_type; |
394 | bool is_kernel_mmap; | 394 | bool is_kernel_mmap; |
395 | 395 | ||
396 | kerninfo = kerninfo__findnew(&session->kerninfo_root, self->mmap.pid); | 396 | machine = perf_session__findnew_machine(session, self->mmap.pid); |
397 | if (!kerninfo) { | 397 | if (!machine) { |
398 | pr_err("Can't find id %d's kerninfo\n", self->mmap.pid); | 398 | pr_err("Can't find id %d's machine\n", self->mmap.pid); |
399 | goto out_problem; | 399 | goto out_problem; |
400 | } | 400 | } |
401 | 401 | ||
402 | kern_mmap_name(kerninfo, kmmap_prefix); | 402 | machine__mmap_name(machine, kmmap_prefix, sizeof(kmmap_prefix)); |
403 | if (is_host_kernel(kerninfo)) | 403 | if (machine__is_host(machine)) |
404 | kernel_type = DSO_TYPE_KERNEL; | 404 | kernel_type = DSO_TYPE_KERNEL; |
405 | else | 405 | else |
406 | kernel_type = DSO_TYPE_GUEST_KERNEL; | 406 | kernel_type = DSO_TYPE_GUEST_KERNEL; |
@@ -429,10 +429,8 @@ static int event__process_kernel_mmap(event_t *self, | |||
429 | } else | 429 | } else |
430 | strcpy(short_module_name, self->mmap.filename); | 430 | strcpy(short_module_name, self->mmap.filename); |
431 | 431 | ||
432 | map = map_groups__new_module(&kerninfo->kmaps, | 432 | map = machine__new_module(machine, self->mmap.start, |
433 | self->mmap.start, | 433 | self->mmap.filename); |
434 | self->mmap.filename, | ||
435 | kerninfo); | ||
436 | if (map == NULL) | 434 | if (map == NULL) |
437 | goto out_problem; | 435 | goto out_problem; |
438 | 436 | ||
@@ -449,27 +447,25 @@ static int event__process_kernel_mmap(event_t *self, | |||
449 | * Should be there already, from the build-id table in | 447 | * Should be there already, from the build-id table in |
450 | * the header. | 448 | * the header. |
451 | */ | 449 | */ |
452 | struct dso *kernel = __dsos__findnew(&kerninfo->dsos__kernel, | 450 | struct dso *kernel = __dsos__findnew(&machine->kernel_dsos, |
453 | kmmap_prefix); | 451 | kmmap_prefix); |
454 | if (kernel == NULL) | 452 | if (kernel == NULL) |
455 | goto out_problem; | 453 | goto out_problem; |
456 | 454 | ||
457 | kernel->kernel = kernel_type; | 455 | kernel->kernel = kernel_type; |
458 | if (__map_groups__create_kernel_maps(&kerninfo->kmaps, | 456 | if (__machine__create_kernel_maps(machine, kernel) < 0) |
459 | kerninfo->vmlinux_maps, kernel) < 0) | ||
460 | goto out_problem; | 457 | goto out_problem; |
461 | 458 | ||
462 | event_set_kernel_mmap_len(kerninfo->vmlinux_maps, self); | 459 | event_set_kernel_mmap_len(machine->vmlinux_maps, self); |
463 | perf_session__set_kallsyms_ref_reloc_sym(kerninfo->vmlinux_maps, | 460 | perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, |
464 | symbol_name, | 461 | symbol_name, |
465 | self->mmap.pgoff); | 462 | self->mmap.pgoff); |
466 | if (is_default_guest(kerninfo)) { | 463 | if (machine__is_default_guest(machine)) { |
467 | /* | 464 | /* |
468 | * preload dso of guest kernel and modules | 465 | * preload dso of guest kernel and modules |
469 | */ | 466 | */ |
470 | dso__load(kernel, | 467 | dso__load(kernel, machine->vmlinux_maps[MAP__FUNCTION], |
471 | kerninfo->vmlinux_maps[MAP__FUNCTION], | 468 | NULL); |
472 | NULL); | ||
473 | } | 469 | } |
474 | } | 470 | } |
475 | return 0; | 471 | return 0; |
@@ -479,7 +475,7 @@ out_problem: | |||
479 | 475 | ||
480 | int event__process_mmap(event_t *self, struct perf_session *session) | 476 | int event__process_mmap(event_t *self, struct perf_session *session) |
481 | { | 477 | { |
482 | struct kernel_info *kerninfo; | 478 | struct machine *machine; |
483 | struct thread *thread; | 479 | struct thread *thread; |
484 | struct map *map; | 480 | struct map *map; |
485 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 481 | u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
@@ -498,8 +494,8 @@ int event__process_mmap(event_t *self, struct perf_session *session) | |||
498 | } | 494 | } |
499 | 495 | ||
500 | thread = perf_session__findnew(session, self->mmap.pid); | 496 | thread = perf_session__findnew(session, self->mmap.pid); |
501 | kerninfo = kerninfo__findhost(&session->kerninfo_root); | 497 | machine = perf_session__find_host_machine(session); |
502 | map = map__new(&kerninfo->dsos__user, self->mmap.start, | 498 | map = map__new(&machine->user_dsos, self->mmap.start, |
503 | self->mmap.len, self->mmap.pgoff, | 499 | self->mmap.len, self->mmap.pgoff, |
504 | self->mmap.pid, self->mmap.filename, | 500 | self->mmap.pid, self->mmap.filename, |
505 | MAP__FUNCTION, session->cwd, session->cwdlen); | 501 | MAP__FUNCTION, session->cwd, session->cwdlen); |
@@ -546,7 +542,7 @@ void thread__find_addr_map(struct thread *self, | |||
546 | struct addr_location *al) | 542 | struct addr_location *al) |
547 | { | 543 | { |
548 | struct map_groups *mg = &self->mg; | 544 | struct map_groups *mg = &self->mg; |
549 | struct kernel_info *kerninfo = NULL; | 545 | struct machine *machine = NULL; |
550 | 546 | ||
551 | al->thread = self; | 547 | al->thread = self; |
552 | al->addr = addr; | 548 | al->addr = addr; |
@@ -555,19 +551,19 @@ void thread__find_addr_map(struct thread *self, | |||
555 | 551 | ||
556 | if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { | 552 | if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { |
557 | al->level = 'k'; | 553 | al->level = 'k'; |
558 | kerninfo = kerninfo__findhost(&session->kerninfo_root); | 554 | machine = perf_session__find_host_machine(session); |
559 | mg = &kerninfo->kmaps; | 555 | mg = &machine->kmaps; |
560 | } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) { | 556 | } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) { |
561 | al->level = '.'; | 557 | al->level = '.'; |
562 | kerninfo = kerninfo__findhost(&session->kerninfo_root); | 558 | machine = perf_session__find_host_machine(session); |
563 | } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) { | 559 | } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) { |
564 | al->level = 'g'; | 560 | al->level = 'g'; |
565 | kerninfo = kerninfo__find(&session->kerninfo_root, pid); | 561 | machine = perf_session__find_machine(session, pid); |
566 | if (!kerninfo) { | 562 | if (!machine) { |
567 | al->map = NULL; | 563 | al->map = NULL; |
568 | return; | 564 | return; |
569 | } | 565 | } |
570 | mg = &kerninfo->kmaps; | 566 | mg = &machine->kmaps; |
571 | } else { | 567 | } else { |
572 | /* | 568 | /* |
573 | * 'u' means guest os user space. | 569 | * 'u' means guest os user space. |
@@ -603,10 +599,9 @@ try_again: | |||
603 | * in the whole kernel symbol list. | 599 | * in the whole kernel symbol list. |
604 | */ | 600 | */ |
605 | if ((long long)al->addr < 0 && | 601 | if ((long long)al->addr < 0 && |
606 | cpumode == PERF_RECORD_MISC_KERNEL && | 602 | cpumode == PERF_RECORD_MISC_KERNEL && |
607 | kerninfo && | 603 | machine && mg != &machine->kmaps) { |
608 | mg != &kerninfo->kmaps) { | 604 | mg = &machine->kmaps; |
609 | mg = &kerninfo->kmaps; | ||
610 | goto try_again; | 605 | goto try_again; |
611 | } | 606 | } |
612 | } else | 607 | } else |