aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/event.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-04-27 20:17:50 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-27 20:17:50 -0400
commit23346f21b277e3aae5e9989e711a11cbe8133a45 (patch)
tree21f11a72cf21d4eb3d824f46e274dc8f9815d749 /tools/perf/util/event.c
parent462b04e28a7ec1339c892117c3f20a40e55d0e83 (diff)
perf tools: Rename "kernel_info" to "machine"
struct kernel_info and kerninfo__ are too vague, what they really describe are machines, virtual ones or hosts. There are more changes to introduce helpers to shorten function calls and to make more clear what is really being done, but I left that for subsequent patches. Cc: Avi Kivity <avi@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r--tools/perf/util/event.c92
1 files changed, 45 insertions, 47 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index e3fa8d3d11b4..2f33ca9899bd 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
173int event__synthesize_modules(event__handler_t process, 173int 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
268int event__synthesize_kernel_mmap(event__handler_t process, 268int 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);
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);
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,9 @@ 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 = map_groups__new_module(&machine->kmaps,
433 self->mmap.start, 433 self->mmap.start,
434 self->mmap.filename, 434 self->mmap.filename, machine);
435 kerninfo);
436 if (map == NULL) 435 if (map == NULL)
437 goto out_problem; 436 goto out_problem;
438 437
@@ -449,27 +448,27 @@ static int event__process_kernel_mmap(event_t *self,
449 * Should be there already, from the build-id table in 448 * Should be there already, from the build-id table in
450 * the header. 449 * the header.
451 */ 450 */
452 struct dso *kernel = __dsos__findnew(&kerninfo->dsos__kernel, 451 struct dso *kernel = __dsos__findnew(&machine->kernel_dsos,
453 kmmap_prefix); 452 kmmap_prefix);
454 if (kernel == NULL) 453 if (kernel == NULL)
455 goto out_problem; 454 goto out_problem;
456 455
457 kernel->kernel = kernel_type; 456 kernel->kernel = kernel_type;
458 if (__map_groups__create_kernel_maps(&kerninfo->kmaps, 457 if (__map_groups__create_kernel_maps(&machine->kmaps,
459 kerninfo->vmlinux_maps, kernel) < 0) 458 machine->vmlinux_maps,
459 kernel) < 0)
460 goto out_problem; 460 goto out_problem;
461 461
462 event_set_kernel_mmap_len(kerninfo->vmlinux_maps, self); 462 event_set_kernel_mmap_len(machine->vmlinux_maps, self);
463 perf_session__set_kallsyms_ref_reloc_sym(kerninfo->vmlinux_maps, 463 perf_session__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps,
464 symbol_name, 464 symbol_name,
465 self->mmap.pgoff); 465 self->mmap.pgoff);
466 if (is_default_guest(kerninfo)) { 466 if (machine__is_default_guest(machine)) {
467 /* 467 /*
468 * preload dso of guest kernel and modules 468 * preload dso of guest kernel and modules
469 */ 469 */
470 dso__load(kernel, 470 dso__load(kernel, machine->vmlinux_maps[MAP__FUNCTION],
471 kerninfo->vmlinux_maps[MAP__FUNCTION], 471 NULL);
472 NULL);
473 } 472 }
474 } 473 }
475 return 0; 474 return 0;
@@ -479,7 +478,7 @@ out_problem:
479 478
480int event__process_mmap(event_t *self, struct perf_session *session) 479int event__process_mmap(event_t *self, struct perf_session *session)
481{ 480{
482 struct kernel_info *kerninfo; 481 struct machine *machine;
483 struct thread *thread; 482 struct thread *thread;
484 struct map *map; 483 struct map *map;
485 u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 484 u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
@@ -498,8 +497,8 @@ int event__process_mmap(event_t *self, struct perf_session *session)
498 } 497 }
499 498
500 thread = perf_session__findnew(session, self->mmap.pid); 499 thread = perf_session__findnew(session, self->mmap.pid);
501 kerninfo = kerninfo__findhost(&session->kerninfo_root); 500 machine = perf_session__find_host_machine(session);
502 map = map__new(&kerninfo->dsos__user, self->mmap.start, 501 map = map__new(&machine->user_dsos, self->mmap.start,
503 self->mmap.len, self->mmap.pgoff, 502 self->mmap.len, self->mmap.pgoff,
504 self->mmap.pid, self->mmap.filename, 503 self->mmap.pid, self->mmap.filename,
505 MAP__FUNCTION, session->cwd, session->cwdlen); 504 MAP__FUNCTION, session->cwd, session->cwdlen);
@@ -546,7 +545,7 @@ void thread__find_addr_map(struct thread *self,
546 struct addr_location *al) 545 struct addr_location *al)
547{ 546{
548 struct map_groups *mg = &self->mg; 547 struct map_groups *mg = &self->mg;
549 struct kernel_info *kerninfo = NULL; 548 struct machine *machine = NULL;
550 549
551 al->thread = self; 550 al->thread = self;
552 al->addr = addr; 551 al->addr = addr;
@@ -555,19 +554,19 @@ void thread__find_addr_map(struct thread *self,
555 554
556 if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { 555 if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
557 al->level = 'k'; 556 al->level = 'k';
558 kerninfo = kerninfo__findhost(&session->kerninfo_root); 557 machine = perf_session__find_host_machine(session);
559 mg = &kerninfo->kmaps; 558 mg = &machine->kmaps;
560 } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) { 559 } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
561 al->level = '.'; 560 al->level = '.';
562 kerninfo = kerninfo__findhost(&session->kerninfo_root); 561 machine = perf_session__find_host_machine(session);
563 } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) { 562 } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
564 al->level = 'g'; 563 al->level = 'g';
565 kerninfo = kerninfo__find(&session->kerninfo_root, pid); 564 machine = perf_session__find_machine(session, pid);
566 if (!kerninfo) { 565 if (!machine) {
567 al->map = NULL; 566 al->map = NULL;
568 return; 567 return;
569 } 568 }
570 mg = &kerninfo->kmaps; 569 mg = &machine->kmaps;
571 } else { 570 } else {
572 /* 571 /*
573 * 'u' means guest os user space. 572 * 'u' means guest os user space.
@@ -603,10 +602,9 @@ try_again:
603 * in the whole kernel symbol list. 602 * in the whole kernel symbol list.
604 */ 603 */
605 if ((long long)al->addr < 0 && 604 if ((long long)al->addr < 0 &&
606 cpumode == PERF_RECORD_MISC_KERNEL && 605 cpumode == PERF_RECORD_MISC_KERNEL &&
607 kerninfo && 606 machine && mg != &machine->kmaps) {
608 mg != &kerninfo->kmaps) { 607 mg = &machine->kmaps;
609 mg = &kerninfo->kmaps;
610 goto try_again; 608 goto try_again;
611 } 609 }
612 } else 610 } else