1 #include <errno.h> 2 #include <fcntl.h> 3 #include <inttypes.h> 4 #include <linux/kernel.h> 5 #include <linux/types.h> 6 #include <perf/cpumap.h> 7 #include <sys/types.h> 8 #include <sys/stat.h> 9 #include <unistd.h> 10 #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ 11 #include <linux/perf_event.h> 12 #include <linux/zalloc.h> 13 #include "cpumap.h" 14 #include "dso.h" 15 #include "event.h" 16 #include "debug.h" 17 #include "hist.h" 18 #include "machine.h" 19 #include "sort.h" 20 #include "string2.h" 21 #include "strlist.h" 22 #include "thread.h" 23 #include "thread_map.h" 24 #include "time-utils.h" 25 #include <linux/ctype.h> 26 #include "map.h" 27 #include "util/namespaces.h" 28 #include "symbol.h" 29 #include "symbol/kallsyms.h" 30 #include "asm/bug.h" 31 #include "stat.h" 32 #include "session.h" 33 #include "bpf-event.h" 34 #include "tool.h" 35 #include "../perf.h" 36 37 static const char *perf_event__names[] = { 38 [0] = "TOTAL", 39 [PERF_RECORD_MMAP] = "MMAP", 40 [PERF_RECORD_MMAP2] = "MMAP2", 41 [PERF_RECORD_LOST] = "LOST", 42 [PERF_RECORD_COMM] = "COMM", 43 [PERF_RECORD_EXIT] = "EXIT", 44 [PERF_RECORD_THROTTLE] = "THROTTLE", 45 [PERF_RECORD_UNTHROTTLE] = "UNTHROTTLE", 46 [PERF_RECORD_FORK] = "FORK", 47 [PERF_RECORD_READ] = "READ", 48 [PERF_RECORD_SAMPLE] = "SAMPLE", 49 [PERF_RECORD_AUX] = "AUX", 50 [PERF_RECORD_ITRACE_START] = "ITRACE_START", 51 [PERF_RECORD_LOST_SAMPLES] = "LOST_SAMPLES", 52 [PERF_RECORD_SWITCH] = "SWITCH", 53 [PERF_RECORD_SWITCH_CPU_WIDE] = "SWITCH_CPU_WIDE", 54 [PERF_RECORD_NAMESPACES] = "NAMESPACES", 55 [PERF_RECORD_KSYMBOL] = "KSYMBOL", 56 [PERF_RECORD_BPF_EVENT] = "BPF_EVENT", 57 [PERF_RECORD_CGROUP] = "CGROUP", 58 [PERF_RECORD_HEADER_ATTR] = "ATTR", 59 [PERF_RECORD_HEADER_EVENT_TYPE] = "EVENT_TYPE", 60 [PERF_RECORD_HEADER_TRACING_DATA] = "TRACING_DATA", 61 [PERF_RECORD_HEADER_BUILD_ID] = "BUILD_ID", 62 [PERF_RECORD_FINISHED_ROUND] = "FINISHED_ROUND", 63 [PERF_RECORD_ID_INDEX] = "ID_INDEX", 64 [PERF_RECORD_AUXTRACE_INFO] = "AUXTRACE_INFO", 65 [PERF_RECORD_AUXTRACE] = "AUXTRACE", 66 [PERF_RECORD_AUXTRACE_ERROR] = "AUXTRACE_ERROR", 67 [PERF_RECORD_THREAD_MAP] = "THREAD_MAP", 68 [PERF_RECORD_CPU_MAP] = "CPU_MAP", 69 [PERF_RECORD_STAT_CONFIG] = "STAT_CONFIG", 70 [PERF_RECORD_STAT] = "STAT", 71 [PERF_RECORD_STAT_ROUND] = "STAT_ROUND", 72 [PERF_RECORD_EVENT_UPDATE] = "EVENT_UPDATE", 73 [PERF_RECORD_TIME_CONV] = "TIME_CONV", 74 [PERF_RECORD_HEADER_FEATURE] = "FEATURE", 75 [PERF_RECORD_COMPRESSED] = "COMPRESSED", 76 }; 77 78 const char *perf_event__name(unsigned int id) 79 { 80 if (id >= ARRAY_SIZE(perf_event__names)) 81 return "INVALID"; 82 if (!perf_event__names[id]) 83 return "UNKNOWN"; 84 return perf_event__names[id]; 85 } 86 87 struct process_symbol_args { 88 const char *name; 89 u64 start; 90 }; 91 92 static int find_symbol_cb(void *arg, const char *name, char type, 93 u64 start) 94 { 95 struct process_symbol_args *args = arg; 96 97 /* 98 * Must be a function or at least an alias, as in PARISC64, where "_text" is 99 * an 'A' to the same address as "_stext". 100 */ 101 if (!(kallsyms__is_function(type) || 102 type == 'A') || strcmp(name, args->name)) 103 return 0; 104 105 args->start = start; 106 return 1; 107 } 108 109 int kallsyms__get_function_start(const char *kallsyms_filename, 110 const char *symbol_name, u64 *addr) 111 { 112 struct process_symbol_args args = { .name = symbol_name, }; 113 114 if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0) 115 return -1; 116 117 *addr = args.start; 118 return 0; 119 } 120 121 void perf_event__read_stat_config(struct perf_stat_config *config, 122 struct perf_record_stat_config *event) 123 { 124 unsigned i; 125 126 for (i = 0; i < event->nr; i++) { 127 128 switch (event->data[i].tag) { 129 #define CASE(__term, __val) \ 130 case PERF_STAT_CONFIG_TERM__##__term: \ 131 config->__val = event->data[i].val; \ 132 break; 133 134 CASE(AGGR_MODE, aggr_mode) 135 CASE(SCALE, scale) 136 CASE(INTERVAL, interval) 137 #undef CASE 138 default: 139 pr_warning("unknown stat config term %" PRI_lu64 "\n", 140 event->data[i].tag); 141 } 142 } 143 } 144 145 size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp) 146 { 147 const char *s; 148 149 if (event->header.misc & PERF_RECORD_MISC_COMM_EXEC) 150 s = " exec"; 151 else 152 s = ""; 153 154 return fprintf(fp, "%s: %s:%d/%d\n", s, event->comm.comm, event->comm.pid, event->comm.tid); 155 } 156 157 size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp) 158 { 159 size_t ret = 0; 160 struct perf_ns_link_info *ns_link_info; 161 u32 nr_namespaces, idx; 162 163 ns_link_info = event->namespaces.link_info; 164 nr_namespaces = event->namespaces.nr_namespaces; 165 166 ret += fprintf(fp, " %d/%d - nr_namespaces: %u\n\t\t[", 167 event->namespaces.pid, 168 event->namespaces.tid, 169 nr_namespaces); 170 171 for (idx = 0; idx < nr_namespaces; idx++) { 172 if (idx && (idx % 4 == 0)) 173 ret += fprintf(fp, "\n\t\t "); 174 175 ret += fprintf(fp, "%u/%s: %" PRIu64 "/%#" PRIx64 "%s", idx, 176 perf_ns__name(idx), (u64)ns_link_info[idx].dev, 177 (u64)ns_link_info[idx].ino, 178 ((idx + 1) != nr_namespaces) ? ", " : "]\n"); 179 } 180 181 return ret; 182 } 183 184 size_t perf_event__fprintf_cgroup(union perf_event *event, FILE *fp) 185 { 186 return fprintf(fp, " cgroup: %" PRI_lu64 " %s\n", 187 event->cgroup.id, event->cgroup.path); 188 } 189 190 int perf_event__process_comm(struct perf_tool *tool __maybe_unused, 191 union perf_event *event, 192 struct perf_sample *sample, 193 struct machine *machine) 194 { 195 return machine__process_comm_event(machine, event, sample); 196 } 197 198 int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, 199 union perf_event *event, 200 struct perf_sample *sample, 201 struct machine *machine) 202 { 203 return machine__process_namespaces_event(machine, event, sample); 204 } 205 206 int perf_event__process_cgroup(struct perf_tool *tool __maybe_unused, 207 union perf_event *event, 208 struct perf_sample *sample, 209 struct machine *machine) 210 { 211 return machine__process_cgroup_event(machine, event, sample); 212 } 213 214 int perf_event__process_lost(struct perf_tool *tool __maybe_unused, 215 union perf_event *event, 216 struct perf_sample *sample, 217 struct machine *machine) 218 { 219 return machine__process_lost_event(machine, event, sample); 220 } 221 222 int perf_event__process_aux(struct perf_tool *tool __maybe_unused, 223 union perf_event *event, 224 struct perf_sample *sample __maybe_unused, 225 struct machine *machine) 226 { 227 return machine__process_aux_event(machine, event); 228 } 229 230 int perf_event__process_itrace_start(struct perf_tool *tool __maybe_unused, 231 union perf_event *event, 232 struct perf_sample *sample __maybe_unused, 233 struct machine *machine) 234 { 235 return machine__process_itrace_start_event(machine, event); 236 } 237 238 int perf_event__process_lost_samples(struct perf_tool *tool __maybe_unused, 239 union perf_event *event, 240 struct perf_sample *sample, 241 struct machine *machine) 242 { 243 return machine__process_lost_samples_event(machine, event, sample); 244 } 245 246 int perf_event__process_switch(struct perf_tool *tool __maybe_unused, 247 union perf_event *event, 248 struct perf_sample *sample __maybe_unused, 249 struct machine *machine) 250 { 251 return machine__process_switch_event(machine, event); 252 } 253 254 int perf_event__process_ksymbol(struct perf_tool *tool __maybe_unused, 255 union perf_event *event, 256 struct perf_sample *sample __maybe_unused, 257 struct machine *machine) 258 { 259 return machine__process_ksymbol(machine, event, sample); 260 } 261 262 int perf_event__process_bpf(struct perf_tool *tool __maybe_unused, 263 union perf_event *event, 264 struct perf_sample *sample, 265 struct machine *machine) 266 { 267 return machine__process_bpf(machine, event, sample); 268 } 269 270 size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) 271 { 272 return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 "]: %c %s\n", 273 event->mmap.pid, event->mmap.tid, event->mmap.start, 274 event->mmap.len, event->mmap.pgoff, 275 (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x', 276 event->mmap.filename); 277 } 278 279 size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) 280 { 281 return fprintf(fp, " %d/%d: [%#" PRI_lx64 "(%#" PRI_lx64 ") @ %#" PRI_lx64 282 " %02x:%02x %"PRI_lu64" %"PRI_lu64"]: %c%c%c%c %s\n", 283 event->mmap2.pid, event->mmap2.tid, event->mmap2.start, 284 event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, 285 event->mmap2.min, event->mmap2.ino, 286 event->mmap2.ino_generation, 287 (event->mmap2.prot & PROT_READ) ? 'r' : '-', 288 (event->mmap2.prot & PROT_WRITE) ? 'w' : '-', 289 (event->mmap2.prot & PROT_EXEC) ? 'x' : '-', 290 (event->mmap2.flags & MAP_SHARED) ? 's' : 'p', 291 event->mmap2.filename); 292 } 293 294 size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp) 295 { 296 struct perf_thread_map *threads = thread_map__new_event(&event->thread_map); 297 size_t ret; 298 299 ret = fprintf(fp, " nr: "); 300 301 if (threads) 302 ret += thread_map__fprintf(threads, fp); 303 else 304 ret += fprintf(fp, "failed to get threads from event\n"); 305 306 perf_thread_map__put(threads); 307 return ret; 308 } 309 310 size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp) 311 { 312 struct perf_cpu_map *cpus = cpu_map__new_data(&event->cpu_map.data); 313 size_t ret; 314 315 ret = fprintf(fp, ": "); 316 317 if (cpus) 318 ret += cpu_map__fprintf(cpus, fp); 319 else 320 ret += fprintf(fp, "failed to get cpumap from event\n"); 321 322 perf_cpu_map__put(cpus); 323 return ret; 324 } 325 326 int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, 327 union perf_event *event, 328 struct perf_sample *sample, 329 struct machine *machine) 330 { 331 return machine__process_mmap_event(machine, event, sample); 332 } 333 334 int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, 335 union perf_event *event, 336 struct perf_sample *sample, 337 struct machine *machine) 338 { 339 return machine__process_mmap2_event(machine, event, sample); 340 } 341 342 size_t perf_event__fprintf_task(union perf_event *event, FILE *fp) 343 { 344 return fprintf(fp, "(%d:%d):(%d:%d)\n", 345 event->fork.pid, event->fork.tid, 346 event->fork.ppid, event->fork.ptid); 347 } 348 349 int perf_event__process_fork(struct perf_tool *tool __maybe_unused, 350 union perf_event *event, 351 struct perf_sample *sample, 352 struct machine *machine) 353 { 354 return machine__process_fork_event(machine, event, sample); 355 } 356 357 int perf_event__process_exit(struct perf_tool *tool __maybe_unused, 358 union perf_event *event, 359 struct perf_sample *sample, 360 struct machine *machine) 361 { 362 return machine__process_exit_event(machine, event, sample); 363 } 364 365 size_t perf_event__fprintf_aux(union perf_event *event, FILE *fp) 366 { 367 return fprintf(fp, " offset: %#"PRI_lx64" size: %#"PRI_lx64" flags: %#"PRI_lx64" [%s%s%s]\n", 368 event->aux.aux_offset, event->aux.aux_size, 369 event->aux.flags, 370 event->aux.flags & PERF_AUX_FLAG_TRUNCATED ? "T" : "", 371 event->aux.flags & PERF_AUX_FLAG_OVERWRITE ? "O" : "", 372 event->aux.flags & PERF_AUX_FLAG_PARTIAL ? "P" : ""); 373 } 374 375 size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp) 376 { 377 return fprintf(fp, " pid: %u tid: %u\n", 378 event->itrace_start.pid, event->itrace_start.tid); 379 } 380 381 size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) 382 { 383 bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT; 384 const char *in_out = !out ? "IN " : 385 !(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_PREEMPT) ? 386 "OUT " : "OUT preempt"; 387 388 if (event->header.type == PERF_RECORD_SWITCH) 389 return fprintf(fp, " %s\n", in_out); 390 391 return fprintf(fp, " %s %s pid/tid: %5u/%-5u\n", 392 in_out, out ? "next" : "prev", 393 event->context_switch.next_prev_pid, 394 event->context_switch.next_prev_tid); 395 } 396 397 static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp) 398 { 399 return fprintf(fp, " lost %" PRI_lu64 "\n", event->lost.lost); 400 } 401 402 size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) 403 { 404 return fprintf(fp, " addr %" PRI_lx64 " len %u type %u flags 0x%x name %s\n", 405 event->ksymbol.addr, event->ksymbol.len, 406 event->ksymbol.ksym_type, 407 event->ksymbol.flags, event->ksymbol.name); 408 } 409 410 size_t perf_event__fprintf_bpf(union perf_event *event, FILE *fp) 411 { 412 return fprintf(fp, " type %u, flags %u, id %u\n", 413 event->bpf.type, event->bpf.flags, event->bpf.id); 414 } 415 416 size_t perf_event__fprintf(union perf_event *event, FILE *fp) 417 { 418 size_t ret = fprintf(fp, "PERF_RECORD_%s", 419 perf_event__name(event->header.type)); 420 421 switch (event->header.type) { 422 case PERF_RECORD_COMM: 423 ret += perf_event__fprintf_comm(event, fp); 424 break; 425 case PERF_RECORD_FORK: 426 case PERF_RECORD_EXIT: 427 ret += perf_event__fprintf_task(event, fp); 428 break; 429 case PERF_RECORD_MMAP: 430 ret += perf_event__fprintf_mmap(event, fp); 431 break; 432 case PERF_RECORD_NAMESPACES: 433 ret += perf_event__fprintf_namespaces(event, fp); 434 break; 435 case PERF_RECORD_CGROUP: 436 ret += perf_event__fprintf_cgroup(event, fp); 437 break; 438 case PERF_RECORD_MMAP2: 439 ret += perf_event__fprintf_mmap2(event, fp); 440 break; 441 case PERF_RECORD_AUX: 442 ret += perf_event__fprintf_aux(event, fp); 443 break; 444 case PERF_RECORD_ITRACE_START: 445 ret += perf_event__fprintf_itrace_start(event, fp); 446 break; 447 case PERF_RECORD_SWITCH: 448 case PERF_RECORD_SWITCH_CPU_WIDE: 449 ret += perf_event__fprintf_switch(event, fp); 450 break; 451 case PERF_RECORD_LOST: 452 ret += perf_event__fprintf_lost(event, fp); 453 break; 454 case PERF_RECORD_KSYMBOL: 455 ret += perf_event__fprintf_ksymbol(event, fp); 456 break; 457 case PERF_RECORD_BPF_EVENT: 458 ret += perf_event__fprintf_bpf(event, fp); 459 break; 460 default: 461 ret += fprintf(fp, "\n"); 462 } 463 464 return ret; 465 } 466 467 int perf_event__process(struct perf_tool *tool __maybe_unused, 468 union perf_event *event, 469 struct perf_sample *sample, 470 struct machine *machine) 471 { 472 return machine__process_event(machine, event, sample); 473 } 474 475 struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr, 476 struct addr_location *al) 477 { 478 struct maps *maps = thread->maps; 479 struct machine *machine = maps->machine; 480 bool load_map = false; 481 482 al->maps = maps; 483 al->thread = thread; 484 al->addr = addr; 485 al->cpumode = cpumode; 486 al->filtered = 0; 487 488 if (machine == NULL) { 489 al->map = NULL; 490 return NULL; 491 } 492 493 if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) { 494 al->level = 'k'; 495 al->maps = maps = &machine->kmaps; 496 load_map = true; 497 } else if (cpumode == PERF_RECORD_MISC_USER && perf_host) { 498 al->level = '.'; 499 } else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) { 500 al->level = 'g'; 501 al->maps = maps = &machine->kmaps; 502 load_map = true; 503 } else if (cpumode == PERF_RECORD_MISC_GUEST_USER && perf_guest) { 504 al->level = 'u'; 505 } else { 506 al->level = 'H'; 507 al->map = NULL; 508 509 if ((cpumode == PERF_RECORD_MISC_GUEST_USER || 510 cpumode == PERF_RECORD_MISC_GUEST_KERNEL) && 511 !perf_guest) 512 al->filtered |= (1 << HIST_FILTER__GUEST); 513 if ((cpumode == PERF_RECORD_MISC_USER || 514 cpumode == PERF_RECORD_MISC_KERNEL) && 515 !perf_host) 516 al->filtered |= (1 << HIST_FILTER__HOST); 517 518 return NULL; 519 } 520 521 al->map = maps__find(maps, al->addr); 522 if (al->map != NULL) { 523 /* 524 * Kernel maps might be changed when loading symbols so loading 525 * must be done prior to using kernel maps. 526 */ 527 if (load_map) 528 map__load(al->map); 529 al->addr = al->map->map_ip(al->map, al->addr); 530 } 531 532 return al->map; 533 } 534 535 /* 536 * For branch stacks or branch samples, the sample cpumode might not be correct 537 * because it applies only to the sample 'ip' and not necessary to 'addr' or 538 * branch stack addresses. If possible, use a fallback to deal with those cases. 539 */ 540 struct map *thread__find_map_fb(struct thread *thread, u8 cpumode, u64 addr, 541 struct addr_location *al) 542 { 543 struct map *map = thread__find_map(thread, cpumode, addr, al); 544 struct machine *machine = thread->maps->machine; 545 u8 addr_cpumode = machine__addr_cpumode(machine, cpumode, addr); 546 547 if (map || addr_cpumode == cpumode) 548 return map; 549 550 return thread__find_map(thread, addr_cpumode, addr, al); 551 } 552 553 struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode, 554 u64 addr, struct addr_location *al) 555 { 556 al->sym = NULL; 557 if (thread__find_map(thread, cpumode, addr, al)) 558 al->sym = map__find_symbol(al->map, al->addr); 559 return al->sym; 560 } 561 562 struct symbol *thread__find_symbol_fb(struct thread *thread, u8 cpumode, 563 u64 addr, struct addr_location *al) 564 { 565 al->sym = NULL; 566 if (thread__find_map_fb(thread, cpumode, addr, al)) 567 al->sym = map__find_symbol(al->map, al->addr); 568 return al->sym; 569 } 570 571 /* 572 * Callers need to drop the reference to al->thread, obtained in 573 * machine__findnew_thread() 574 */ 575 int machine__resolve(struct machine *machine, struct addr_location *al, 576 struct perf_sample *sample) 577 { 578 struct thread *thread = machine__findnew_thread(machine, sample->pid, 579 sample->tid); 580 581 if (thread == NULL) 582 return -1; 583 584 dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid); 585 thread__find_map(thread, sample->cpumode, sample->ip, al); 586 dump_printf(" ...... dso: %s\n", 587 al->map ? al->map->dso->long_name : 588 al->level == 'H' ? "[hypervisor]" : "<not found>"); 589 590 if (thread__is_filtered(thread)) 591 al->filtered |= (1 << HIST_FILTER__THREAD); 592 593 al->sym = NULL; 594 al->cpu = sample->cpu; 595 al->socket = -1; 596 al->srcline = NULL; 597 598 if (al->cpu >= 0) { 599 struct perf_env *env = machine->env; 600 601 if (env && env->cpu) 602 al->socket = env->cpu[al->cpu].socket_id; 603 } 604 605 if (al->map) { 606 struct dso *dso = al->map->dso; 607 608 if (symbol_conf.dso_list && 609 (!dso || !(strlist__has_entry(symbol_conf.dso_list, 610 dso->short_name) || 611 (dso->short_name != dso->long_name && 612 strlist__has_entry(symbol_conf.dso_list, 613 dso->long_name))))) { 614 al->filtered |= (1 << HIST_FILTER__DSO); 615 } 616 617 al->sym = map__find_symbol(al->map, al->addr); 618 } 619 620 if (symbol_conf.sym_list) { 621 int ret = 0; 622 char al_addr_str[32]; 623 size_t sz = sizeof(al_addr_str); 624 625 if (al->sym) { 626 ret = strlist__has_entry(symbol_conf.sym_list, 627 al->sym->name); 628 } 629 if (!ret && al->sym) { 630 snprintf(al_addr_str, sz, "0x%"PRIx64, 631 al->map->unmap_ip(al->map, al->sym->start)); 632 ret = strlist__has_entry(symbol_conf.sym_list, 633 al_addr_str); 634 } 635 if (!ret) 636 al->filtered |= (1 << HIST_FILTER__SYMBOL); 637 } 638 639 return 0; 640 } 641 642 /* 643 * The preprocess_sample method will return with reference counts for the 644 * in it, when done using (and perhaps getting ref counts if needing to 645 * keep a pointer to one of those entries) it must be paired with 646 * addr_location__put(), so that the refcounts can be decremented. 647 */ 648 void addr_location__put(struct addr_location *al) 649 { 650 thread__zput(al->thread); 651 } 652 653 bool is_bts_event(struct perf_event_attr *attr) 654 { 655 return attr->type == PERF_TYPE_HARDWARE && 656 (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) && 657 attr->sample_period == 1; 658 } 659 660 bool sample_addr_correlates_sym(struct perf_event_attr *attr) 661 { 662 if (attr->type == PERF_TYPE_SOFTWARE && 663 (attr->config == PERF_COUNT_SW_PAGE_FAULTS || 664 attr->config == PERF_COUNT_SW_PAGE_FAULTS_MIN || 665 attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)) 666 return true; 667 668 if (is_bts_event(attr)) 669 return true; 670 671 return false; 672 } 673 674 void thread__resolve(struct thread *thread, struct addr_location *al, 675 struct perf_sample *sample) 676 { 677 thread__find_map_fb(thread, sample->cpumode, sample->addr, al); 678 679 al->cpu = sample->cpu; 680 al->sym = NULL; 681 682 if (al->map) 683 al->sym = map__find_symbol(al->map, al->addr); 684 } 685