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:
"Mostly tooling fixes, but also two PMU driver fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf tools powerpc: Use dwfl_report_elf() instead of offline.
perf tools: Fix segfault for symbol annotation on TUI
perf test: Fix dwarf unwind using libunwind.
perf tools: Avoid build splat for syscall numbers with uclibc
perf tools: Elide strlcpy warning with uclibc
perf tools: Fix statfs.f_type data type mismatch build error with uclibc
tools: Remove bitops/hweight usage of bits in tools/perf
perf machine: Fix __machine__findnew_thread() error path
perf tools: Fix building error in x86_64 when dwarf unwind is on
perf probe: Propagate error code when write(2) failed
perf/x86/intel: Fix bug for "cycles:p" and "cycles:pp" on SLM
perf/rapl: Fix sysfs_show() initialization for RAPL PMU

+165 -96
+2 -2
arch/x86/kernel/cpu/perf_event_intel_ds.c
··· 568 568 }; 569 569 570 570 struct event_constraint intel_slm_pebs_event_constraints[] = { 571 - /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ 572 - INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), 571 + /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ 572 + INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x1), 573 573 /* Allow all events as PEBS with no flags */ 574 574 INTEL_ALL_EVENT_CONSTRAINT(0, 0x1), 575 575 EVENT_CONSTRAINT_END
+32 -12
arch/x86/kernel/cpu/perf_event_intel_rapl.c
··· 103 103 104 104 #define RAPL_CNTR_WIDTH 32 /* 32-bit rapl counters */ 105 105 106 + #define RAPL_EVENT_ATTR_STR(_name, v, str) \ 107 + static struct perf_pmu_events_attr event_attr_##v = { \ 108 + .attr = __ATTR(_name, 0444, rapl_sysfs_show, NULL), \ 109 + .id = 0, \ 110 + .event_str = str, \ 111 + }; 112 + 106 113 struct rapl_pmu { 107 114 spinlock_t lock; 108 115 int hw_unit; /* 1/2^hw_unit Joule */ ··· 386 379 .attrs = rapl_pmu_attrs, 387 380 }; 388 381 389 - EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); 390 - EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); 391 - EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); 392 - EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); 382 + static ssize_t rapl_sysfs_show(struct device *dev, 383 + struct device_attribute *attr, 384 + char *page) 385 + { 386 + struct perf_pmu_events_attr *pmu_attr = \ 387 + container_of(attr, struct perf_pmu_events_attr, attr); 393 388 394 - EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); 395 - EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); 396 - EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); 397 - EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); 389 + if (pmu_attr->event_str) 390 + return sprintf(page, "%s", pmu_attr->event_str); 391 + 392 + return 0; 393 + } 394 + 395 + RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); 396 + RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); 397 + RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); 398 + RAPL_EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); 399 + 400 + RAPL_EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); 401 + RAPL_EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); 402 + RAPL_EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); 403 + RAPL_EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); 398 404 399 405 /* 400 406 * we compute in 0.23 nJ increments regardless of MSR 401 407 */ 402 - EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890625e-10"); 403 - EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10"); 404 - EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); 405 - EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); 408 + RAPL_EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890625e-10"); 409 + RAPL_EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10"); 410 + RAPL_EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); 411 + RAPL_EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); 406 412 407 413 static struct attribute *rapl_events_srv_attr[] = { 408 414 EVENT_PTR(rapl_cores),
+2
tools/include/asm-generic/bitops.h
··· 22 22 #error only <linux/bitops.h> can be included directly 23 23 #endif 24 24 25 + #include <asm-generic/bitops/hweight.h> 26 + 25 27 #include <asm-generic/bitops/atomic.h> 26 28 27 29 #endif /* __TOOLS_ASM_GENERIC_BITOPS_H */
+1
tools/include/asm-generic/bitops/arch_hweight.h
··· 1 + #include "../../../../include/asm-generic/bitops/arch_hweight.h"
+1
tools/include/asm-generic/bitops/const_hweight.h
··· 1 + #include "../../../../include/asm-generic/bitops/const_hweight.h"
+7
tools/include/asm-generic/bitops/hweight.h
··· 1 + #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ 2 + #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ 3 + 4 + #include <asm-generic/bitops/arch_hweight.h> 5 + #include <asm-generic/bitops/const_hweight.h> 6 + 7 + #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ */
+6 -1
tools/include/linux/bitops.h
··· 1 1 #ifndef _TOOLS_LINUX_BITOPS_H_ 2 2 #define _TOOLS_LINUX_BITOPS_H_ 3 3 4 + #include <asm/types.h> 4 5 #include <linux/kernel.h> 5 6 #include <linux/compiler.h> 6 - #include <asm/hweight.h> 7 7 8 8 #ifndef __WORDSIZE 9 9 #define __WORDSIZE (__SIZEOF_LONG__ * 8) ··· 18 18 #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) 19 19 #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) 20 20 #define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE) 21 + 22 + extern unsigned int __sw_hweight8(unsigned int w); 23 + extern unsigned int __sw_hweight16(unsigned int w); 24 + extern unsigned int __sw_hweight32(unsigned int w); 25 + extern unsigned long __sw_hweight64(__u64 w); 21 26 22 27 /* 23 28 * Include this here because some architectures need generic_ffs/fls in
+1 -1
tools/lib/api/fs/debugfs.c
··· 67 67 68 68 if (statfs(debugfs, &st_fs) < 0) 69 69 return -ENOENT; 70 - else if (st_fs.f_type != (long) DEBUGFS_MAGIC) 70 + else if ((long)st_fs.f_type != (long)DEBUGFS_MAGIC) 71 71 return -ENOENT; 72 72 73 73 return 0;
+1 -1
tools/lib/api/fs/fs.c
··· 79 79 80 80 if (statfs(fs, &st_fs) < 0) 81 81 return -ENOENT; 82 - else if (st_fs.f_type != magic) 82 + else if ((long)st_fs.f_type != magic) 83 83 return -ENOENT; 84 84 85 85 return 0;
+6
tools/perf/MANIFEST
··· 6 6 tools/lib/symbol/kallsyms.h 7 7 tools/lib/util/find_next_bit.c 8 8 tools/include/asm/bug.h 9 + tools/include/asm-generic/bitops/arch_hweight.h 9 10 tools/include/asm-generic/bitops/atomic.h 11 + tools/include/asm-generic/bitops/const_hweight.h 10 12 tools/include/asm-generic/bitops/__ffs.h 11 13 tools/include/asm-generic/bitops/__fls.h 12 14 tools/include/asm-generic/bitops/find.h 13 15 tools/include/asm-generic/bitops/fls64.h 14 16 tools/include/asm-generic/bitops/fls.h 17 + tools/include/asm-generic/bitops/hweight.h 15 18 tools/include/asm-generic/bitops.h 16 19 tools/include/linux/bitops.h 17 20 tools/include/linux/compiler.h ··· 22 19 tools/include/linux/hash.h 23 20 tools/include/linux/log2.h 24 21 tools/include/linux/types.h 22 + include/asm-generic/bitops/arch_hweight.h 23 + include/asm-generic/bitops/const_hweight.h 25 24 include/asm-generic/bitops/fls64.h 26 25 include/asm-generic/bitops/__fls.h 27 26 include/asm-generic/bitops/fls.h ··· 34 29 include/linux/hash.h 35 30 include/linux/stringify.h 36 31 lib/find_next_bit.c 32 + lib/hweight.c 37 33 lib/rbtree.c 38 34 include/linux/swab.h 39 35 arch/*/include/asm/unistd*.h
+9 -2
tools/perf/Makefile.perf
··· 232 232 LIB_H += ../../include/linux/stringify.h 233 233 LIB_H += util/include/linux/bitmap.h 234 234 LIB_H += ../include/linux/bitops.h 235 + LIB_H += ../include/asm-generic/bitops/arch_hweight.h 235 236 LIB_H += ../include/asm-generic/bitops/atomic.h 237 + LIB_H += ../include/asm-generic/bitops/const_hweight.h 236 238 LIB_H += ../include/asm-generic/bitops/find.h 237 239 LIB_H += ../include/asm-generic/bitops/fls64.h 238 240 LIB_H += ../include/asm-generic/bitops/fls.h 239 241 LIB_H += ../include/asm-generic/bitops/__ffs.h 240 242 LIB_H += ../include/asm-generic/bitops/__fls.h 243 + LIB_H += ../include/asm-generic/bitops/hweight.h 241 244 LIB_H += ../include/asm-generic/bitops.h 242 245 LIB_H += ../include/linux/compiler.h 243 246 LIB_H += ../include/linux/log2.h ··· 258 255 LIB_H += util/include/asm/asm-offsets.h 259 256 LIB_H += ../include/asm/bug.h 260 257 LIB_H += util/include/asm/byteorder.h 261 - LIB_H += util/include/asm/hweight.h 262 258 LIB_H += util/include/asm/swab.h 263 259 LIB_H += util/include/asm/system.h 264 260 LIB_H += util/include/asm/uaccess.h ··· 464 462 # Benchmark modules 465 463 BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o 466 464 BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o 467 - ifeq ($(RAW_ARCH),x86_64) 465 + ifeq ($(ARCH), x86) 466 + ifeq ($(IS_64_BIT), 1) 468 467 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o 469 468 BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o 469 + endif 470 470 endif 471 471 BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o 472 472 BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o ··· 745 741 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< 746 742 747 743 $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS 744 + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 745 + 746 + $(OUTPUT)util/hweight.o: ../../lib/hweight.c $(OUTPUT)PERF-CFLAGS 748 747 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 749 748 750 749 $(OUTPUT)util/find_next_bit.o: ../lib/util/find_next_bit.c $(OUTPUT)PERF-CFLAGS
+11 -8
tools/perf/arch/powerpc/util/skip-callchain-idx.c
··· 103 103 return NULL; 104 104 } 105 105 106 - result = dwarf_cfi_addrframe(cfi, pc, &frame); 106 + result = dwarf_cfi_addrframe(cfi, pc-bias, &frame); 107 107 if (result) { 108 108 pr_debug("%s(): %s\n", __func__, dwfl_errmsg(-1)); 109 109 return NULL; ··· 128 128 return NULL; 129 129 } 130 130 131 - result = dwarf_cfi_addrframe(cfi, pc, &frame); 131 + result = dwarf_cfi_addrframe(cfi, pc-bias, &frame); 132 132 if (result) { 133 133 pr_debug("%s(): %s\n", __func__, dwfl_errmsg(-1)); 134 134 return NULL; ··· 145 145 * yet used) 146 146 * -1 in case of errors 147 147 */ 148 - static int check_return_addr(struct dso *dso, Dwarf_Addr pc) 148 + static int check_return_addr(struct dso *dso, u64 map_start, Dwarf_Addr pc) 149 149 { 150 150 int rc = -1; 151 151 Dwfl *dwfl; ··· 155 155 Dwarf_Addr start = pc; 156 156 Dwarf_Addr end = pc; 157 157 bool signalp; 158 + const char *exec_file = dso->long_name; 158 159 159 160 dwfl = dso->dwfl; 160 161 ··· 166 165 return -1; 167 166 } 168 167 169 - if (dwfl_report_offline(dwfl, "", dso->long_name, -1) == NULL) { 170 - pr_debug("dwfl_report_offline() failed %s\n", 168 + mod = dwfl_report_elf(dwfl, exec_file, exec_file, -1, 169 + map_start, false); 170 + if (!mod) { 171 + pr_debug("dwfl_report_elf() failed %s\n", 171 172 dwarf_errmsg(-1)); 172 173 /* 173 174 * We normally cache the DWARF debug info and never ··· 259 256 return skip_slot; 260 257 } 261 258 262 - rc = check_return_addr(dso, ip); 259 + rc = check_return_addr(dso, al.map->start, ip); 263 260 264 - pr_debug("DSO %s, nr %" PRIx64 ", ip 0x%" PRIx64 "rc %d\n", 265 - dso->long_name, chain->nr, ip, rc); 261 + pr_debug("[DSO %s, sym %s, ip 0x%" PRIx64 "] rc %d\n", 262 + dso->long_name, al.sym->name, ip, rc); 266 263 267 264 if (rc == 0) { 268 265 /*
+1 -1
tools/perf/bench/sched-pipe.c
··· 19 19 #include <stdlib.h> 20 20 #include <signal.h> 21 21 #include <sys/wait.h> 22 - #include <linux/unistd.h> 23 22 #include <string.h> 24 23 #include <errno.h> 25 24 #include <assert.h> 26 25 #include <sys/time.h> 27 26 #include <sys/types.h> 27 + #include <sys/syscall.h> 28 28 29 29 #include <pthread.h> 30 30
-1
tools/perf/builtin-top.c
··· 66 66 #include <sys/utsname.h> 67 67 #include <sys/mman.h> 68 68 69 - #include <linux/unistd.h> 70 69 #include <linux/types.h> 71 70 72 71 static volatile int done;
+1 -1
tools/perf/config/Makefile
··· 20 20 21 21 # Additional ARCH settings for x86 22 22 ifeq ($(ARCH),x86) 23 - ifeq (${IS_X86_64}, 1) 23 + ifeq (${IS_64_BIT}, 1) 24 24 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT 25 25 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 26 26 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
+13 -13
tools/perf/config/Makefile.arch
··· 1 1 2 2 uname_M := $(shell uname -m 2>/dev/null || echo not) 3 3 4 - ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ 4 + RAW_ARCH := $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ 5 5 -e s/arm.*/arm/ -e s/sa110/arm/ \ 6 6 -e s/s390x/s390/ -e s/parisc64/parisc/ \ 7 7 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ ··· 9 9 -e s/tile.*/tile/ ) 10 10 11 11 # Additional ARCH settings for x86 12 - ifeq ($(ARCH),i386) 13 - override ARCH := x86 12 + ifeq ($(RAW_ARCH),i386) 13 + ARCH ?= x86 14 14 endif 15 15 16 - ifeq ($(ARCH),x86_64) 17 - override ARCH := x86 18 - IS_X86_64 := 0 19 - ifeq (, $(findstring m32,$(CFLAGS))) 20 - IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) 21 - RAW_ARCH := x86_64 16 + ifeq ($(RAW_ARCH),x86_64) 17 + ARCH ?= x86 18 + 19 + ifneq (, $(findstring m32,$(CFLAGS))) 20 + RAW_ARCH := x86_32 22 21 endif 23 22 endif 24 23 25 - ifeq (${IS_X86_64}, 1) 24 + ARCH ?= $(RAW_ARCH) 25 + 26 + LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) 27 + ifeq ($(LP64), 1) 26 28 IS_64_BIT := 1 27 - else ifeq ($(ARCH),x86) 28 - IS_64_BIT := 0 29 29 else 30 - IS_64_BIT := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) 30 + IS_64_BIT := 0 31 31 endif
-1
tools/perf/perf-sys.h
··· 6 6 #include <sys/syscall.h> 7 7 #include <linux/types.h> 8 8 #include <linux/perf_event.h> 9 - #include <asm/unistd.h> 10 9 11 10 #if defined(__i386__) 12 11 #define mb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
+34 -2
tools/perf/tests/dwarf-unwind.c
··· 11 11 #include "thread.h" 12 12 #include "callchain.h" 13 13 14 + /* For bsearch. We try to unwind functions in shared object. */ 15 + #include <stdlib.h> 16 + 14 17 static int mmap_handler(struct perf_tool *tool __maybe_unused, 15 18 union perf_event *event, 16 19 struct perf_sample *sample __maybe_unused, ··· 31 28 mmap_handler, machine, true); 32 29 } 33 30 34 - #define MAX_STACK 6 31 + #define MAX_STACK 8 35 32 36 33 static int unwind_entry(struct unwind_entry *entry, void *arg) 37 34 { ··· 40 37 static const char *funcs[MAX_STACK] = { 41 38 "test__arch_unwind_sample", 42 39 "unwind_thread", 40 + "compare", 41 + "bsearch", 43 42 "krava_3", 44 43 "krava_2", 45 44 "krava_1", ··· 93 88 return err; 94 89 } 95 90 91 + static int global_unwind_retval = -INT_MAX; 92 + 93 + __attribute__ ((noinline)) 94 + static int compare(void *p1, void *p2) 95 + { 96 + /* Any possible value should be 'thread' */ 97 + struct thread *thread = *(struct thread **)p1; 98 + 99 + if (global_unwind_retval == -INT_MAX) 100 + global_unwind_retval = unwind_thread(thread); 101 + 102 + return p1 - p2; 103 + } 104 + 96 105 __attribute__ ((noinline)) 97 106 static int krava_3(struct thread *thread) 98 107 { 99 - return unwind_thread(thread); 108 + struct thread *array[2] = {thread, thread}; 109 + void *fp = &bsearch; 110 + /* 111 + * make _bsearch a volatile function pointer to 112 + * prevent potential optimization, which may expand 113 + * bsearch and call compare directly from this function, 114 + * instead of libc shared object. 115 + */ 116 + void *(*volatile _bsearch)(void *, void *, size_t, 117 + size_t, int (*)(void *, void *)); 118 + 119 + _bsearch = fp; 120 + _bsearch(array, &thread, 2, sizeof(struct thread **), compare); 121 + return global_unwind_retval; 100 122 } 101 123 102 124 __attribute__ ((noinline))
+1 -7
tools/perf/util/annotate.h
··· 116 116 struct annotated_source *src; 117 117 }; 118 118 119 - struct sannotation { 120 - struct annotation annotation; 121 - struct symbol symbol; 122 - }; 123 - 124 119 static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx) 125 120 { 126 121 return (((void *)&notes->src->histograms) + ··· 124 129 125 130 static inline struct annotation *symbol__annotation(struct symbol *sym) 126 131 { 127 - struct sannotation *a = container_of(sym, struct sannotation, symbol); 128 - return &a->annotation; 132 + return (void *)sym - symbol_conf.priv_size; 129 133 } 130 134 131 135 int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx);
+2
tools/perf/util/cache.h
··· 71 71 extern char *perf_pathdup(const char *fmt, ...) 72 72 __attribute__((format (printf, 1, 2))); 73 73 74 + #ifndef __UCLIBC__ 74 75 /* Matches the libc/libbsd function attribute so we declare this unconditionally: */ 75 76 extern size_t strlcpy(char *dest, const char *src, size_t size); 77 + #endif 76 78 77 79 #endif /* __PERF_CACHE_H */
-31
tools/perf/util/hweight.c
··· 1 - #include <linux/bitops.h> 2 - 3 - /** 4 - * hweightN - returns the hamming weight of a N-bit word 5 - * @x: the word to weigh 6 - * 7 - * The Hamming Weight of a number is the total number of bits set in it. 8 - */ 9 - 10 - unsigned int hweight32(unsigned int w) 11 - { 12 - unsigned int res = w - ((w >> 1) & 0x55555555); 13 - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); 14 - res = (res + (res >> 4)) & 0x0F0F0F0F; 15 - res = res + (res >> 8); 16 - return (res + (res >> 16)) & 0x000000FF; 17 - } 18 - 19 - unsigned long hweight64(__u64 w) 20 - { 21 - #if BITS_PER_LONG == 32 22 - return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); 23 - #elif BITS_PER_LONG == 64 24 - __u64 res = w - ((w >> 1) & 0x5555555555555555ul); 25 - res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); 26 - res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; 27 - res = res + (res >> 8); 28 - res = res + (res >> 16); 29 - return (res + (res >> 32)) & 0x00000000000000FFul; 30 - #endif 31 - }
-8
tools/perf/util/include/asm/hweight.h
··· 1 - #ifndef PERF_HWEIGHT_H 2 - #define PERF_HWEIGHT_H 3 - 4 - #include <linux/types.h> 5 - unsigned int hweight32(unsigned int w); 6 - unsigned long hweight64(__u64 w); 7 - 8 - #endif /* PERF_HWEIGHT_H */
+3 -1
tools/perf/util/machine.c
··· 389 389 if (th != NULL) { 390 390 rb_link_node(&th->rb_node, parent, p); 391 391 rb_insert_color(&th->rb_node, &machine->threads); 392 - machine->last_match = th; 393 392 394 393 /* 395 394 * We have to initialize map_groups separately ··· 399 400 * leader and that would screwed the rb tree. 400 401 */ 401 402 if (thread__init_map_groups(th, machine)) { 403 + rb_erase(&th->rb_node, &machine->threads); 402 404 thread__delete(th); 403 405 return NULL; 404 406 } 407 + 408 + machine->last_match = th; 405 409 } 406 410 407 411 return th;
+3 -1
tools/perf/util/probe-event.c
··· 2052 2052 pr_debug("Writing event: %s\n", buf); 2053 2053 if (!probe_event_dry_run) { 2054 2054 ret = write(fd, buf, strlen(buf)); 2055 - if (ret <= 0) 2055 + if (ret <= 0) { 2056 + ret = -errno; 2056 2057 pr_warning("Failed to write event: %s\n", 2057 2058 strerror_r(errno, sbuf, sizeof(sbuf))); 2059 + } 2058 2060 } 2059 2061 free(buf); 2060 2062 return ret;
+1 -1
tools/perf/util/python-ext-sources
··· 10 10 util/evlist.c 11 11 util/evsel.c 12 12 util/cpumap.c 13 - util/hweight.c 13 + ../../lib/hweight.c 14 14 util/thread_map.c 15 15 util/util.c 16 16 util/xyarray.c
+27 -1
tools/perf/util/unwind-libunwind.c
··· 185 185 return offset; 186 186 } 187 187 188 + #ifndef NO_LIBUNWIND_DEBUG_FRAME 189 + static int elf_is_exec(int fd, const char *name) 190 + { 191 + Elf *elf; 192 + GElf_Ehdr ehdr; 193 + int retval = 0; 194 + 195 + elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); 196 + if (elf == NULL) 197 + return 0; 198 + if (gelf_getehdr(elf, &ehdr) == NULL) 199 + goto out; 200 + 201 + retval = (ehdr.e_type == ET_EXEC); 202 + 203 + out: 204 + elf_end(elf); 205 + pr_debug("unwind: elf_is_exec(%s): %d\n", name, retval); 206 + return retval; 207 + } 208 + #endif 209 + 188 210 struct table_entry { 189 211 u32 start_ip_offset; 190 212 u32 fde_offset; ··· 344 322 #ifndef NO_LIBUNWIND_DEBUG_FRAME 345 323 /* Check the .debug_frame section for unwinding info */ 346 324 if (!read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) { 325 + int fd = dso__data_fd(map->dso, ui->machine); 326 + int is_exec = elf_is_exec(fd, map->dso->name); 327 + unw_word_t base = is_exec ? 0 : map->start; 328 + 347 329 memset(&di, 0, sizeof(di)); 348 - if (dwarf_find_debug_frame(0, &di, ip, 0, map->dso->name, 330 + if (dwarf_find_debug_frame(0, &di, ip, base, map->dso->name, 349 331 map->start, map->end)) 350 332 return dwarf_search_unwind_table(as, ip, &di, pi, 351 333 need_unwind_info, arg);