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 branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
"An uncharacteristically large number of bugs popped up in the last
week:

- various tooling fixes, two crashes and build problems
- two Intel PT fixes
- an KNL uncore driver fix
- an Intel PMU driver fix"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf stat: Fallback to user only counters when perf_event_paranoid > 1
perf evsel: Handle EACCESS + perf_event_paranoid=2 in fallback()
perf evsel: Improve EPERM error handling in open_strerror()
tools lib traceevent: Do not reassign parg after collapse_tree()
perf probe: Check if dwarf_getlocations() is available
perf dwarf: Guard !x86_64 definitions under #ifdef else clause
perf tools: Use readdir() instead of deprecated readdir_r()
perf thread_map: Use readdir() instead of deprecated readdir_r()
perf script: Use readdir() instead of deprecated readdir_r()
perf tools: Use readdir() instead of deprecated readdir_r()
perf/core: Disable the event on a truncated AUX record
perf/x86/intel/pt: Generate PMI in the STOP region as well
perf/x86: Fix undefined shift on 32-bit kernels
perf/x86/msr: Fix SMI overflow
perf/x86/intel/uncore: Fix CHA registers configuration procedure for Knights Landing platform
perf diff: Fix duplicated output column

+167 -87
+1 -1
arch/x86/events/intel/core.c
··· 3708 3708 c->idxmsk64 |= (1ULL << x86_pmu.num_counters) - 1; 3709 3709 } 3710 3710 c->idxmsk64 &= 3711 - ~(~0UL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed)); 3711 + ~(~0ULL << (INTEL_PMC_IDX_FIXED + x86_pmu.num_counters_fixed)); 3712 3712 c->weight = hweight64(c->idxmsk64); 3713 3713 } 3714 3714 }
+2
arch/x86/events/intel/pt.c
··· 709 709 710 710 /* clear STOP and INT from current entry */ 711 711 buf->topa_index[buf->stop_pos]->stop = 0; 712 + buf->topa_index[buf->stop_pos]->intr = 0; 712 713 buf->topa_index[buf->intr_pos]->intr = 0; 713 714 714 715 /* how many pages till the STOP marker */ ··· 734 733 buf->intr_pos = idx; 735 734 736 735 buf->topa_index[buf->stop_pos]->stop = 1; 736 + buf->topa_index[buf->stop_pos]->intr = 1; 737 737 buf->topa_index[buf->intr_pos]->intr = 1; 738 738 739 739 return 0;
+7
arch/x86/events/intel/uncore_snbep.c
··· 219 219 #define KNL_CHA_MSR_PMON_BOX_FILTER_TID 0x1ff 220 220 #define KNL_CHA_MSR_PMON_BOX_FILTER_STATE (7 << 18) 221 221 #define KNL_CHA_MSR_PMON_BOX_FILTER_OP (0xfffffe2aULL << 32) 222 + #define KNL_CHA_MSR_PMON_BOX_FILTER_REMOTE_NODE (0x1ULL << 32) 223 + #define KNL_CHA_MSR_PMON_BOX_FILTER_LOCAL_NODE (0x1ULL << 33) 224 + #define KNL_CHA_MSR_PMON_BOX_FILTER_NNC (0x1ULL << 37) 222 225 223 226 /* KNL EDC/MC UCLK */ 224 227 #define KNL_UCLK_MSR_PMON_CTR0_LOW 0x400 ··· 1905 1902 reg1->reg = HSWEP_C0_MSR_PMON_BOX_FILTER0 + 1906 1903 KNL_CHA_MSR_OFFSET * box->pmu->pmu_idx; 1907 1904 reg1->config = event->attr.config1 & knl_cha_filter_mask(idx); 1905 + 1906 + reg1->config |= KNL_CHA_MSR_PMON_BOX_FILTER_REMOTE_NODE; 1907 + reg1->config |= KNL_CHA_MSR_PMON_BOX_FILTER_LOCAL_NODE; 1908 + reg1->config |= KNL_CHA_MSR_PMON_BOX_FILTER_NNC; 1908 1909 reg1->idx = idx; 1909 1910 } 1910 1911 return 0;
+1 -1
arch/x86/events/msr.c
··· 166 166 if (unlikely(event->hw.event_base == MSR_SMI_COUNT)) 167 167 delta = sign_extend64(delta, 31); 168 168 169 - local64_add(now - prev, &event->count); 169 + local64_add(delta, &event->count); 170 170 } 171 171 172 172 static void msr_event_start(struct perf_event *event, int flags)
+9 -1
kernel/events/ring_buffer.c
··· 347 347 bool truncated) 348 348 { 349 349 struct ring_buffer *rb = handle->rb; 350 + bool wakeup = truncated; 350 351 unsigned long aux_head; 351 352 u64 flags = 0; 352 353 ··· 376 375 aux_head = rb->user_page->aux_head = local_read(&rb->aux_head); 377 376 378 377 if (aux_head - local_read(&rb->aux_wakeup) >= rb->aux_watermark) { 379 - perf_output_wakeup(handle); 378 + wakeup = true; 380 379 local_add(rb->aux_watermark, &rb->aux_wakeup); 381 380 } 381 + 382 + if (wakeup) { 383 + if (truncated) 384 + handle->event->pending_disable = 1; 385 + perf_output_wakeup(handle); 386 + } 387 + 382 388 handle->event = NULL; 383 389 384 390 local_set(&rb->aux_nest, 0);
+2
tools/build/Makefile.feature
··· 30 30 FEATURE_TESTS_BASIC := \ 31 31 backtrace \ 32 32 dwarf \ 33 + dwarf_getlocations \ 33 34 fortify-source \ 34 35 sync-compare-and-swap \ 35 36 glibc \ ··· 79 78 80 79 FEATURE_DISPLAY ?= \ 81 80 dwarf \ 81 + dwarf_getlocations \ 82 82 glibc \ 83 83 gtk2 \ 84 84 libaudit \
+4
tools/build/feature/Makefile
··· 3 3 test-backtrace.bin \ 4 4 test-bionic.bin \ 5 5 test-dwarf.bin \ 6 + test-dwarf_getlocations.bin \ 6 7 test-fortify-source.bin \ 7 8 test-sync-compare-and-swap.bin \ 8 9 test-glibc.bin \ ··· 81 80 endif 82 81 83 82 $(OUTPUT)test-dwarf.bin: 83 + $(BUILD) $(DWARFLIBS) 84 + 85 + $(OUTPUT)test-dwarf_getlocations.bin: 84 86 $(BUILD) $(DWARFLIBS) 85 87 86 88 $(OUTPUT)test-libelf-mmap.bin:
+5
tools/build/feature/test-all.c
··· 41 41 # include "test-dwarf.c" 42 42 #undef main 43 43 44 + #define main main_test_dwarf_getlocations 45 + # include "test-dwarf_getlocations.c" 46 + #undef main 47 + 44 48 #define main main_test_libelf_getphdrnum 45 49 # include "test-libelf-getphdrnum.c" 46 50 #undef main ··· 147 143 main_test_libelf_mmap(); 148 144 main_test_glibc(); 149 145 main_test_dwarf(); 146 + main_test_dwarf_getlocations(); 150 147 main_test_libelf_getphdrnum(); 151 148 main_test_libunwind(); 152 149 main_test_libaudit();
+12
tools/build/feature/test-dwarf_getlocations.c
··· 1 + #include <stdlib.h> 2 + #include <elfutils/libdw.h> 3 + 4 + int main(void) 5 + { 6 + Dwarf_Addr base, start, end; 7 + Dwarf_Attribute attr; 8 + Dwarf_Op *op; 9 + size_t nops; 10 + ptrdiff_t offset = 0; 11 + return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops); 12 + }
+2 -2
tools/lib/traceevent/parse-filter.c
··· 1164 1164 current_op = current_exp; 1165 1165 1166 1166 ret = collapse_tree(current_op, parg, error_str); 1167 + /* collapse_tree() may free current_op, and updates parg accordingly */ 1168 + current_op = NULL; 1167 1169 if (ret < 0) 1168 1170 goto fail; 1169 - 1170 - *parg = current_op; 1171 1171 1172 1172 free(token); 1173 1173 return 0;
+4 -4
tools/perf/arch/x86/util/dwarf-regs.c
··· 63 63 # define REG_OFFSET_NAME_32(n, r) {.name = n, .offset = offsetof(struct pt_regs, r)} 64 64 #endif 65 65 66 + /* TODO: switching by dwarf address size */ 67 + #ifndef __x86_64__ 66 68 static const struct pt_regs_offset x86_32_regoffset_table[] = { 67 69 REG_OFFSET_NAME_32("%ax", eax), 68 70 REG_OFFSET_NAME_32("%cx", ecx), ··· 77 75 REG_OFFSET_END, 78 76 }; 79 77 78 + #define regoffset_table x86_32_regoffset_table 79 + #else 80 80 static const struct pt_regs_offset x86_64_regoffset_table[] = { 81 81 REG_OFFSET_NAME_64("%ax", rax), 82 82 REG_OFFSET_NAME_64("%dx", rdx), ··· 99 95 REG_OFFSET_END, 100 96 }; 101 97 102 - /* TODO: switching by dwarf address size */ 103 - #ifdef __x86_64__ 104 98 #define regoffset_table x86_64_regoffset_table 105 - #else 106 - #define regoffset_table x86_32_regoffset_table 107 99 #endif 108 100 109 101 /* Minus 1 for the ending REG_OFFSET_END */
+33 -35
tools/perf/builtin-script.c
··· 1415 1415 return S_ISDIR(st.st_mode); 1416 1416 } 1417 1417 1418 - #define for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next)\ 1419 - while (!readdir_r(scripts_dir, &lang_dirent, &lang_next) && \ 1420 - lang_next) \ 1421 - if ((lang_dirent.d_type == DT_DIR || \ 1422 - (lang_dirent.d_type == DT_UNKNOWN && \ 1423 - is_directory(scripts_path, &lang_dirent))) && \ 1424 - (strcmp(lang_dirent.d_name, ".")) && \ 1425 - (strcmp(lang_dirent.d_name, ".."))) 1418 + #define for_each_lang(scripts_path, scripts_dir, lang_dirent) \ 1419 + while ((lang_dirent = readdir(scripts_dir)) != NULL) \ 1420 + if ((lang_dirent->d_type == DT_DIR || \ 1421 + (lang_dirent->d_type == DT_UNKNOWN && \ 1422 + is_directory(scripts_path, lang_dirent))) && \ 1423 + (strcmp(lang_dirent->d_name, ".")) && \ 1424 + (strcmp(lang_dirent->d_name, ".."))) 1426 1425 1427 - #define for_each_script(lang_path, lang_dir, script_dirent, script_next)\ 1428 - while (!readdir_r(lang_dir, &script_dirent, &script_next) && \ 1429 - script_next) \ 1430 - if (script_dirent.d_type != DT_DIR && \ 1431 - (script_dirent.d_type != DT_UNKNOWN || \ 1432 - !is_directory(lang_path, &script_dirent))) 1426 + #define for_each_script(lang_path, lang_dir, script_dirent) \ 1427 + while ((script_dirent = readdir(lang_dir)) != NULL) \ 1428 + if (script_dirent->d_type != DT_DIR && \ 1429 + (script_dirent->d_type != DT_UNKNOWN || \ 1430 + !is_directory(lang_path, script_dirent))) 1433 1431 1434 1432 1435 1433 #define RECORD_SUFFIX "-record" ··· 1573 1575 const char *s __maybe_unused, 1574 1576 int unset __maybe_unused) 1575 1577 { 1576 - struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1578 + struct dirent *script_dirent, *lang_dirent; 1577 1579 char scripts_path[MAXPATHLEN]; 1578 1580 DIR *scripts_dir, *lang_dir; 1579 1581 char script_path[MAXPATHLEN]; ··· 1588 1590 if (!scripts_dir) 1589 1591 return -1; 1590 1592 1591 - for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1593 + for_each_lang(scripts_path, scripts_dir, lang_dirent) { 1592 1594 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1593 - lang_dirent.d_name); 1595 + lang_dirent->d_name); 1594 1596 lang_dir = opendir(lang_path); 1595 1597 if (!lang_dir) 1596 1598 continue; 1597 1599 1598 - for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1599 - script_root = get_script_root(&script_dirent, REPORT_SUFFIX); 1600 + for_each_script(lang_path, lang_dir, script_dirent) { 1601 + script_root = get_script_root(script_dirent, REPORT_SUFFIX); 1600 1602 if (script_root) { 1601 1603 desc = script_desc__findnew(script_root); 1602 1604 snprintf(script_path, MAXPATHLEN, "%s/%s", 1603 - lang_path, script_dirent.d_name); 1605 + lang_path, script_dirent->d_name); 1604 1606 read_script_info(desc, script_path); 1605 1607 free(script_root); 1606 1608 } ··· 1688 1690 */ 1689 1691 int find_scripts(char **scripts_array, char **scripts_path_array) 1690 1692 { 1691 - struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1693 + struct dirent *script_dirent, *lang_dirent; 1692 1694 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN]; 1693 1695 DIR *scripts_dir, *lang_dir; 1694 1696 struct perf_session *session; ··· 1711 1713 return -1; 1712 1714 } 1713 1715 1714 - for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1716 + for_each_lang(scripts_path, scripts_dir, lang_dirent) { 1715 1717 snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, 1716 - lang_dirent.d_name); 1718 + lang_dirent->d_name); 1717 1719 #ifdef NO_LIBPERL 1718 1720 if (strstr(lang_path, "perl")) 1719 1721 continue; ··· 1727 1729 if (!lang_dir) 1728 1730 continue; 1729 1731 1730 - for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1732 + for_each_script(lang_path, lang_dir, script_dirent) { 1731 1733 /* Skip those real time scripts: xxxtop.p[yl] */ 1732 - if (strstr(script_dirent.d_name, "top.")) 1734 + if (strstr(script_dirent->d_name, "top.")) 1733 1735 continue; 1734 1736 sprintf(scripts_path_array[i], "%s/%s", lang_path, 1735 - script_dirent.d_name); 1736 - temp = strchr(script_dirent.d_name, '.'); 1737 + script_dirent->d_name); 1738 + temp = strchr(script_dirent->d_name, '.'); 1737 1739 snprintf(scripts_array[i], 1738 - (temp - script_dirent.d_name) + 1, 1739 - "%s", script_dirent.d_name); 1740 + (temp - script_dirent->d_name) + 1, 1741 + "%s", script_dirent->d_name); 1740 1742 1741 1743 if (check_ev_match(lang_path, 1742 1744 scripts_array[i], session)) ··· 1754 1756 1755 1757 static char *get_script_path(const char *script_root, const char *suffix) 1756 1758 { 1757 - struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1759 + struct dirent *script_dirent, *lang_dirent; 1758 1760 char scripts_path[MAXPATHLEN]; 1759 1761 char script_path[MAXPATHLEN]; 1760 1762 DIR *scripts_dir, *lang_dir; ··· 1767 1769 if (!scripts_dir) 1768 1770 return NULL; 1769 1771 1770 - for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1772 + for_each_lang(scripts_path, scripts_dir, lang_dirent) { 1771 1773 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1772 - lang_dirent.d_name); 1774 + lang_dirent->d_name); 1773 1775 lang_dir = opendir(lang_path); 1774 1776 if (!lang_dir) 1775 1777 continue; 1776 1778 1777 - for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1778 - __script_root = get_script_root(&script_dirent, suffix); 1779 + for_each_script(lang_path, lang_dir, script_dirent) { 1780 + __script_root = get_script_root(script_dirent, suffix); 1779 1781 if (__script_root && !strcmp(script_root, __script_root)) { 1780 1782 free(__script_root); 1781 1783 closedir(lang_dir); 1782 1784 closedir(scripts_dir); 1783 1785 snprintf(script_path, MAXPATHLEN, "%s/%s", 1784 - lang_path, script_dirent.d_name); 1786 + lang_path, script_dirent->d_name); 1785 1787 return strdup(script_path); 1786 1788 } 1787 1789 free(__script_root);
+6 -1
tools/perf/builtin-stat.c
··· 528 528 perf_evlist__set_leader(evsel_list); 529 529 530 530 evlist__for_each(evsel_list, counter) { 531 + try_again: 531 532 if (create_perf_stat_counter(counter) < 0) { 532 533 /* 533 534 * PPC returns ENXIO for HW counters until 2.6.37 ··· 545 544 if ((counter->leader != counter) || 546 545 !(counter->leader->nr_members > 1)) 547 546 continue; 548 - } 547 + } else if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { 548 + if (verbose) 549 + ui__warning("%s\n", msg); 550 + goto try_again; 551 + } 549 552 550 553 perf_evsel__open_strerror(counter, &target, 551 554 errno, msg, sizeof(msg));
+6
tools/perf/config/Makefile
··· 268 268 ifneq ($(feature-dwarf), 1) 269 269 msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); 270 270 NO_DWARF := 1 271 + else 272 + ifneq ($(feature-dwarf_getlocations), 1) 273 + msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); 274 + else 275 + CFLAGS += -DHAVE_DWARF_GETLOCATIONS 276 + endif # dwarf_getlocations 271 277 endif # Dwarf support 272 278 endif # libelf support 273 279 endif # NO_LIBELF
+9
tools/perf/util/dwarf-aux.c
··· 959 959 return 0; 960 960 } 961 961 962 + #ifdef HAVE_DWARF_GETLOCATIONS 962 963 /** 963 964 * die_get_var_innermost_scope - Get innermost scope range of given variable DIE 964 965 * @sp_die: a subprogram DIE ··· 1081 1080 1082 1081 return ret; 1083 1082 } 1083 + #else 1084 + int die_get_var_range(Dwarf_Die *sp_die __maybe_unused, 1085 + Dwarf_Die *vr_die __maybe_unused, 1086 + struct strbuf *buf __maybe_unused) 1087 + { 1088 + return -ENOTSUP; 1089 + } 1090 + #endif
+6 -6
tools/perf/util/event.c
··· 433 433 { 434 434 char filename[PATH_MAX]; 435 435 DIR *tasks; 436 - struct dirent dirent, *next; 436 + struct dirent *dirent; 437 437 pid_t tgid, ppid; 438 438 int rc = 0; 439 439 ··· 462 462 return 0; 463 463 } 464 464 465 - while (!readdir_r(tasks, &dirent, &next) && next) { 465 + while ((dirent = readdir(tasks)) != NULL) { 466 466 char *end; 467 467 pid_t _pid; 468 468 469 - _pid = strtol(dirent.d_name, &end, 10); 469 + _pid = strtol(dirent->d_name, &end, 10); 470 470 if (*end) 471 471 continue; 472 472 ··· 575 575 { 576 576 DIR *proc; 577 577 char proc_path[PATH_MAX]; 578 - struct dirent dirent, *next; 578 + struct dirent *dirent; 579 579 union perf_event *comm_event, *mmap_event, *fork_event; 580 580 int err = -1; 581 581 ··· 600 600 if (proc == NULL) 601 601 goto out_free_fork; 602 602 603 - while (!readdir_r(proc, &dirent, &next) && next) { 603 + while ((dirent = readdir(proc)) != NULL) { 604 604 char *end; 605 - pid_t pid = strtol(dirent.d_name, &end, 10); 605 + pid_t pid = strtol(dirent->d_name, &end, 10); 606 606 607 607 if (*end) /* only interested in proper numerical dirents */ 608 608 continue;
+21 -2
tools/perf/util/evsel.c
··· 2345 2345 bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 2346 2346 char *msg, size_t msgsize) 2347 2347 { 2348 + int paranoid; 2349 + 2348 2350 if ((err == ENOENT || err == ENXIO || err == ENODEV) && 2349 2351 evsel->attr.type == PERF_TYPE_HARDWARE && 2350 2352 evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) { ··· 2366 2364 2367 2365 zfree(&evsel->name); 2368 2366 return true; 2367 + } else if (err == EACCES && !evsel->attr.exclude_kernel && 2368 + (paranoid = perf_event_paranoid()) > 1) { 2369 + const char *name = perf_evsel__name(evsel); 2370 + char *new_name; 2371 + 2372 + if (asprintf(&new_name, "%s%su", name, strchr(name, ':') ? "" : ":") < 0) 2373 + return false; 2374 + 2375 + if (evsel->name) 2376 + free(evsel->name); 2377 + evsel->name = new_name; 2378 + scnprintf(msg, msgsize, 2379 + "kernel.perf_event_paranoid=%d, trying to fall back to excluding kernel samples", paranoid); 2380 + evsel->attr.exclude_kernel = 1; 2381 + 2382 + return true; 2369 2383 } 2370 2384 2371 2385 return false; ··· 2400 2382 "Consider tweaking /proc/sys/kernel/perf_event_paranoid,\n" 2401 2383 "which controls use of the performance events system by\n" 2402 2384 "unprivileged users (without CAP_SYS_ADMIN).\n\n" 2403 - "The default value is 1:\n\n" 2385 + "The current value is %d:\n\n" 2404 2386 " -1: Allow use of (almost) all events by all users\n" 2405 2387 ">= 0: Disallow raw tracepoint access by users without CAP_IOC_LOCK\n" 2406 2388 ">= 1: Disallow CPU event access by users without CAP_SYS_ADMIN\n" 2407 2389 ">= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN", 2408 - target->system_wide ? "system-wide " : ""); 2390 + target->system_wide ? "system-wide " : "", 2391 + perf_event_paranoid()); 2409 2392 case ENOENT: 2410 2393 return scnprintf(msg, size, "The %s event is not supported.", 2411 2394 perf_evsel__name(evsel));
+30 -30
tools/perf/util/parse-events.c
··· 138 138 #define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE) 139 139 #define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT) 140 140 141 - #define for_each_subsystem(sys_dir, sys_dirent, sys_next) \ 142 - while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \ 143 - if (sys_dirent.d_type == DT_DIR && \ 144 - (strcmp(sys_dirent.d_name, ".")) && \ 145 - (strcmp(sys_dirent.d_name, ".."))) 141 + #define for_each_subsystem(sys_dir, sys_dirent) \ 142 + while ((sys_dirent = readdir(sys_dir)) != NULL) \ 143 + if (sys_dirent->d_type == DT_DIR && \ 144 + (strcmp(sys_dirent->d_name, ".")) && \ 145 + (strcmp(sys_dirent->d_name, ".."))) 146 146 147 147 static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir) 148 148 { ··· 159 159 return 0; 160 160 } 161 161 162 - #define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) \ 163 - while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \ 164 - if (evt_dirent.d_type == DT_DIR && \ 165 - (strcmp(evt_dirent.d_name, ".")) && \ 166 - (strcmp(evt_dirent.d_name, "..")) && \ 167 - (!tp_event_has_id(&sys_dirent, &evt_dirent))) 162 + #define for_each_event(sys_dirent, evt_dir, evt_dirent) \ 163 + while ((evt_dirent = readdir(evt_dir)) != NULL) \ 164 + if (evt_dirent->d_type == DT_DIR && \ 165 + (strcmp(evt_dirent->d_name, ".")) && \ 166 + (strcmp(evt_dirent->d_name, "..")) && \ 167 + (!tp_event_has_id(sys_dirent, evt_dirent))) 168 168 169 169 #define MAX_EVENT_LENGTH 512 170 170 ··· 173 173 { 174 174 struct tracepoint_path *path = NULL; 175 175 DIR *sys_dir, *evt_dir; 176 - struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 176 + struct dirent *sys_dirent, *evt_dirent; 177 177 char id_buf[24]; 178 178 int fd; 179 179 u64 id; ··· 184 184 if (!sys_dir) 185 185 return NULL; 186 186 187 - for_each_subsystem(sys_dir, sys_dirent, sys_next) { 187 + for_each_subsystem(sys_dir, sys_dirent) { 188 188 189 189 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, 190 - sys_dirent.d_name); 190 + sys_dirent->d_name); 191 191 evt_dir = opendir(dir_path); 192 192 if (!evt_dir) 193 193 continue; 194 194 195 - for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { 195 + for_each_event(sys_dirent, evt_dir, evt_dirent) { 196 196 197 197 snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path, 198 - evt_dirent.d_name); 198 + evt_dirent->d_name); 199 199 fd = open(evt_path, O_RDONLY); 200 200 if (fd < 0) 201 201 continue; ··· 220 220 free(path); 221 221 return NULL; 222 222 } 223 - strncpy(path->system, sys_dirent.d_name, 223 + strncpy(path->system, sys_dirent->d_name, 224 224 MAX_EVENT_LENGTH); 225 - strncpy(path->name, evt_dirent.d_name, 225 + strncpy(path->name, evt_dirent->d_name, 226 226 MAX_EVENT_LENGTH); 227 227 return path; 228 228 } ··· 1812 1812 bool name_only) 1813 1813 { 1814 1814 DIR *sys_dir, *evt_dir; 1815 - struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 1815 + struct dirent *sys_dirent, *evt_dirent; 1816 1816 char evt_path[MAXPATHLEN]; 1817 1817 char dir_path[MAXPATHLEN]; 1818 1818 char **evt_list = NULL; ··· 1830 1830 goto out_close_sys_dir; 1831 1831 } 1832 1832 1833 - for_each_subsystem(sys_dir, sys_dirent, sys_next) { 1833 + for_each_subsystem(sys_dir, sys_dirent) { 1834 1834 if (subsys_glob != NULL && 1835 - !strglobmatch(sys_dirent.d_name, subsys_glob)) 1835 + !strglobmatch(sys_dirent->d_name, subsys_glob)) 1836 1836 continue; 1837 1837 1838 1838 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, 1839 - sys_dirent.d_name); 1839 + sys_dirent->d_name); 1840 1840 evt_dir = opendir(dir_path); 1841 1841 if (!evt_dir) 1842 1842 continue; 1843 1843 1844 - for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { 1844 + for_each_event(sys_dirent, evt_dir, evt_dirent) { 1845 1845 if (event_glob != NULL && 1846 - !strglobmatch(evt_dirent.d_name, event_glob)) 1846 + !strglobmatch(evt_dirent->d_name, event_glob)) 1847 1847 continue; 1848 1848 1849 1849 if (!evt_num_known) { ··· 1852 1852 } 1853 1853 1854 1854 snprintf(evt_path, MAXPATHLEN, "%s:%s", 1855 - sys_dirent.d_name, evt_dirent.d_name); 1855 + sys_dirent->d_name, evt_dirent->d_name); 1856 1856 1857 1857 evt_list[evt_i] = strdup(evt_path); 1858 1858 if (evt_list[evt_i] == NULL) ··· 1905 1905 int is_valid_tracepoint(const char *event_string) 1906 1906 { 1907 1907 DIR *sys_dir, *evt_dir; 1908 - struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 1908 + struct dirent *sys_dirent, *evt_dirent; 1909 1909 char evt_path[MAXPATHLEN]; 1910 1910 char dir_path[MAXPATHLEN]; 1911 1911 ··· 1913 1913 if (!sys_dir) 1914 1914 return 0; 1915 1915 1916 - for_each_subsystem(sys_dir, sys_dirent, sys_next) { 1916 + for_each_subsystem(sys_dir, sys_dirent) { 1917 1917 1918 1918 snprintf(dir_path, MAXPATHLEN, "%s/%s", tracing_events_path, 1919 - sys_dirent.d_name); 1919 + sys_dirent->d_name); 1920 1920 evt_dir = opendir(dir_path); 1921 1921 if (!evt_dir) 1922 1922 continue; 1923 1923 1924 - for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next) { 1924 + for_each_event(sys_dirent, evt_dir, evt_dirent) { 1925 1925 snprintf(evt_path, MAXPATHLEN, "%s:%s", 1926 - sys_dirent.d_name, evt_dirent.d_name); 1926 + sys_dirent->d_name, evt_dirent->d_name); 1927 1927 if (!strcmp(evt_path, event_string)) { 1928 1928 closedir(evt_dir); 1929 1929 closedir(sys_dir);
+3
tools/perf/util/sort.c
··· 2445 2445 2446 2446 static char *setup_overhead(char *keys) 2447 2447 { 2448 + if (sort__mode == SORT_MODE__DIFF) 2449 + return keys; 2450 + 2448 2451 keys = prefix_if_not_in("overhead", keys); 2449 2452 2450 2453 if (symbol_conf.cumulate_callchain)
+4 -4
tools/perf/util/thread_map.c
··· 94 94 DIR *proc; 95 95 int max_threads = 32, items, i; 96 96 char path[256]; 97 - struct dirent dirent, *next, **namelist = NULL; 97 + struct dirent *dirent, **namelist = NULL; 98 98 struct thread_map *threads = thread_map__alloc(max_threads); 99 99 100 100 if (threads == NULL) ··· 107 107 threads->nr = 0; 108 108 atomic_set(&threads->refcnt, 1); 109 109 110 - while (!readdir_r(proc, &dirent, &next) && next) { 110 + while ((dirent = readdir(proc)) != NULL) { 111 111 char *end; 112 112 bool grow = false; 113 113 struct stat st; 114 - pid_t pid = strtol(dirent.d_name, &end, 10); 114 + pid_t pid = strtol(dirent->d_name, &end, 10); 115 115 116 116 if (*end) /* only interested in proper numerical dirents */ 117 117 continue; 118 118 119 - snprintf(path, sizeof(path), "/proc/%s", dirent.d_name); 119 + snprintf(path, sizeof(path), "/proc/%s", dirent->d_name); 120 120 121 121 if (stat(path, &st) != 0) 122 122 continue;