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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'perf-tools-fixes-for-v5.10-2020-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tool fixes from Arnaldo Carvalho de Melo:

- Fix die_entrypc() when DW_AT_ranges DWARF attribute not available

- Cope with broken DWARF (missing DW_AT_declaration) generated by some
recent gcc versions

- Do not generate CGROUP metadata events when not asked to in 'perf
record'

- Use proper CPU for shadow stats in 'perf stat'

- Update copy of libbpf's hashmap.c, silencing tools/perf build warning

- Fix return value in 'perf diff'

* tag 'perf-tools-fixes-for-v5.10-2020-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
perf probe: Change function definition check due to broken DWARF
perf probe: Fix to die_entrypc() returns error correctly
perf stat: Use proper cpu for shadow stats
perf record: Synthesize cgroup events only if needed
perf diff: Fix error return value in __cmd_diff()
perf tools: Update copy of libbpf's hashmap.c

+43 -15
+3 -1
tools/perf/builtin-diff.c
··· 1222 1222 if (compute == COMPUTE_STREAM) { 1223 1223 d->evlist_streams = evlist__create_streams( 1224 1224 d->session->evlist, 5); 1225 - if (!d->evlist_streams) 1225 + if (!d->evlist_streams) { 1226 + ret = -ENOMEM; 1226 1227 goto out_delete; 1228 + } 1227 1229 } 1228 1230 } 1229 1231
+26 -2
tools/perf/util/dwarf-aux.c
··· 356 356 bool die_is_func_def(Dwarf_Die *dw_die) 357 357 { 358 358 Dwarf_Attribute attr; 359 + Dwarf_Addr addr = 0; 359 360 360 - return (dwarf_tag(dw_die) == DW_TAG_subprogram && 361 - dwarf_attr(dw_die, DW_AT_declaration, &attr) == NULL); 361 + if (dwarf_tag(dw_die) != DW_TAG_subprogram) 362 + return false; 363 + 364 + if (dwarf_attr(dw_die, DW_AT_declaration, &attr)) 365 + return false; 366 + 367 + /* 368 + * DW_AT_declaration can be lost from function declaration 369 + * by gcc's bug #97060. 370 + * So we need to check this subprogram DIE has DW_AT_inline 371 + * or an entry address. 372 + */ 373 + if (!dwarf_attr(dw_die, DW_AT_inline, &attr) && 374 + die_entrypc(dw_die, &addr) < 0) 375 + return false; 376 + 377 + return true; 362 378 } 363 379 364 380 /** ··· 389 373 int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr) 390 374 { 391 375 Dwarf_Addr base, end; 376 + Dwarf_Attribute attr; 392 377 393 378 if (!addr) 394 379 return -EINVAL; 395 380 396 381 if (dwarf_entrypc(dw_die, addr) == 0) 397 382 return 0; 383 + 384 + /* 385 + * Since the dwarf_ranges() will return 0 if there is no 386 + * DW_AT_ranges attribute, we should check it first. 387 + */ 388 + if (!dwarf_attr(dw_die, DW_AT_ranges, &attr)) 389 + return -ENOENT; 398 390 399 391 return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0; 400 392 }
+9 -6
tools/perf/util/hashmap.h
··· 15 15 static inline size_t hash_bits(size_t h, int bits) 16 16 { 17 17 /* shuffle bits and return requested number of upper bits */ 18 + if (bits == 0) 19 + return 0; 20 + 18 21 #if (__SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__) 19 22 /* LP64 case */ 20 23 return (h * 11400714819323198485llu) >> (__SIZEOF_LONG_LONG__ * 8 - bits); ··· 177 174 * @key: key to iterate entries for 178 175 */ 179 176 #define hashmap__for_each_key_entry(map, cur, _key) \ 180 - for (cur = ({ size_t bkt = hash_bits(map->hash_fn((_key), map->ctx),\ 181 - map->cap_bits); \ 182 - map->buckets ? map->buckets[bkt] : NULL; }); \ 177 + for (cur = map->buckets \ 178 + ? map->buckets[hash_bits(map->hash_fn((_key), map->ctx), map->cap_bits)] \ 179 + : NULL; \ 183 180 cur; \ 184 181 cur = cur->next) \ 185 182 if (map->equal_fn(cur->key, (_key), map->ctx)) 186 183 187 184 #define hashmap__for_each_key_entry_safe(map, cur, tmp, _key) \ 188 - for (cur = ({ size_t bkt = hash_bits(map->hash_fn((_key), map->ctx),\ 189 - map->cap_bits); \ 190 - cur = map->buckets ? map->buckets[bkt] : NULL; }); \ 185 + for (cur = map->buckets \ 186 + ? map->buckets[hash_bits(map->hash_fn((_key), map->ctx), map->cap_bits)] \ 187 + : NULL; \ 191 188 cur && ({ tmp = cur->next; true; }); \ 192 189 cur = tmp) \ 193 190 if (map->equal_fn(cur->key, (_key), map->ctx))
+1 -2
tools/perf/util/probe-finder.c
··· 1885 1885 if (lr->file && strtailcmp(lr->file, dwarf_decl_file(sp_die))) 1886 1886 return DWARF_CB_OK; 1887 1887 1888 - if (die_is_func_def(sp_die) && 1889 - die_match_name(sp_die, lr->function)) { 1888 + if (die_match_name(sp_die, lr->function) && die_is_func_def(sp_die)) { 1890 1889 lf->fname = dwarf_decl_file(sp_die); 1891 1890 dwarf_decl_line(sp_die, &lr->offset); 1892 1891 pr_debug("fname: %s, lineno:%d\n", lf->fname, lr->offset);
+1 -4
tools/perf/util/stat-display.c
··· 324 324 struct evlist *evlist = evsel->evlist; 325 325 int i; 326 326 327 - if (!config->aggr_get_id) 328 - return 0; 329 - 330 327 if (config->aggr_mode == AGGR_NONE) 331 328 return id; 332 329 333 - if (config->aggr_mode == AGGR_GLOBAL) 330 + if (!config->aggr_get_id) 334 331 return 0; 335 332 336 333 for (i = 0; i < evsel__nr_cpus(evsel); i++) {
+3
tools/perf/util/synthetic-events.c
··· 563 563 char cgrp_root[PATH_MAX]; 564 564 size_t mount_len; /* length of mount point in the path */ 565 565 566 + if (!tool || !tool->cgroup_events) 567 + return 0; 568 + 566 569 if (cgroupfs_find_mountpoint(cgrp_root, PATH_MAX, "perf_event") < 0) { 567 570 pr_debug("cannot find cgroup mount point\n"); 568 571 return -1;