Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf callchain: Use 'struct map_symbol' in 'struct callchain_cursor_node'

To ease passing around map+symbol, just like done for other parts of the
tree recently.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+71 -62
+2 -2
tools/perf/builtin-kmem.c
··· 412 412 sizeof(key), callcmp); 413 413 if (!caller) { 414 414 /* found */ 415 - if (node->map) 416 - addr = map__unmap_ip(node->map, node->ip); 415 + if (node->ms.map) 416 + addr = map__unmap_ip(node->ms.map, node->ip); 417 417 else 418 418 addr = node->ip; 419 419
+1 -1
tools/perf/builtin-sched.c
··· 2172 2172 if (node == NULL) 2173 2173 break; 2174 2174 2175 - sym = node->sym; 2175 + sym = node->ms.sym; 2176 2176 if (sym) { 2177 2177 if (!strcmp(sym->name, "schedule") || 2178 2178 !strcmp(sym->name, "__schedule") ||
+16 -17
tools/perf/util/callchain.c
··· 582 582 return -1; 583 583 } 584 584 call->ip = cursor_node->ip; 585 - call->ms.sym = cursor_node->sym; 586 - call->ms.map = map__get(cursor_node->map); 585 + call->ms = cursor_node->ms; 586 + map__get(call->ms.map); 587 587 call->srcline = cursor_node->srcline; 588 588 589 589 if (cursor_node->branch) { ··· 720 720 /* otherwise fall-back to symbol-based comparison below */ 721 721 __fallthrough; 722 722 case CCKEY_FUNCTION: 723 - if (node->sym && cnode->ms.sym) { 723 + if (node->ms.sym && cnode->ms.sym) { 724 724 /* 725 725 * Compare inlined frames based on their symbol name 726 726 * because different inlined frames will have the same 727 727 * symbol start. Otherwise do a faster comparison based 728 728 * on the symbol start address. 729 729 */ 730 - if (cnode->ms.sym->inlined || node->sym->inlined) { 730 + if (cnode->ms.sym->inlined || node->ms.sym->inlined) { 731 731 match = match_chain_strings(cnode->ms.sym->name, 732 - node->sym->name); 732 + node->ms.sym->name); 733 733 if (match != MATCH_ERROR) 734 734 break; 735 735 } else { 736 736 match = match_chain_dso_addresses(cnode->ms.map, cnode->ms.sym->start, 737 - node->map, node->sym->start); 737 + node->ms.map, node->ms.sym->start); 738 738 break; 739 739 } 740 740 } ··· 742 742 __fallthrough; 743 743 case CCKEY_ADDRESS: 744 744 default: 745 - match = match_chain_dso_addresses(cnode->ms.map, cnode->ip, node->map, node->ip); 745 + match = match_chain_dso_addresses(cnode->ms.map, cnode->ip, node->ms.map, node->ip); 746 746 break; 747 747 } 748 748 ··· 1004 1004 int err = 0; 1005 1005 1006 1006 list_for_each_entry_safe(list, next_list, &src->val, list) { 1007 - callchain_cursor_append(cursor, list->ip, 1008 - list->ms.map, list->ms.sym, 1007 + callchain_cursor_append(cursor, list->ip, &list->ms, 1009 1008 false, NULL, 0, 0, 0, list->srcline); 1010 1009 list_del_init(&list->list); 1011 1010 map__zput(list->ms.map); ··· 1043 1044 } 1044 1045 1045 1046 int callchain_cursor_append(struct callchain_cursor *cursor, 1046 - u64 ip, struct map *map, struct symbol *sym, 1047 + u64 ip, struct map_symbol *ms, 1047 1048 bool branch, struct branch_flags *flags, 1048 1049 int nr_loop_iter, u64 iter_cycles, u64 branch_from, 1049 1050 const char *srcline) ··· 1059 1060 } 1060 1061 1061 1062 node->ip = ip; 1062 - map__zput(node->map); 1063 - node->map = map__get(map); 1064 - node->sym = sym; 1063 + map__zput(node->ms.map); 1064 + node->ms = *ms; 1065 + map__get(node->ms.map); 1065 1066 node->branch = branch; 1066 1067 node->nr_loop_iter = nr_loop_iter; 1067 1068 node->iter_cycles = iter_cycles; ··· 1106 1107 int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node, 1107 1108 bool hide_unresolved) 1108 1109 { 1109 - al->map = node->map; 1110 - al->sym = node->sym; 1110 + al->map = node->ms.map; 1111 + al->sym = node->ms.sym; 1111 1112 al->srcline = node->srcline; 1112 1113 al->addr = node->ip; 1113 1114 ··· 1570 1571 if (node == NULL) 1571 1572 break; 1572 1573 1573 - rc = callchain_cursor_append(dst, node->ip, node->map, node->sym, 1574 + rc = callchain_cursor_append(dst, node->ip, &node->ms, 1574 1575 node->branch, &node->branch_flags, 1575 1576 node->nr_loop_iter, 1576 1577 node->iter_cycles, ··· 1596 1597 cursor->last = &cursor->first; 1597 1598 1598 1599 for (node = cursor->first; node != NULL; node = node->next) 1599 - map__zput(node->map); 1600 + map__zput(node->ms.map); 1600 1601 }
+2 -3
tools/perf/util/callchain.h
··· 141 141 */ 142 142 struct callchain_cursor_node { 143 143 u64 ip; 144 - struct map *map; 145 - struct symbol *sym; 144 + struct map_symbol ms; 146 145 const char *srcline; 147 146 bool branch; 148 147 struct branch_flags branch_flags; ··· 194 195 void callchain_cursor_reset(struct callchain_cursor *cursor); 195 196 196 197 int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, 197 - struct map *map, struct symbol *sym, 198 + struct map_symbol *ms, 198 199 bool branch, struct branch_flags *flags, 199 200 int nr_loop_iter, u64 iter_cycles, u64 branch_from, 200 201 const char *srcline);
+2 -2
tools/perf/util/db-export.c
··· 249 249 * constructing an addr_location struct and then passing it to 250 250 * db_ids_from_al() to perform the export. 251 251 */ 252 - al.sym = node->sym; 253 - al.map = node->map; 252 + al.sym = node->ms.sym; 253 + al.map = node->ms.map; 254 254 al.mg = thread->mg; 255 255 al.addr = node->ip; 256 256
+17 -12
tools/perf/util/evsel_fprintf.c
··· 125 125 callchain_cursor_commit(cursor); 126 126 127 127 while (1) { 128 + struct symbol *sym; 129 + struct map *map; 128 130 u64 addr = 0; 129 131 130 132 node = callchain_cursor_current(cursor); 131 133 if (!node) 132 134 break; 133 135 134 - if (node->sym && node->sym->ignore && print_skip_ignored) 136 + sym = node->ms.sym; 137 + map = node->ms.map; 138 + 139 + if (sym && sym->ignore && print_skip_ignored) 135 140 goto next; 136 141 137 142 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); ··· 147 142 if (print_ip) 148 143 printed += fprintf(fp, "%c%16" PRIx64, s, node->ip); 149 144 150 - if (node->map) 151 - addr = node->map->map_ip(node->map, node->ip); 145 + if (map) 146 + addr = map->map_ip(map, node->ip); 152 147 153 148 if (print_sym) { 154 149 printed += fprintf(fp, " "); 155 150 node_al.addr = addr; 156 - node_al.map = node->map; 151 + node_al.map = map; 157 152 158 153 if (print_symoffset) { 159 - printed += __symbol__fprintf_symname_offs(node->sym, &node_al, 154 + printed += __symbol__fprintf_symname_offs(sym, &node_al, 160 155 print_unknown_as_addr, 161 156 true, fp); 162 157 } else { 163 - printed += __symbol__fprintf_symname(node->sym, &node_al, 158 + printed += __symbol__fprintf_symname(sym, &node_al, 164 159 print_unknown_as_addr, fp); 165 160 } 166 161 } 167 162 168 - if (print_dso && (!node->sym || !node->sym->inlined)) { 163 + if (print_dso && (!sym || !sym->inlined)) { 169 164 printed += fprintf(fp, " ("); 170 - printed += map__fprintf_dsoname(node->map, fp); 165 + printed += map__fprintf_dsoname(map, fp); 171 166 printed += fprintf(fp, ")"); 172 167 } 173 168 174 169 if (print_srcline) 175 - printed += map__fprintf_srcline(node->map, addr, "\n ", fp); 170 + printed += map__fprintf_srcline(map, addr, "\n ", fp); 176 171 177 - if (node->sym && node->sym->inlined) 172 + if (sym && sym->inlined) 178 173 printed += fprintf(fp, " (inlined)"); 179 174 180 175 if (!print_oneline) 181 176 printed += fprintf(fp, "\n"); 182 177 183 178 /* Add srccode here too? */ 184 - if (bt_stop_list && node->sym && 185 - strlist__has_entry(bt_stop_list, node->sym->name)) { 179 + if (bt_stop_list && sym && 180 + strlist__has_entry(bt_stop_list, sym->name)) { 186 181 break; 187 182 } 188 183
+15 -9
tools/perf/util/machine.c
··· 2006 2006 return mi; 2007 2007 } 2008 2008 2009 - static char *callchain_srcline(struct map *map, struct symbol *sym, u64 ip) 2009 + static char *callchain_srcline(struct map_symbol *ms, u64 ip) 2010 2010 { 2011 + struct map *map = ms->map; 2011 2012 char *srcline = NULL; 2012 2013 2013 2014 if (!map || callchain_param.key == CCKEY_FUNCTION) ··· 2020 2019 bool show_addr = callchain_param.key == CCKEY_ADDRESS; 2021 2020 2022 2021 srcline = get_srcline(map->dso, map__rip_2objdump(map, ip), 2023 - sym, show_sym, show_addr, ip); 2022 + ms->sym, show_sym, show_addr, ip); 2024 2023 srcline__tree_insert(&map->dso->srclines, ip, srcline); 2025 2024 } 2026 2025 ··· 2043 2042 struct iterations *iter, 2044 2043 u64 branch_from) 2045 2044 { 2045 + struct map_symbol ms; 2046 2046 struct addr_location al; 2047 2047 int nr_loop_iter = 0; 2048 2048 u64 iter_cycles = 0; ··· 2101 2099 iter_cycles = iter->cycles; 2102 2100 } 2103 2101 2104 - srcline = callchain_srcline(al.map, al.sym, al.addr); 2105 - return callchain_cursor_append(cursor, ip, al.map, al.sym, 2102 + ms.map = al.map; 2103 + ms.sym = al.sym; 2104 + srcline = callchain_srcline(&ms, al.addr); 2105 + return callchain_cursor_append(cursor, ip, &ms, 2106 2106 branch, flags, nr_loop_iter, 2107 2107 iter_cycles, branch_from, srcline); 2108 2108 } ··· 2476 2472 } 2477 2473 2478 2474 list_for_each_entry(ilist, &inline_node->val, list) { 2479 - ret = callchain_cursor_append(cursor, ip, map, 2480 - ilist->symbol, false, 2475 + struct map_symbol ilist_ms = { 2476 + .map = map, 2477 + .sym = ilist->symbol, 2478 + }; 2479 + ret = callchain_cursor_append(cursor, ip, &ilist_ms, false, 2481 2480 NULL, 0, 0, 0, ilist->srcline); 2482 2481 2483 2482 if (ret != 0) ··· 2509 2502 if (entry->ms.map) 2510 2503 addr = map__map_ip(entry->ms.map, entry->ip); 2511 2504 2512 - srcline = callchain_srcline(entry->ms.map, entry->ms.sym, addr); 2513 - return callchain_cursor_append(cursor, entry->ip, 2514 - entry->ms.map, entry->ms.sym, 2505 + srcline = callchain_srcline(&entry->ms, addr); 2506 + return callchain_cursor_append(cursor, entry->ip, &entry->ms, 2515 2507 false, NULL, 0, 0, 0, srcline); 2516 2508 } 2517 2509
+8 -8
tools/perf/util/scripting-engines/trace-event-perl.c
··· 294 294 goto exit; 295 295 } 296 296 297 - if (node->sym) { 297 + if (node->ms.sym) { 298 298 HV *sym = newHV(); 299 299 if (!sym) { 300 300 hv_undef(elem); 301 301 goto exit; 302 302 } 303 - if (!hv_stores(sym, "start", newSVuv(node->sym->start)) || 304 - !hv_stores(sym, "end", newSVuv(node->sym->end)) || 305 - !hv_stores(sym, "binding", newSVuv(node->sym->binding)) || 306 - !hv_stores(sym, "name", newSVpvn(node->sym->name, 307 - node->sym->namelen)) || 303 + if (!hv_stores(sym, "start", newSVuv(node->ms.sym->start)) || 304 + !hv_stores(sym, "end", newSVuv(node->ms.sym->end)) || 305 + !hv_stores(sym, "binding", newSVuv(node->ms.sym->binding)) || 306 + !hv_stores(sym, "name", newSVpvn(node->ms.sym->name, 307 + node->ms.sym->namelen)) || 308 308 !hv_stores(elem, "sym", newRV_noinc((SV*)sym))) { 309 309 hv_undef(sym); 310 310 hv_undef(elem); ··· 312 312 } 313 313 } 314 314 315 - if (node->map) { 316 - struct map *map = node->map; 315 + if (node->ms.map) { 316 + struct map *map = node->ms.map; 317 317 const char *dsoname = "[unknown]"; 318 318 if (map && map->dso) { 319 319 if (symbol_conf.show_kernel_path && map->dso->long_name)
+8 -8
tools/perf/util/scripting-engines/trace-event-python.c
··· 428 428 pydict_set_item_string_decref(pyelem, "ip", 429 429 PyLong_FromUnsignedLongLong(node->ip)); 430 430 431 - if (node->sym) { 431 + if (node->ms.sym) { 432 432 PyObject *pysym = PyDict_New(); 433 433 if (!pysym) 434 434 Py_FatalError("couldn't create Python dictionary"); 435 435 pydict_set_item_string_decref(pysym, "start", 436 - PyLong_FromUnsignedLongLong(node->sym->start)); 436 + PyLong_FromUnsignedLongLong(node->ms.sym->start)); 437 437 pydict_set_item_string_decref(pysym, "end", 438 - PyLong_FromUnsignedLongLong(node->sym->end)); 438 + PyLong_FromUnsignedLongLong(node->ms.sym->end)); 439 439 pydict_set_item_string_decref(pysym, "binding", 440 - _PyLong_FromLong(node->sym->binding)); 440 + _PyLong_FromLong(node->ms.sym->binding)); 441 441 pydict_set_item_string_decref(pysym, "name", 442 - _PyUnicode_FromStringAndSize(node->sym->name, 443 - node->sym->namelen)); 442 + _PyUnicode_FromStringAndSize(node->ms.sym->name, 443 + node->ms.sym->namelen)); 444 444 pydict_set_item_string_decref(pyelem, "sym", pysym); 445 445 } 446 446 447 - if (node->map) { 448 - const char *dsoname = get_dsoname(node->map); 447 + if (node->ms.map) { 448 + const char *dsoname = get_dsoname(node->ms.map); 449 449 450 450 pydict_set_item_string_decref(pyelem, "dso", 451 451 _PyUnicode_FromString(dsoname));